This patch makes ai-rsk simpler to use for developers and non-developers, more pedagogical in its output, and self-compliant (ai-rsk passes its own scan at 100/100).
- Running
ai-rskwithout any subcommand now scans the current directory. - No need to type
ai-rsk scanunless passing options. ai-rsk --helpandai-rsk --versionstill work as expected.- File:
src/main.rs- fallback onMissingSubcommand/DisplayHelpOnMissingArgumentOrSubcommanderror kinds, injects"scan"into args and reparses.
- New subcommand to update ai-rsk to the latest version.
- Checks crates.io for the latest version, compares with current.
- If newer: tries
cargo install ai-rskfirst, falls back to GitHub Releases binary download. - If up to date: prints confirmation and exits.
- The version check notification (
check_for_update()) now saysRun: ai-rsk updateinstead ofcargo install ai-rsk. - Files:
src/cli.rs(newUpdatevariant),src/version.rs(newrun_self_update()function),src/main.rs(handler).
- Every scan now displays a security score:
Security Score: 72/100. - Formula:
100 - (BLOCK * 15 + WARN * 5 + ADVISE * 1), floor at 0. - Color-coded: green (80+), yellow (50-79), red (0-49).
- Present in terminal output, JSON output (
security_scorefield), andreport.md. - File:
src/types.rs(newsecurity_score()method),src/main.rs(display).
- After displaying findings, ai-rsk now tells the user what to do:
- "Fix the 3 BLOCK findings first - the build is blocked until they are resolved."
- "Then address the 2 WARNs (they become BLOCK with --strict)."
- "After fixing, run
ai-rsk scanto verify."
- On PASS: "All clear. Report saved to .ai-rsk/report.md"
- File:
src/main.rs(guidance block after result display).
- Each finding with CWE identifiers now displays a direct link to cwe.mitre.org.
- Terminal:
Ref: CWE-89 (https://cwe.mitre.org/data/definitions/89.html) - report.md:
[CWE-89](https://cwe.mitre.org/data/definitions/89.html)(clickable markdown link). - No hardcoded descriptions - the CWE database is the source of truth.
- Files:
src/main.rs(terminal display),src/types.rs(report.md generation).
- Static messages replaced with numbered steps:
[1/3] Running external tools...[2/3] Scanning 58 rules...[3/3] Analyzing project structure...
- File:
src/main.rs.
ai-rsk --helpnow shows:- Quick start guide (3 steps)
- "No subcommand needed" note
- Concrete examples for every command
ai-rsk scan --helpshows usage examples and a tip about the default command.ai-rsk init --help,ai-rsk check --help,ai-rsk update --helpall have context.aboutchanged from "AI Rust Security Keeper" to "Security gate for AI-generated code. Scans, blocks, and educates."- File:
src/cli.rs(clapafter_helpattributes on each command).
ai-rsk now passes its own scan at 100/100 (PASS, 0B 0W 0A).
Semgrep's rust.actix ruleset flagged 6 findings in ai-rsk's source code:
- 5x
rust.actix.path-traversal.tainted-pathin config.rs, init.rs, rules.rs - 1x
rust.actix.command-injectionin runner.rs
Why these are false positives: ai-rsk is a CLI tool, not an Actix web server. All file paths come from the user's CLI arguments on their own machine (not network input). All binary names in Command::new() are hardcoded strings in tools.rs, not user-supplied input.
Resolution: Excluded via ai-rsk.config.yaml with semgrep_exclude_rules. The config file includes the justification.
Gitleaks detected 3 "secrets" in the codebase:
- 1x
stripe-access-tokenintests/fixtures/vulnerable/real-world-patterns.js:25- a fake Stripe token (sk_test_51ABC123...) used as a test fixture to verify ai-rsk detects secrets. - 2x
generic-api-keyinrules/hardcoded-secret.yaml:40,55- fake API keys used as examples in the YAML rule documentation.
Why these are false positives: These are test fixtures and documentation examples by design. They are not real secrets.
Resolution: Excluded via .gitleaksignore with fingerprints. Each entry has a comment explaining why.
Installed cargo-audit (recommended tool for Rust projects). ai-rsk now detects and lists it.
ai-rsk.config.yaml- ai-rsk configuration for the ai-rsk project itself.gitleaksignore- Gitleaks false positive exclusions with justifications
| Test | Result |
|---|---|
cargo test |
187 passed, 0 failed |
cargo clippy |
0 warnings |
cargo build --release |
success |
| Test | Input | Expected | Result |
|---|---|---|---|
| Default command | ai-rsk (no args) |
Scans current directory | PASS |
| Help | ai-rsk --help |
Quick start + examples | PASS |
| Version | ai-rsk --version |
Shows version | PASS |
| Scan help | ai-rsk scan --help |
Examples + tip | PASS |
| Update (no network) | ai-rsk update |
"Could not reach crates.io" message | PASS |
| JSON output | ai-rsk scan --json |
security_score field present |
PASS |
| Self-scan | ai-rsk scan on ai-rsk |
PASS 100/100, 0B 0W 0A | PASS |
| Real project scan | ai-rsk scan on ai-alixia |
BLOCKED with findings (expected) | PASS |
test_security_score_perfect- 0 findings = 100/100test_security_score_with_findings- 2B + 1W + 3A = 62/100test_security_score_floor_at_zero- 10B = 0/100 (not negative)
- Total tests: 187 (184 previous + 3 new)
- 0 clippy warnings
- Self-scan: PASS 100/100