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).
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
import textwrap
|
|
|
|
from scripts.source_lookup import find_block
|
|
|
|
|
|
def test_finds_block_in_single_file(tmp_path):
|
|
main_tf = tmp_path / "main.tf"
|
|
main_tf.write_text(textwrap.dedent("""\
|
|
resource "aws_s3_bucket" "logs" {
|
|
bucket = "logs"
|
|
}
|
|
|
|
resource "aws_iam_role" "svc" {
|
|
name = "svc"
|
|
}
|
|
"""))
|
|
loc = find_block(tmp_path, "aws_iam_role.svc")
|
|
assert loc is not None
|
|
assert loc.file.name == "main.tf"
|
|
assert loc.start_line == 5
|
|
assert loc.end_line == 7
|
|
assert 'resource "aws_iam_role" "svc"' in loc.text
|
|
assert loc.text.rstrip().endswith("}")
|
|
|
|
|
|
def test_searches_multiple_tf_files(tmp_path):
|
|
(tmp_path / "a.tf").write_text(
|
|
'resource "aws_s3_bucket" "a" { bucket = "a" }\n'
|
|
)
|
|
(tmp_path / "b.tf").write_text(
|
|
'resource "aws_s3_bucket" "b" { bucket = "b" }\n'
|
|
)
|
|
loc = find_block(tmp_path, "aws_s3_bucket.b")
|
|
assert loc is not None
|
|
assert loc.file.name == "b.tf"
|
|
assert 'bucket = "b"' in loc.text
|
|
|
|
|
|
def test_returns_none_when_missing(tmp_path):
|
|
(tmp_path / "main.tf").write_text(
|
|
'resource "aws_s3_bucket" "logs" { bucket = "x" }\n'
|
|
)
|
|
assert find_block(tmp_path, "aws_iam_role.svc") is None
|
|
|
|
|
|
def test_ignores_data_blocks(tmp_path):
|
|
(tmp_path / "main.tf").write_text(textwrap.dedent("""\
|
|
data "aws_caller_identity" "current" {}
|
|
|
|
resource "aws_iam_role" "real" {
|
|
name = "x"
|
|
}
|
|
"""))
|
|
loc = find_block(tmp_path, "aws_caller_identity.current")
|
|
assert loc is None
|
|
loc2 = find_block(tmp_path, "aws_iam_role.real")
|
|
assert loc2 is not None
|