Local Rules Pipelines: Secure Offline Threat Classification
G
Gary Gitton
• 5 min read
Rules Pipeline
Goal
Keep the secret detection catalog up to date without trusting live upstream downloads at runtime.
Files
resources/security/rules/canonical_rules.json: human-maintained source of truthresources/security/rules/imports/: optional upstream packs in TOML, JSON, or YAMLresources/security/generated_rules.json: generated runtime bundle embedded into the binarybin/rules_compiler.rs: local generator and CI checker.github/workflows/rules.yml: CI validation workflow
Workflow
- edit
resources/security/rules/canonical_rules.json - run
cargo run --bin rules_compiler - commit the regenerated
resources/security/generated_rules.json - let GitHub Actions run
cargo run --bin rules_compiler -- --check - run the test suite
Supported import shapes
- canonical
SecretRulearrays in JSON, TOML, or YAML RulePack { rules: [...] }- Gitleaks-style
[[rules]]packs withidandregex
Why this is safer
- the runtime never fetches untrusted rules on startup
- CI can verify the bundle before merge
- the embedded bundle is deterministic and versioned
- external packs can be added later as signed overlays
Test strategy
Use a small set of seed secrets and generate many positive/negative combinations on the fly:
- text wrappers: plain,
key=value,key: value, logs - structured data: nested JSON, YAML, TOML, config snippets
- negative controls: common words, docs phrases, and benign token-like strings
This catches false positives and false negatives without growing the fixture set too fast.
Runtime filtering
Refer to security_and_compliance.feature for business rules regarding strictness and confidence thresholds.
Crates
In Rust, a crate is a package unit. A crate can be:
- a library crate: reusable code exposed to other crates
- a binary crate: an executable built by Cargo
This project now uses both: the gateway library and the rules_compiler binary.
#Security
#Threat Modeling
#Gitleaks
#Rust Crate