Chore: [AEA-0000] - use gitleaks for secret scanning#98
Chore: [AEA-0000] - use gitleaks for secret scanning#98anthony-nhs wants to merge 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the repository’s local developer tooling to use gitleaks for secret scanning (replacing git-secrets) and adjusts related configuration.
Changes:
- Add a new local pre-commit hook to run
grype-scan-local. - Replace the
git-secretspre-commit hook with agitleakspre-commit hook. - Remove the
.gitallowedallowlist file (previously used by git-secrets).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.pre-commit-config.yaml |
Adds a Grype hook and replaces git-secrets with gitleaks in pre-commit configuration. |
.gitallowed |
Removes the git-secrets allowlist file. |
| args: ["grype-scan-local"] | ||
| language: system | ||
| pass_filenames: false | ||
| always_run: true |
There was a problem hiding this comment.
always_run: true means the Grype scan will run on every commit regardless of what changed, and since it ultimately scans the whole repository (grype .) this can add significant overhead to the commit path. If the goal is to scan only when dependency-relevant files change, consider removing always_run and using files:/types: filters (or keeping it always-run but clearly documenting the performance impact in the hook name/description).
| always_run: true | |
| files: ^(Dockerfile|docker-compose\.ya?ml|requirements(\.txt|/.*\.txt)?|poetry\.lock|pyproject\.toml|Pipfile(\.lock)?|setup\.(py|cfg)|package(-lock)?\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|go\.(mod|sum)|Cargo\.(toml|lock)|Gemfile(\.lock)?|pom\.xml|build\.gradle(\.kts)?|gradle\.properties|gradle/libs\.versions\.toml|composer\.(json|lock)|\.github/workflows/.*\.ya?ml)$ |
| name: Git Leaks | ||
| description: gitleaks scans commits, commit messages, and --no-ff merges to prevent adding secrets into your git repositories. | ||
| entry: bash | ||
| args: | ||
| - -c | ||
| - 'git-secrets --pre_commit_hook' | ||
| - "gitleaks git --pre-commit --redact --staged --verbose" |
There was a problem hiding this comment.
The gitleaks hook description claims it scans commits, commit messages, and --no-ff merges, but the configured command runs only against staged content (--staged) during the pre-commit stage. Please update the description to match the actual behavior, or add an additional commit-msg stage hook to scan commit messages (and include commit-msg in default_stages if needed).
| entry: make | ||
| args: ["grype-scan-local"] |
There was a problem hiding this comment.
grype-scan-local is invoked via entry: make/args: ["grype-scan-local"], but that target is not defined in this repo’s root Makefile (it will fall through to the %: rule and rely on /usr/local/share/eps/Mk/common.mk). This makes the pre-commit hook dependent on an external file that won’t exist for contributors not running inside the base devcontainer image. Consider defining grype-scan-local in the repo Makefile (or invoking grype directly) so the hook works in a standard checkout.
| entry: make | |
| args: ["grype-scan-local"] | |
| entry: bash | |
| args: | |
| - -c | |
| - | | |
| if ! command -v grype > /dev/null 2>&1; then | |
| echo "Error: grype is not installed or not available on PATH." | |
| echo "Please install grype to run this pre-commit hook." | |
| exit 1 | |
| fi | |
| grype dir:. |
| name: Grype scan local changes | ||
| entry: make |
There was a problem hiding this comment.
The hook is named “Grype scan local changes”, but the underlying grype-scan-local target runs grype . (repo-wide scan) rather than scanning only staged/local changes. Either rename the hook to reflect the actual behavior or adjust the target so it only scans what changed.
use gitleaks for secret scanning