Skip to content

feat: add lefthook pre-commit hook with gitleaks secret scanning - #35072

Merged
thorwolpert merged 1 commit into
mainfrom
feat/git-hooks-gitleaks
Oct 1, 2026
Merged

thorwolpert merged 1 commit into
mainfrom
feat/git-hooks-gitleaks

Conversation

@panish16

Copy link
Copy Markdown
Collaborator

Part of the Git Hooks RFC rollout (#34619).

Adds a pre-commit hook that runs gitleaks on staged changes, same setup as bcgov/ppr and bcgov/namex#2019 (repos with no root package.json).

  • package.json - hooks-only, just installs lefthook. Subfolders keep managing their own deps.
  • lefthook.yml - secret scan only via npx gitleaks-secret-scanner
  • .gitleaks.toml - gitleaks default rules, lockfiles + this config allowlisted
  • pnpm-workspace.yaml - allowBuilds: lefthook: false, so lefthook's own postinstall doesn't run (prepare handles the install)

prepare is git --version && lefthook install || exit 0, so it skips when there's no git (build images) and works on Windows too.

To get the hook: run pnpm install at the repo root once.

Tested

Real git commit on Windows, pnpm 11.9.0:

  • fake GitHub token at root, in vue-project-stub/, in api-e2e/ → all blocked
  • clean change, YOUR_API_KEY placeholder → commit fine

No CI/CD workflows in this repo, so nothing else to check.

Part of the Git Hooks RFC rollout (#34619). Adds a
hooks-only root package.json (no app code at root) that installs
lefthook, which runs gitleaks against staged changes on commit.

prepare skips lefthook when git is absent and works under both cmd.exe
and POSIX sh. lefthook's own postinstall is disabled via allowBuilds in
pnpm-workspace.yaml since prepare handles installation.
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.

3 participants