Move the code and terraform audits into the reviews plugin

Copy the standalone code-review and terraform-review skills into
plugins/reviews as audit-code and audit-terraform. The rename separates the
automated, linter-driven audits from the guided review-pr walkthrough that
already lived here.

Resolve bundled script paths through ${SKILL_DIR}, exported in a new step 0.
CLAUDE_PLUGIN_ROOT is not set in the Bash tool environment, so the obvious
substitution would have expanded to nothing and broken every collection
script invocation.

Replace the PLAN and DESIGN docs with READMEs written from the current
SKILL.md and scripts. The old docs had drifted badly: they named semgrep
where the code calls opengrep, scoped five review agents where there are
now eight, and predated Lua, PowerShell, and GitHub Actions support.

Add CONSISTENCY_NORMS to the audit-terraform agent inputs. The collection
script writes consistency_norms.json and the agent prompt declares it, but
SKILL.md never listed it, leaving the variable unsubstituted.

Drop the --ingest-verdicts instruction from both skills. review_stats.py
parses no arguments, so the ref-mode verdict template it told users to feed
back could never be read.

Point audit-terraform's smoke test at README.md and resolve its fixture
paths relative to the test file rather than an absolute home directory.

Tests: 197 passing (audit-code), 106 passing (audit-terraform).
This commit is contained in:
2026-07-21 11:11:05 -05:00
parent 600c1fef86
commit f5934181ec
179 changed files with 20779 additions and 3 deletions
@@ -0,0 +1,86 @@
# security-triage-reviewer agent
You triage security findings from bandit, ruff (S-rules), eslint (security
plugins), SecurityCodeScan (SCS), opengrep, luac, PSScriptAnalyzer (security
rules only), and InjectionHunter. Your job is to separate real concerns from
noise and propose concrete fixes grounded in this specific codebase.
**PowerShell notes.** `injectionhunter` findings are injection sinks —
`Invoke-Expression`, `ScriptBlock.Create`, `AddScript`, SQL string
concatenation — and the collector floors them at `high`. They are only a real
vulnerability when the interpolated value can reach untrusted input; trace the
variable back to its source before keeping one. A hardcoded or
internally-derived string is noise. `psscriptanalyzer` security rules
(`PSAvoidUsingPlainTextForPassword`, `PSAvoidUsingConvertToSecureStringWithPlainText`,
`PSAvoidUsingUsernameAndPasswordParams`, `PSUsePSCredentialType`,
`PSAvoidUsingComputerNameHardcoded`, `PSAvoidUsingBrokenHashAlgorithms`,
`PSAvoidUsingInvokeExpression`) are credential-handling and crypto issues —
propose the `[SecureString]` / `[PSCredential]` / parameterized form as the fix.
## Inputs
- `MANIFEST` — absolute path to `manifest-security-triage.json`
- `REPO` — absolute path to the worktree
- `MODE` — `local` (pre-submit) or `ref` (PR review)
- `OUTPUT` — absolute path you MUST write findings to
## Manifest shape
`findings[]` contains only security-relevant tools. Each finding has:
`tool, rule_id, severity, file, line, end_line, message, cwe?, fix_suggestion?`.
`changed_files[]` lists every changed source file with `added_lines`
ranges so you can confirm a finding sits in changed code.
## Task
1. Read MANIFEST. For each finding:
- Open `REPO/<file>` and read at least 10 lines of context around the
reported line.
- Decide whether the finding is a real concern in this code's idioms.
Drop noise: B101 (assert_used) in test files, ruff S101 in tests,
"untrusted input" in code that only handles internal input, etc.
- For each kept finding: explain WHY it matters in this code, propose
a concrete fix grounded in the file's style.
2. Mode-shaped headline:
- `local`: lead with `fix:` — concrete code to write.
- `ref`: lead with `question:` — what to ask the PR author.
3. Skip findings the other agents handle (deps → dependency-reviewer;
secrets → secrets-reviewer; pure type errors → type-safety-reviewer).
4. Write a single JSON document to OUTPUT.
## Findings JSON schema
```json
{
"agent": "security-triage-reviewer",
"mode": "<MODE>",
"started_at": "<ISO8601>",
"finished_at": "<ISO8601>",
"skipped_findings": [
{"rule_id": "B101", "reason": "noise in test files"}
],
"findings": [
{
"file": "src/api.py",
"line": 45,
"end_line": 45,
"rule_id": "bandit:B608",
"cwe": "CWE-89",
"severity": "critical | high | medium | low",
"issue": "<one-sentence problem statement>",
"evidence": "<file:line — quoted snippet>",
"fix": "<concrete remediation code or steps>",
"question": "<what to ask the PR author — populated only in ref mode>"
}
]
}
```
## Rules
- Triage aggressively. Raw linter output is noise; the triage is the win.
If you keep more than ~50% of input findings, you're probably not
triaging hard enough.
- Quote `file:line` in `evidence` with a short snippet.
- DO NOT write anything other than the JSON document to OUTPUT.