Skip to content

Chore: [AEA-0000] - use gitleaks for secret scanning#532

Open
anthony-nhs wants to merge 1 commit intomainfrom
gitleaks
Open

Chore: [AEA-0000] - use gitleaks for secret scanning#532
anthony-nhs wants to merge 1 commit intomainfrom
gitleaks

Conversation

@anthony-nhs
Copy link
Copy Markdown
Contributor

use gitleaks for secret scanning

Copilot AI review requested due to automatic review settings April 17, 2026 10:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR switches the repository’s pre-commit secret scanning from git-secrets to gitleaks.

Changes:

  • Replaces the existing git-secrets pre-commit hook with a gitleaks hook.
  • Adds a .gitleaksignore file to suppress current findings in test fixtures and sample documentation.
  • Removes the legacy .gitallowed allowlist file used by git-secrets.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
.pre-commit-config.yaml Swaps the secret scanning hook from git-secrets to gitleaks (currently via a system-installed binary).
.gitleaksignore Adds commit-specific ignore entries for existing token-like strings in fixtures/docs.
.gitallowed Deletes the git-secrets allowlist file no longer needed after the tool switch.

Comment thread .pre-commit-config.yaml
- -c
- 'git-secrets --pre_commit_hook'
- "gitleaks git --pre-commit --redact --staged --verbose"
language: system
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gitleaks hook is currently configured without pass_filenames: false / always_run: true. With entry: bash -c ..., pre-commit will still append the staged filenames as extra bash parameters, and the hook can be skipped when no filenames are passed. Consider setting pass_filenames: false (and always_run: true if you want it to run on every commit) so the hook behavior is deterministic and not dependent on filename passing.

Suggested change
language: system
language: system
pass_filenames: false
always_run: true

Copilot uses AI. Check for mistakes.
Comment thread .pre-commit-config.yaml
Comment on lines +90 to 98
- id: gitleaks
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"
language: system

Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook relies on a system-installed gitleaks binary (language: system) but the config doesn’t pin a version like the other tool hooks (black/flake8). That can lead to different results (or failures) across developer machines/CI depending on the installed gitleaks version and CLI compatibility. Prefer using the official gitleaks pre-commit repo hook (pinned rev) or otherwise managing the gitleaks version in-repo (e.g., via a Make target/script that installs a specific version).

Copilot uses AI. Check for mistakes.
Comment thread .gitleaksignore
Comment on lines +1 to +14
37bc8f37e5f717b2aac63783e8c6760d8e4babb5:packages/slackBotFunction/tests/example_command.json:generic-api-key:3
37bc8f37e5f717b2aac63783e8c6760d8e4babb5:packages/slackBotFunction/tests/example_command.json:generic-api-key:20
2979738bdff20c9d70de06d682f0e8e8932fd5e3:packages/slackBotFunction/tests/example_command.json:generic-api-key:3
2979738bdff20c9d70de06d682f0e8e8932fd5e3:packages/slackBotFunction/tests/example_command.json:generic-api-key:20
5627ebe762dc71b49801dc89da4c20e0cd339ece:packages/slackBotFunction/tests/example_event.json:generic-api-key:2
5627ebe762dc71b49801dc89da4c20e0cd339ece:packages/slackBotFunction/tests/example_action.json:generic-api-key:10
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:284
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:3040
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:5908
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:9290
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:14391
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:15297
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:19205
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:20174
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new .gitleaksignore entries are commit-SHA-specific for fixtures/docs that contain token-like strings (e.g., Slack token/response_url values and Authorization: Bearer ... examples). This is brittle: any edit to those files will usually generate a new finding fingerprint and the ignore will stop working, creating recurring noise. Prefer sanitising those fixtures/docs to use obvious placeholders (so they don’t match secret patterns) and/or adding a path-/regex-based allowlist in a gitleaks config, reserving .gitleaksignore for one-off historical findings.

Suggested change
37bc8f37e5f717b2aac63783e8c6760d8e4babb5:packages/slackBotFunction/tests/example_command.json:generic-api-key:3
37bc8f37e5f717b2aac63783e8c6760d8e4babb5:packages/slackBotFunction/tests/example_command.json:generic-api-key:20
2979738bdff20c9d70de06d682f0e8e8932fd5e3:packages/slackBotFunction/tests/example_command.json:generic-api-key:3
2979738bdff20c9d70de06d682f0e8e8932fd5e3:packages/slackBotFunction/tests/example_command.json:generic-api-key:20
5627ebe762dc71b49801dc89da4c20e0cd339ece:packages/slackBotFunction/tests/example_event.json:generic-api-key:2
5627ebe762dc71b49801dc89da4c20e0cd339ece:packages/slackBotFunction/tests/example_action.json:generic-api-key:10
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:284
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:3040
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:5908
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:9290
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:14391
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:15297
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:19205
70f4f55f8a060fe2747bc3e4e61937d72c0fb0a9:sample_docs/eps_output.md:curl-auth-header:20174

Copilot uses AI. Check for mistakes.
Comment thread .pre-commit-config.yaml
Comment on lines +91 to +96
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"
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hook description looks copied from git-secrets and may not reflect what this configuration actually does (it runs gitleaks ... --staged during pre-commit rather than scanning commit messages/merge commits). Updating the description to match the actual behavior will help contributors understand what is being scanned.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

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