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).
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
"""Adapter: zizmor --format sarif normalized to Finding[]."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import re
|
|
|
|
from scripts.manifest import Finding
|
|
|
|
|
|
_LEVEL = {"error": "high", "warning": "medium", "note": "low"}
|
|
_CWE_RE = re.compile(r"(CWE-\d+)")
|
|
|
|
|
|
def parse_zizmor_output(stdout: str) -> list[Finding]:
|
|
try:
|
|
payload = json.loads(stdout)
|
|
except json.JSONDecodeError:
|
|
return []
|
|
out: list[Finding] = []
|
|
for run in payload.get("runs", []):
|
|
cwe_by_rule: dict[str, str] = {}
|
|
for rule in run.get("tool", {}).get("driver", {}).get("rules", []):
|
|
for tag in rule.get("properties", {}).get("tags", []):
|
|
m = _CWE_RE.match(tag)
|
|
if m:
|
|
cwe_by_rule[rule["id"]] = m.group(1)
|
|
break
|
|
for result in run.get("results", []):
|
|
rule_id = result.get("ruleId", "unknown")
|
|
locations = result.get("locations", [])
|
|
if not locations:
|
|
continue
|
|
phys = locations[0].get("physicalLocation", {})
|
|
uri = phys.get("artifactLocation", {}).get("uri", "")
|
|
region = phys.get("region", {})
|
|
start_line = region.get("startLine", 0)
|
|
end_line = region.get("endLine", start_line)
|
|
out.append(Finding(
|
|
tool="zizmor",
|
|
rule_id=rule_id,
|
|
severity=_LEVEL.get(result.get("level", "warning"), "medium"),
|
|
file=uri,
|
|
line=start_line,
|
|
end_line=end_line,
|
|
message=result.get("message", {}).get("text", ""),
|
|
cwe=cwe_by_rule.get(rule_id),
|
|
))
|
|
return out
|