Skip to content

feat: add lefthook pre-commit hooks with gitleaks secret scanning - #2364

Open
panish16 wants to merge 2 commits into
bcgov:mainfrom
panish16:feat/git-hooks-gitleaks
Open

feat: add lefthook pre-commit hooks with gitleaks secret scanning#2364
panish16 wants to merge 2 commits into
bcgov:mainfrom
panish16:feat/git-hooks-gitleaks

Conversation

@panish16

Copy link
Copy Markdown
Contributor

Summary

Pilot rollout of the Git Hooks RFC (bcgov/entity#34619) to a polyrepo-style monorepo, following the reference implementation in bcgov/connect#38:

  • This repo has no root package.json today (ppr-ui, ppr-api, mhr-api each manage their own deps independently) - added a minimal, hooks-only root package.json so pnpm install at the repo root is the single setup step, without touching each service's own tooling.
  • Root lefthook.yml runs lint scoped per-service via root: (ppr-ui-lint, ppr-api-lint, mhr-api-lint), so a commit touching one service doesn't trigger checks for the others. secret-scan runs unscoped, across the whole staged changeset.
  • Lint commands mirror what each service's own CI already runs: eslint for ppr-ui, poetry run flake8 for ppr-api/mhr-api (per bcgov/bcregistry-sre's shared backend-ci.yaml).
  • gitleaks binary is downloaded from its official GitHub release and checksum-verified at install time, not an unofficial npm wrapper.
  • Added .gitleaks.toml (extends default ruleset, allowlists lockfiles including poetry.lock) and a short README dev-setup note.

Test plan

  • pnpm install at repo root installs the hook and downloads/checksum-verifies gitleaks v8.30.1
  • Real git commit: all three per-service lint commands correctly skip when no matching staged files exist, secret-scan runs and passes
  • Verified root: scoping actually routes correctly: staged a throwaway file under ppr-api/ and confirmed only ppr-api-lint triggered, while ppr-ui-lint/mhr-api-lint stayed skipped

Related: bcgov/entity#34619, template: bcgov/connect#38, single-app pilot: bcgov/bcregistry#278

Pilot rollout of the Git Hooks RFC (bcgov/entity#34619) to a
polyrepo-style monorepo, following the reference implementation in
bcgov/connect#38: a root-level lefthook.yml runs per-service lint
(scoped via `root:` to ppr-ui, ppr-api, mhr-api independently) and a
repo-wide gitleaks secret scan before each commit. Since this repo
has no root package.json today, added a minimal hooks-only one - the
services keep their own independent dependency management.
Without this, pnpm's CI mode (frozen-lockfile / CI=true) hard-fails
with ERR_PNPM_IGNORED_BUILDS instead of just warning, since lefthook
ships a postinstall script pnpm won't run without explicit approval.
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