Skip to content

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

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

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

Conversation

@panish16

Copy link
Copy Markdown
Collaborator

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

Adds a pre-commit hook that runs gitleaks on staged changes, same setup as bcgov/entity#35072.

  • 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). Without this, pnpm v11 fails the root install with ERR_PNPM_IGNORED_BUILDS.

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 with default build-script approval:

  • root pnpm install exits 0, hook installed
  • fake GitHub token at root and in colin-api/ → blocked
  • clean change → commit fine

No CI/CD workflow installs at the repo root (all path-scoped to service folders), so no pipeline impact.

Part of the Git Hooks RFC rollout (bcgov/entity#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.
@sonarqubecloud

Copy link
Copy Markdown

@panish16
panish16 merged commit 7119832 into main Oct 2, 2026
7 checks passed
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