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,61 @@
|
||||
"""Scrape AWS Security Hub FSBP controls index page into structured rows.
|
||||
|
||||
The index page (https://docs.aws.amazon.com/securityhub/latest/userguide/fsbp-standard.html)
|
||||
lists controls as <p><a href="./<svc>-controls.html#<id>">[<Service>.<Number>] <Title></a></p>.
|
||||
This module only parses the index — severity defaults to "medium" because the
|
||||
index doesn't surface severity. Detail-page enrichment is a future task.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from scripts.control_resource_map import control_id_to_types
|
||||
|
||||
|
||||
FSBP_INDEX_URL = (
|
||||
"https://docs.aws.amazon.com/securityhub/latest/userguide/"
|
||||
"fsbp-standard.html"
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class FSBPRow:
|
||||
control_id: str
|
||||
title: str
|
||||
severity: str
|
||||
detail_url: str
|
||||
resource_types: list[str] = field(default_factory=list)
|
||||
requirement: str = ""
|
||||
|
||||
|
||||
_ANCHOR_RE = re.compile(r"^\s*\[(?P<id>[A-Za-z][A-Za-z0-9]*\.\d+)\]\s*(?P<title>.+)$")
|
||||
|
||||
|
||||
def parse_fsbp_index(html: str, base_url: str) -> list[FSBPRow]:
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
rows: list[FSBPRow] = []
|
||||
seen: set[str] = set()
|
||||
for a in soup.find_all("a"):
|
||||
text = a.get_text(strip=True)
|
||||
m = _ANCHOR_RE.match(text)
|
||||
if not m:
|
||||
continue
|
||||
control_id = m.group("id")
|
||||
if control_id in seen:
|
||||
continue
|
||||
seen.add(control_id)
|
||||
title = m.group("title").strip()
|
||||
href = a.get("href", "")
|
||||
detail_url = urljoin(base_url, href) if href else ""
|
||||
rows.append(FSBPRow(
|
||||
control_id=control_id,
|
||||
title=title,
|
||||
severity="medium",
|
||||
detail_url=detail_url,
|
||||
resource_types=control_id_to_types(control_id),
|
||||
))
|
||||
return rows
|
||||
Reference in New Issue
Block a user