Security Scanning
Unified security assessment for regulated industries. Modes: static (SAST with semgrep), deps (pip-audit/npm audit), secrets (gitleaks), sbom (CycloneDX). Zero tolerance for medium+ findings. Each finding includes severity, location, fix suggestion, and CWE reference.
When to Use
- Security review, pre-release gate, dependency audit, compliance reporting.
- NOT for code quality metrics -- use
/ai-quality.
- NOT for governance compliance -- use
/ai-governance.
Modes
static -- SAST
- Detect stacks -- read project files for active languages.
- Secret detection --
gitleaks detect --source . --no-git. Any finding is critical.
- Semgrep --
semgrep scan --config auto --json. Parse for rule IDs, severity, CWE.
- Manual analysis -- review what tools miss:
- Authentication on every endpoint (A01)
- Parameterized queries only (A03)
- Secrets from env/vault, never hardcoded (A02)
- HTTP security headers (A05)
- No user-controlled URLs in HTTP clients (A10)
- Classify -- severity + OWASP category per finding.
deps -- Dependency Audit
- Detect lock files --
uv.lock, package-lock.json, Cargo.lock, *.csproj.
- Run audit -- Python:
pip-audit --strict --desc. Node: npm audit --json. Rust: cargo audit --json.
- Assess exploitability -- mark unreachable paths as reduced severity with justification.
- Report with upgrade paths.
secrets -- Secret Detection
- Full scan --
gitleaks detect --source . --no-git --report-format json.
- Staged scan --
gitleaks protect --staged --no-banner.
- For each finding: file, line, rule, remediation (rotate credential, store in vault).
sbom -- Software Bill of Materials
- Generate --
cdxgen -o sbom.json --spec-version 1.5 (CycloneDX JSON).
- Validate -- all direct deps with versions, license info, package URLs.
- Flag license risks -- copyleft (GPL, AGPL) conflicting with project license.
--fix -- Auto-fix
When --fix is passed, attempt automatic remediation:
- Secrets: remove from source, add to
.gitignore, warn to rotate.
- Dependencies:
pip install --upgrade <pkg> for fixable vulns.
- Lint findings:
semgrep --autofix where rules support it.
- Report what was fixed and what requires manual intervention.
Severity Classification
| Severity |
Definition |
Gate Impact |
| Blocker |
Actively exploitable, breach imminent |
Blocks release |
| Critical |
High-impact, exploit feasible |
Blocks release |
| Major |
Significant risk, requires conditions |
Resolve before next release |
| Minor |
Low risk, defense-in-depth |
Resolve during maintenance |
Output Contract
# Security Report: [mode]
## Score: N/100
## Verdict: PASS (>=80) | WARN (60-79) | FAIL (<60)
## Findings
| # | Severity | OWASP | CWE | Description | Location | Fix |
|---|----------|-------|-----|-------------|----------|-----|
## Tool Outputs
- gitleaks: [N findings / clean]
- semgrep: [N findings / clean]
- pip-audit: [N findings / clean]
Quick Reference
/ai-security # run all modes
/ai-security static # SAST only
/ai-security deps # dependency audit only
/ai-security secrets # secret detection only
/ai-security sbom # generate SBOM
/ai-security deps --fix # audit + auto-fix
Common Mistakes
- Suppressing findings with
# nosec -- fix the root cause or use risk acceptance.
- Ignoring transitive dependency vulns -- they are still exploitable.
- Running
gitleaks detect on the full repo for pre-commit -- use gitleaks protect --staged.
Integration
- Pre-commit hook runs
gitleaks protect --staged automatically.
- Pre-push hook runs
semgrep and pip-audit.
- Release gate (
/ai-release) aggregates security results.
- Risk acceptances go to
state/decision-store.json via /ai-governance risk.
References
.ai-engineering/contexts/frameworks/ -- security and OWASP control mapping.
.ai-engineering/manifest.yml -- non-negotiables and gate thresholds.
$ARGUMENTS
1---2name: security-163description: Use when scanning for security vulnerabilities: SAST, dependency audit, secret detection, and SBOM generation with OWASP mapping and CWE references.4---5
6
7
8# Security Scanning
9
10Unified security assessment for regulated industries. Modes: `static` (SAST with semgrep), `deps` (pip-audit/npm audit), `secrets` (gitleaks), `sbom` (CycloneDX). Zero tolerance for medium+ findings. Each finding includes severity, location, fix suggestion, and CWE reference.
11
12## When to Use
13
14- Security review, pre-release gate, dependency audit, compliance reporting.
15- NOT for code quality metrics -- use `/ai-quality`.
16- NOT for governance compliance -- use `/ai-governance`.
17
18## Modes
19
20### static -- SAST
21
221. **Detect stacks** -- read project files for active languages.
232. **Secret detection** -- `gitleaks detect --source . --no-git`. Any finding is critical.
243. **Semgrep** -- `semgrep scan --config auto --json`. Parse for rule IDs, severity, CWE.
254. **Manual analysis** -- review what tools miss:
26 - Authentication on every endpoint (A01)
27 - Parameterized queries only (A03)
28 - Secrets from env/vault, never hardcoded (A02)
29 - HTTP security headers (A05)
30 - No user-controlled URLs in HTTP clients (A10)
315. **Classify** -- severity + OWASP category per finding.
32
33### deps -- Dependency Audit
34
351. **Detect lock files** -- `uv.lock`, `package-lock.json`, `Cargo.lock`, `*.csproj`.
362. **Run audit** -- Python: `pip-audit --strict --desc`. Node: `npm audit --json`. Rust: `cargo audit --json`.
373. **Assess exploitability** -- mark unreachable paths as reduced severity with justification.
384. **Report** with upgrade paths.
39
40### secrets -- Secret Detection
41
421. **Full scan** -- `gitleaks detect --source . --no-git --report-format json`.
432. **Staged scan** -- `gitleaks protect --staged --no-banner`.
443. **For each finding**: file, line, rule, remediation (rotate credential, store in vault).
45
46### sbom -- Software Bill of Materials
47
481. **Generate** -- `cdxgen -o sbom.json --spec-version 1.5` (CycloneDX JSON).
492. **Validate** -- all direct deps with versions, license info, package URLs.
503. **Flag license risks** -- copyleft (GPL, AGPL) conflicting with project license.
51
52### `--fix` -- Auto-fix
53
54When `--fix` is passed, attempt automatic remediation:
55- Secrets: remove from source, add to `.gitignore`, warn to rotate.
56- Dependencies: `pip install --upgrade <pkg>` for fixable vulns.
57- Lint findings: `semgrep --autofix` where rules support it.
58- Report what was fixed and what requires manual intervention.
59
60## Severity Classification
61
62| Severity | Definition | Gate Impact |
63|----------|-----------|-------------|
64| Blocker | Actively exploitable, breach imminent | Blocks release |
65| Critical | High-impact, exploit feasible | Blocks release |
66| Major | Significant risk, requires conditions | Resolve before next release |
67| Minor | Low risk, defense-in-depth | Resolve during maintenance |
68
69## Output Contract
70
71```markdown
72# Security Report: [mode]
73
74## Score: N/100
75## Verdict: PASS (>=80) | WARN (60-79) | FAIL (<60)
76
77## Findings
78| # | Severity | OWASP | CWE | Description | Location | Fix |
79|---|----------|-------|-----|-------------|----------|-----|
80
81## Tool Outputs
82- gitleaks: [N findings / clean]
83- semgrep: [N findings / clean]
84- pip-audit: [N findings / clean]
85```
86
87## Quick Reference
88
89```
90/ai-security # run all modes
91/ai-security static # SAST only
92/ai-security deps # dependency audit only
93/ai-security secrets # secret detection only
94/ai-security sbom # generate SBOM
95/ai-security deps --fix # audit + auto-fix
96```
97
98## Common Mistakes
99
100- Suppressing findings with `# nosec` -- fix the root cause or use risk acceptance.
101- Ignoring transitive dependency vulns -- they are still exploitable.
102- Running `gitleaks detect` on the full repo for pre-commit -- use `gitleaks protect --staged`.
103
104## Integration
105
106- Pre-commit hook runs `gitleaks protect --staged` automatically.
107- Pre-push hook runs `semgrep` and `pip-audit`.
108- Release gate (`/ai-release`) aggregates security results.
109- Risk acceptances go to `state/decision-store.json` via `/ai-governance risk`.
110
111## References
112
113- `.ai-engineering/contexts/frameworks/` -- security and OWASP control mapping.
114- `.ai-engineering/manifest.yml` -- non-negotiables and gate thresholds.
115$ARGUMENTS