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,56 @@
|
||||
"""Schema and serialization for AWS controls cache files."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from dataclasses import dataclass, asdict
|
||||
from datetime import datetime
|
||||
from typing import Literal
|
||||
|
||||
|
||||
Severity = Literal["critical", "high", "medium", "low", "informational"]
|
||||
ControlSource = Literal["fsbp", "cis", "aws-bp"]
|
||||
|
||||
|
||||
@dataclass
|
||||
class Control:
|
||||
control_id: str
|
||||
title: str
|
||||
severity: Severity
|
||||
resource_types: list[str]
|
||||
requirement: str
|
||||
source_url: str
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return asdict(self)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ControlsFile:
|
||||
source: ControlSource
|
||||
fetched_at: datetime
|
||||
controls: list[Control]
|
||||
|
||||
def _by_resource_type(self) -> dict[str, list[str]]:
|
||||
"""Map terraform resource type -> list of control_ids.
|
||||
|
||||
Full control records live in `controls`. Looking up details by ID
|
||||
from `controls` keeps the index small.
|
||||
"""
|
||||
index: dict[str, list[str]] = {}
|
||||
for c in self.controls:
|
||||
for rt in c.resource_types:
|
||||
index.setdefault(rt, []).append(c.control_id)
|
||||
for rt in index:
|
||||
index[rt].sort()
|
||||
return dict(sorted(index.items()))
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
"source": self.source,
|
||||
"fetched_at": self.fetched_at.isoformat(),
|
||||
"controls": [c.to_dict() for c in self.controls],
|
||||
"by_resource_type": self._by_resource_type(),
|
||||
}
|
||||
|
||||
def to_json(self, indent: int = 2) -> str:
|
||||
return json.dumps(self.to_dict(), indent=indent, sort_keys=False)
|
||||
Reference in New Issue
Block a user