Contributing
Adding a New CERT C Rule
Create the rule directory and implementation file:
src/rules/cert_c/CATEGORY/RULE-ID/rule_id_c.rs
Implement the
CertRuletrait:use crate::prelude::*; pub struct Mem30C; impl CertRule for Mem30C { fn rule_id(&self) -> &'static str { "MEM30-C" } fn description(&self) -> &'static str { "Do not access freed memory" } fn check( &self, node: &Node, source: &str, _context: &ProjectContext, ) -> Vec<RuleViolation> { // Implementation here Vec::new() } }
Register the rule in
src/rules/cert_c/mod.rs.Add test cases as
.cfiles insrc/rules/cert_c/CATEGORY/RULE-ID/tests/fail/andtests/pass/.Add the rule entry to
rules_templates/rules-all.toml.Build and test:
cargo build cargo test --package sqc --lib -- rules::cert_c::RULE_ID::tests cargo fmt
Build Requirements
Rust: 2021 edition (stable toolchain)
Platform: Linux, macOS, Windows (cross-platform via crossterm)
Dependencies: See
Cargo.tomlfor the full list
cargo build # Debug build
cargo build --release # Release build (optimized)
cargo test # Run all tests
cargo fmt # Format code