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:
+160
@@ -0,0 +1,160 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$SKILL_DIR"
|
||||
|
||||
say() { printf '\n\033[1m▶ %s\033[0m\n' "$*"; }
|
||||
warn() { printf '\033[33m! %s\033[0m\n' "$*"; }
|
||||
|
||||
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
warn "uv not installed. Install: https://docs.astral.sh/uv/getting-started/installation/"
|
||||
warn "Falling back to plain pip — tools will install into the active environment."
|
||||
if ! command -v pip >/dev/null 2>&1; then
|
||||
echo "Neither uv nor pip available. Aborting Python-tools install."
|
||||
exit 1
|
||||
fi
|
||||
pip install bandit ruff mypy pip-audit
|
||||
else
|
||||
say "Installing Python tools into $SKILL_DIR/.venv/ via uv"
|
||||
uv sync --group tools
|
||||
fi
|
||||
|
||||
|
||||
install_opengrep() {
|
||||
if [[ -x "$SKILL_DIR/.venv/bin/opengrep" ]]; then
|
||||
echo " opengrep: already installed (.venv/bin)"
|
||||
return
|
||||
fi
|
||||
say "Installing opengrep into $SKILL_DIR/.venv/bin/"
|
||||
local os arch asset
|
||||
os="$(uname -s)"
|
||||
arch="$(uname -m)"
|
||||
case "$os-$arch" in
|
||||
Linux-x86_64) asset="opengrep_manylinux_x86" ;;
|
||||
Linux-aarch64) asset="opengrep_manylinux_aarch64" ;;
|
||||
Darwin-x86_64) asset="opengrep_osx_x86" ;;
|
||||
Darwin-arm64) asset="opengrep_osx_arm64" ;;
|
||||
*)
|
||||
warn "opengrep: unsupported platform $os-$arch, install manually from https://github.com/opengrep/opengrep/releases"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
local tag url
|
||||
tag="$(curl -fsSL https://api.github.com/repos/opengrep/opengrep/releases/latest | grep -m1 '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')"
|
||||
if [[ -z "$tag" ]]; then
|
||||
warn "opengrep: could not resolve latest release tag, install manually"
|
||||
return
|
||||
fi
|
||||
url="https://github.com/opengrep/opengrep/releases/download/$tag/$asset"
|
||||
mkdir -p "$SKILL_DIR/.venv/bin"
|
||||
curl -fsSL "$url" -o "$SKILL_DIR/.venv/bin/opengrep"
|
||||
chmod +x "$SKILL_DIR/.venv/bin/opengrep"
|
||||
}
|
||||
|
||||
install_opengrep
|
||||
|
||||
|
||||
install_powershell_modules() {
|
||||
if ! command -v pwsh >/dev/null 2>&1; then
|
||||
warn "pwsh not found — PowerShell review (PSScriptAnalyzer, InjectionHunter) will be skipped."
|
||||
warn " Install: https://learn.microsoft.com/powershell/scripting/install/installing-powershell"
|
||||
return
|
||||
fi
|
||||
say "Installing PowerShell modules for the current user"
|
||||
pwsh -NoProfile -NonInteractive -Command '
|
||||
foreach ($m in "PSScriptAnalyzer", "InjectionHunter") {
|
||||
if (Get-Module -ListAvailable -Name $m) {
|
||||
Write-Host " $m: already installed"
|
||||
} else {
|
||||
Install-Module -Name $m -Scope CurrentUser -Force -AcceptLicense -Repository PSGallery
|
||||
Write-Host " $m: installed"
|
||||
}
|
||||
}'
|
||||
}
|
||||
|
||||
install_powershell_modules
|
||||
|
||||
|
||||
install_native_brew() {
|
||||
say "Installing native tools via Homebrew"
|
||||
for pkg in gitleaks osv-scanner gh; do
|
||||
if brew list --formula | grep -qx "$pkg"; then
|
||||
echo " $pkg: already installed"
|
||||
else
|
||||
brew install "$pkg"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
install_native_apt() {
|
||||
say "Installing native tools via apt-get"
|
||||
if ! command -v gh >/dev/null 2>&1; then
|
||||
warn "gh: follow https://github.com/cli/cli/blob/trunk/docs/install_linux.md"
|
||||
fi
|
||||
if ! command -v gitleaks >/dev/null 2>&1; then
|
||||
warn "gitleaks: download from https://github.com/gitleaks/gitleaks/releases"
|
||||
fi
|
||||
if ! command -v osv-scanner >/dev/null 2>&1; then
|
||||
warn "osv-scanner: install via 'go install github.com/google/osv-scanner/cmd/osv-scanner@latest' or download from https://github.com/google/osv-scanner/releases"
|
||||
fi
|
||||
}
|
||||
|
||||
install_native_arch() {
|
||||
local helper
|
||||
if command -v paru >/dev/null 2>&1; then
|
||||
helper="paru"
|
||||
elif command -v yay >/dev/null 2>&1; then
|
||||
helper="yay"
|
||||
else
|
||||
helper="pacman"
|
||||
fi
|
||||
say "Installing native tools via $helper"
|
||||
|
||||
local pkgs=(gitleaks github-cli osv-scanner)
|
||||
if [[ "$helper" == "pacman" ]]; then
|
||||
sudo pacman -S --needed --noconfirm gitleaks github-cli || true
|
||||
if ! command -v osv-scanner >/dev/null 2>&1; then
|
||||
warn "osv-scanner is AUR-only; pacman can't install it. Use paru/yay or install manually:"
|
||||
warn " go install github.com/google/osv-scanner/cmd/osv-scanner@latest"
|
||||
fi
|
||||
else
|
||||
"$helper" -S --needed --noconfirm "${pkgs[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
if command -v brew >/dev/null 2>&1; then
|
||||
install_native_brew
|
||||
elif command -v pacman >/dev/null 2>&1; then
|
||||
install_native_arch
|
||||
elif command -v apt-get >/dev/null 2>&1; then
|
||||
install_native_apt
|
||||
else
|
||||
warn "No supported native package manager found (brew/pacman/apt). Install gitleaks, osv-scanner, gh manually."
|
||||
fi
|
||||
|
||||
|
||||
say "Verifying tool availability"
|
||||
for tool in bandit ruff mypy pip-audit opengrep vulture radon interrogate lizard gitleaks osv-scanner gh pwsh; do
|
||||
if [[ -x "$SKILL_DIR/.venv/bin/$tool" ]]; then
|
||||
printf ' %-15s %s\n' "$tool" "(.venv/bin)"
|
||||
elif command -v "$tool" >/dev/null 2>&1; then
|
||||
printf ' %-15s %s\n' "$tool" "$(command -v "$tool")"
|
||||
else
|
||||
printf ' %-15s \033[31mmissing\033[0m\n' "$tool"
|
||||
fi
|
||||
done
|
||||
|
||||
cat <<EOF
|
||||
|
||||
Per-project tools (not installed here — must live in the target repo):
|
||||
- eslint + eslint-plugin-security (npm i -D)
|
||||
- typescript (tsc) (npm i -D)
|
||||
- SecurityCodeScan + dotnet (dotnet add package SecurityCodeScan.VS2019)
|
||||
- knip (npm i -D)
|
||||
- jscpd (npm i -D)
|
||||
|
||||
Run /audit-code to use the skill.
|
||||
EOF
|
||||
Reference in New Issue
Block a user