Skip to content

feat: add gitleaks secret scanning to pre-commit hooks - #122

Closed
panish16 wants to merge 1 commit into
bcgov:mainfrom
panish16:feat/gitleaks-secret-scan
Closed

panish16 wants to merge 1 commit into
bcgov:mainfrom
panish16:feat/gitleaks-secret-scan

Conversation

@panish16

Copy link
Copy Markdown

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

main already has lefthook (lint + typecheck) but no secret scanning. This adds it, matching the pattern now live on bcgov/bcregistry#281 and bcgov/ppr#2364: bare npx gitleaks-secret-scanner in the pre-commit config, no custom install script.

Also guards prepare with || exit 0. This repo has no CI/CD workflows right now, so it's not an active problem here, but it's the exact bug that broke bcregistry's CD after merging the same base lefthook setup without the guard (bcgov/bcregistry#281) - worth having from the start rather than rediscovering it later once this repo does get a pipeline.

Note (not fixed here, out of scope): pnpm install prints [WARN] The "pnpm" field in package.json is no longer read by pnpm ... "pnpm.onlyBuiltDependencies". That's pre-existing and unrelated to this change - lefthook still builds and installs fine despite the warning (verified with both a normal install and CI=true pnpm install --frozen-lockfile), so it's not currently breaking anything, but the config format itself is stale for whatever pnpm version is in use now.

Verified with a real git commit, not just a dry run: the hook installs, and committing a fake GitHub token is correctly caught and blocked (RuleID: github-pat) before the commit is created.

Did not touch feature-design-01 - it's 7 commits behind main and bundles an unrelated design/ Nuxt site, so it's not a clean base to build this on top of.

Adds the secret-scan command from the Git Hooks RFC (discussion bcgov#23) to
the lefthook config already on main (lint + typecheck only, no secret
scanning yet). Matches the pattern now live on bcgov/bcregistry and
bcgov/ppr: bare 'npx gitleaks-secret-scanner', no custom install script.

Also guards 'prepare' with '|| exit 0' so a missing git binary (e.g. a
git-less CD build image) can't fail the install - this bit bcregistry
after it merged the same lefthook setup without the guard:
bcgov/bcregistry#281
@thorwolpert

thorwolpert commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

This isn't needed as it will get covered with the 2 branches being merged to main.
I'd prefer to not replace/rebase for no reason.

@panish16

Copy link
Copy Markdown
Author

Ill close this one then

@panish16 panish16 closed this Sep 23, 2026
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.

2 participants