DocsGuidesRust Testing & Security

Rust Converter — Testing & Security Guide

Quick reference for building, testing, and auditing the Rust converter in converters/rust/.


Prerequisites

rustc --version
cargo --version
 
# If not available:
source ~/.cargo/env

Quick Commands

CommandPurpose
cargo buildCompile the project
cargo test --libRun unit tests only
cargo test --all-featuresRun all tests
cargo check --all-featuresFast validation (no link)
cargo clippy --all-features -- -D warningsLint with Clippy
cargo fmtFormat code
cargo doc --openGenerate and view docs
cargo cleanRemove build artifacts

Security Testing

Full Security Audit

# From project root:
./scripts/rust-security-audit.sh

This runs:

  • cargo check — compilation validation
  • cargo audit — dependency vulnerability scan
  • cargo geiger — unsafe code detection
  • cargo deny — license and security compliance

Reports are saved to converters/rust/security-reports/.

Manual Commands

cd converters/rust
 
cargo audit          # Vulnerability scan
cargo geiger --all-features  # Unsafe code detection
cargo deny check     # License checking (requires deny.toml)

Installing Security Tools (one-time)

cargo install cargo-audit
cargo install cargo-geiger
cargo install cargo-deny
cargo install cargo-fuzz   # optional

Development Workflow

Before Every Commit

cargo fmt
cargo clippy --all-features -- -D warnings
cargo test --all-features
cargo audit
cargo geiger --all-features

CI Pipeline

The .github/workflows/ci.yml runs all of the above automatically on every push, plus:

  • Rust stable and beta channels
  • Tarpaulin coverage (cobertura format → Codecov)

Advanced Testing

Fuzzing

cargo fuzz init
cargo fuzz add json_to_graphql
cargo fuzz run json_to_graphql

Code Coverage

cargo install cargo-tarpaulin
cargo tarpaulin --out Html

Benchmarks

cargo bench

Common Issues

ProblemSolution
rustc: command not foundsource ~/.cargo/env
Security tools not foundcargo install cargo-audit cargo-geiger cargo-deny
Tests fail to compilecd converters/rust && cargo clean && cargo build