Skip to content

chore(security): add gitleaks pre-commit + CI secret scan (LAC-2555) - #34

Open
lacymorrow wants to merge 2 commits into
mainfrom
lac-2555-secret-scanner
Open

chore(security): add gitleaks pre-commit + CI secret scan (LAC-2555)#34
lacymorrow wants to merge 2 commits into
mainfrom
lac-2555-secret-scanner

Conversation

@lacymorrow

Copy link
Copy Markdown
Contributor

Summary

Adds a two-layer secret scanner per LAC-2555 (Paperclip): CI-side gate + local pre-commit hook. Follows LAC-2548, where a plaintext OpenAI key made it into the repo.

  • CI gate: .github/workflows/gitleaks.yml runs gitleaks-action on every PR and every push to main. Fails the check if a plaintext credential appears in the diff.
  • Local hook: .githooks/pre-commit runs gitleaks protect --staged when the binary is installed. Graceful skip + warning if not — CI still catches it either way.
  • Auto-wiring: postinstall sets git config core.hooksPath .githooks so the hook activates on the next install without adding a new devDependency.
  • Config: .gitleaks.toml extends the default rule set and allowlists placeholder-credential files (.env.example*, docs/, LLM crawl fixtures) so we don't false-positive.

Scope kept tight per Rule 28 — no refactors, no other changes.

Test plan

  • CI job "gitleaks" appears on this PR and passes (nothing sensitive in the diff).
  • After merge, git config core.hooksPath reads .githooks after pnpm install / bun install.
  • Manual leak test: echo "AWS_SECRET_ACCESS_KEY=AKIA...redacted" > /tmp/leak.txt && git add /tmp/leak.txt && git commit -m test should fail locally (if gitleaks installed) or on CI.

Refs: LAC-2555, LAC-2548, LAC-2554 (credential rotation, tracked separately).

Defense-in-depth to prevent plaintext credentials from reaching the repo.

- `.github/workflows/gitleaks.yml` — Gitleaks Action on every PR/main push.
- `.gitleaks.toml` — extends default rules; allowlists example env files,
  docs, and generated LLM crawl fixtures.
- `.githooks/pre-commit` — local scan of staged changes when gitleaks is
  installed; graceful skip + warning otherwise (CI still runs).
- `package.json` postinstall wires `core.hooksPath` to `.githooks/` on
  every install so the hook auto-activates without a new devDependency.

If a real secret is caught: rotate first, then remove from the diff
(knowledge/agent-common.md → Secret handling).
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bones Ready Ready Preview Aug 25, 2026 6:20pm

Request Review

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Failed to generate code suggestions for PR

gitleaks-action@v2 requires a paid license on GitHub Organizations
(shipkit-io hit "missing gitleaks license" and failed every run).
Install the CLI directly and scan the PR/push diff — same coverage,
no license needed, matches the pattern merged in lacymorrow/shipkit#277.
@lacymorrow

Copy link
Copy Markdown
Contributor Author

Pushed 8c7a078 — replaced gitleaks/gitleaks-action@v2 with the raw gitleaks CLI (matches the pattern in the merged lacymorrow/shipkit#277).

Root cause of the 6-week check failure: gitleaks-action@v2 requires a paid GitHub Organization license. Every run since 2026-07-06 died with 🛑 missing gitleaks license before scanning a single line. Personal-repo forks (lash-www, shipkit-sink) never hit this because they're under a user account, which is why only bones was stuck.

Verified: new gitleaks run on this PR passes in 7s (https://github.com/shipkit-io/bones/actions/runs/32883093758).

Remaining non-blocking noise on this PR (unrelated to the secret-scanner add):

  • smoke-test fail from 2026-07-06 — Resource not accessible by integration (403) when the workflow tried to POST a commit status. Token-permission issue in the Deployment Check workflow, pre-dates this PR.
  • audit (Lighthouse loop) — Vercel preview URL churn, always flaky on stale PRs.

The PR content itself (gitleaks CI + config + hook + unrelated repo tidy) is unchanged from the 2026-07-06 commit; only the workflow install method changed. Ready for merge review — flagged on LAC-3287.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant