From cb2d28507e885a3b1fa5eb1692531cc965722e2e Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 5 Apr 2026 15:43:34 -0400 Subject: [PATCH 01/10] chore: add security scanning and enforce no-npx rule - Add ecc-agentshield as pinned devDep for Claude Code config scanning - Add `pnpm run security` script (agentshield + zizmor) - Add /security-scan command for Claude - Add npx/dlx/yarn-dlx check to pre-commit hook - Add NEVER npx/dlx rule to CLAUDE.md ABSOLUTE RULES - Remove dead .husky/security-checks.sh (duplicate of .git-hooks/pre-commit) --- .claude/commands/security-scan.md | 22 +++ .git-hooks/pre-commit | 18 ++ .husky/security-checks.sh | 125 -------------- CLAUDE.md | 1 + external-tools.json | 31 ++++ package.json | 3 + pnpm-lock.yaml | 208 +++++++++++++++++++++++ pnpm-workspace.yaml | 1 + scripts/setup.mjs | 271 ++++++++++++++++++++++++++++++ 9 files changed, 555 insertions(+), 125 deletions(-) create mode 100644 .claude/commands/security-scan.md delete mode 100755 .husky/security-checks.sh create mode 100644 external-tools.json create mode 100644 scripts/setup.mjs diff --git a/.claude/commands/security-scan.md b/.claude/commands/security-scan.md new file mode 100644 index 00000000..42e36005 --- /dev/null +++ b/.claude/commands/security-scan.md @@ -0,0 +1,22 @@ +Run a security scan of the project via `pnpm run security`, or manually: + +## 1. Claude Code configuration security + +Run `pnpm exec agentshield scan` to check `.claude/` for: +- Hardcoded secrets in CLAUDE.md and settings +- Overly permissive tool allow lists (e.g. `Bash(*)`) +- Prompt injection patterns in agent definitions +- Command injection risks in hooks +- Risky MCP server configurations + +## 2. GitHub Actions workflow security + +Run `zizmor .github/` to scan all workflows for: +- Unpinned actions (should use full SHA, not tags) +- Secrets used outside `env:` blocks +- Injection risks from untrusted inputs +- Overly permissive permissions + +If zizmor is not installed, skip with a message. Install via `brew install zizmor` or see https://docs.zizmor.sh/installation/. + +Report all findings with severity levels. Fix CRITICAL and HIGH findings immediately. diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 28c0da69..7ae6f541 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -112,6 +112,24 @@ for file in $STAGED_FILES; do fi done +# Check for npx/dlx usage (use pnpm exec or pnpm run instead). +printf "Checking for npx/dlx usage...\n" +for file in $STAGED_FILES; do + if [ -f "$file" ]; then + # Skip node_modules, lockfiles, and this hook itself. + if echo "$file" | grep -qE 'node_modules/|pnpm-lock\.yaml|\.git-hooks/'; then + continue + fi + + if grep -nE '\bnpx\b|\bpnpm dlx\b|\byarn dlx\b' "$file" 2>/dev/null | grep -v '# zizmor:' | grep -q .; then + printf "${RED}✗ ERROR: npx/dlx usage found in: $file${NC}\n" + grep -nE '\bnpx\b|\bpnpm dlx\b|\byarn dlx\b' "$file" | grep -v '# zizmor:' | head -3 + printf "Use 'pnpm exec ' or 'pnpm run