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,58 @@
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from scripts.controls_schema import Control, ControlsFile
|
||||
|
||||
|
||||
def test_controls_file_serializes_with_resource_type_index():
|
||||
a = Control(
|
||||
control_id="FSBP S3.5",
|
||||
title="S3 buckets should require requests to use SSL",
|
||||
severity="medium",
|
||||
resource_types=["aws_s3_bucket"],
|
||||
requirement="The bucket policy must include a deny statement for "
|
||||
"non-TLS access (aws:SecureTransport = false).",
|
||||
source_url="https://docs.aws.amazon.com/securityhub/.../S3.5",
|
||||
)
|
||||
b = Control(
|
||||
control_id="FSBP IAM.5",
|
||||
title="MFA should be enabled for IAM users",
|
||||
severity="medium",
|
||||
resource_types=["aws_iam_user"],
|
||||
requirement="IAM users with console access must have MFA.",
|
||||
source_url="https://docs.aws.amazon.com/securityhub/.../IAM.5",
|
||||
)
|
||||
cf = ControlsFile(
|
||||
source="fsbp",
|
||||
fetched_at=datetime(2026, 5, 12, 9, 0, 0, tzinfo=timezone.utc),
|
||||
controls=[a, b],
|
||||
)
|
||||
payload = json.loads(cf.to_json())
|
||||
assert payload["source"] == "fsbp"
|
||||
assert payload["fetched_at"].endswith("+00:00") or payload["fetched_at"].endswith("Z")
|
||||
|
||||
by_rtype = payload["by_resource_type"]
|
||||
assert "aws_s3_bucket" in by_rtype
|
||||
assert by_rtype["aws_s3_bucket"] == ["FSBP S3.5"]
|
||||
assert "aws_iam_user" in by_rtype
|
||||
assert by_rtype["aws_iam_user"] == ["FSBP IAM.5"]
|
||||
|
||||
ids = {c["control_id"] for c in payload["controls"]}
|
||||
assert ids == {"FSBP S3.5", "FSBP IAM.5"}
|
||||
|
||||
|
||||
def test_control_appears_under_every_resource_type():
|
||||
c = Control(
|
||||
control_id="FSBP X.1",
|
||||
title="t", severity="low",
|
||||
resource_types=["aws_s3_bucket", "aws_s3_bucket_policy"],
|
||||
requirement="r", source_url="u",
|
||||
)
|
||||
cf = ControlsFile(
|
||||
source="fsbp",
|
||||
fetched_at=datetime(2026, 5, 12, tzinfo=timezone.utc),
|
||||
controls=[c],
|
||||
)
|
||||
payload = json.loads(cf.to_json())
|
||||
assert payload["by_resource_type"]["aws_s3_bucket"] == ["FSBP X.1"]
|
||||
assert payload["by_resource_type"]["aws_s3_bucket_policy"] == ["FSBP X.1"]
|
||||
Reference in New Issue
Block a user