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:
@@ -0,0 +1,80 @@
|
||||
import json
|
||||
|
||||
from scripts.manifest import (
|
||||
Manifest, Finding, ChangedFile, LanguageBreakdown,
|
||||
PackageDiff, PackageEntry, PackageUpgrade, ToolStat,
|
||||
)
|
||||
|
||||
|
||||
def test_finding_to_dict_includes_all_fields():
|
||||
f = Finding(
|
||||
tool="bandit", rule_id="B608", severity="high",
|
||||
file="src/api.py", line=45, end_line=45,
|
||||
message="Possible SQL injection.",
|
||||
cwe="CWE-89", fix_suggestion=None,
|
||||
)
|
||||
d = f.to_dict()
|
||||
assert d["tool"] == "bandit"
|
||||
assert d["rule_id"] == "B608"
|
||||
assert d["cwe"] == "CWE-89"
|
||||
assert "fix_suggestion" in d
|
||||
|
||||
|
||||
def test_changed_file_serializes_ranges():
|
||||
cf = ChangedFile(
|
||||
path="src/api.py", language="python",
|
||||
added_lines=[(12, 14), (45, 45)],
|
||||
)
|
||||
d = cf.to_dict()
|
||||
assert d["language"] == "python"
|
||||
assert d["added_lines"] == [[12, 14], [45, 45]]
|
||||
|
||||
|
||||
def test_manifest_roundtrip():
|
||||
m = Manifest(
|
||||
mode="local", base_ref="origin/main", head_ref="HEAD",
|
||||
default_branch="main",
|
||||
language_breakdown=LanguageBreakdown(
|
||||
python=2, javascript=0, typescript=0, csharp=0,
|
||||
skipped_files=[],
|
||||
),
|
||||
changed_files=[],
|
||||
findings=[],
|
||||
package_diffs={
|
||||
"python": PackageDiff(),
|
||||
"javascript": PackageDiff(),
|
||||
"csharp": PackageDiff(),
|
||||
},
|
||||
tool_stats={},
|
||||
tools_unavailable=[],
|
||||
errors=[],
|
||||
)
|
||||
payload = json.loads(m.to_json())
|
||||
assert payload["mode"] == "local"
|
||||
assert payload["language_breakdown"]["python"] == 2
|
||||
assert payload["findings"] == []
|
||||
|
||||
|
||||
def test_package_diff_with_entries():
|
||||
pd = PackageDiff(
|
||||
added=[PackageEntry(name="pyyaml", version="6.0")],
|
||||
removed=[],
|
||||
upgraded=[PackageUpgrade(name="requests", from_version="2.28.0", to_version="2.31.0")],
|
||||
)
|
||||
d = pd.to_dict()
|
||||
assert d["added"][0]["name"] == "pyyaml"
|
||||
assert d["upgraded"][0]["from"] == "2.28.0"
|
||||
assert d["upgraded"][0]["to"] == "2.31.0"
|
||||
|
||||
|
||||
def test_tool_stat_records_ran_and_counts():
|
||||
ts = ToolStat(ran=True, pre_filter=47, post_filter=3)
|
||||
d = ts.to_dict()
|
||||
assert d == {"ran": True, "pre_filter": 47, "post_filter": 3}
|
||||
|
||||
|
||||
def test_tool_stat_records_skip_reason():
|
||||
ts = ToolStat(ran=False, reason="not on PATH")
|
||||
d = ts.to_dict()
|
||||
assert d["ran"] is False
|
||||
assert d["reason"] == "not on PATH"
|
||||
Reference in New Issue
Block a user