Skip to content

fix(standards): rename GITLEAKS_SHA256→GITLEAKS_CHECKSUM, add .gitleaks.toml template#167

Open
don-petry wants to merge 71 commits into
mainfrom
fix/gitleaks-standard-checksum-and-toml
Open

fix(standards): rename GITLEAKS_SHA256→GITLEAKS_CHECKSUM, add .gitleaks.toml template#167
don-petry wants to merge 71 commits into
mainfrom
fix/gitleaks-standard-checksum-and-toml

Conversation

@don-petry
Copy link
Copy Markdown
Contributor

@don-petry don-petry commented Apr 28, 2026

Summary

  • standards/push-protection.md — Replaces the gitleaks/gitleaks-action based canonical job (Layer 3) with the manual-install pattern using GITLEAKS_CHECKSUM (not GITLEAKS_SHA256). Adds a new ### .gitleaks.toml template subsection explaining why the config file is required and what to put in it. Drops the now-unused security-events: write permission from the job.
  • standards/gitleaks.toml — New canonical template. Copy to repo root; extend allowlist.paths for repo-specific false positives. Ships with '''_bmad/''' pre-populated.
  • standards/ci-standards.md — Adds a "Required repo artifact" callout under §4 Secret Scanning explaining the .gitleaks.toml requirement and the GITLEAKS_CHECKSUM naming rule. Updates the CI failure table (adds config file not found row, fixes the .gitleaksignore.gitleaks.toml reference). Adds step 3 to the "Applying CI to a New Repository" checklist.

Why these changes

GITLEAKS_CHECKSUM not GITLEAKS_SHA256: SonarCloud's security gate flags env var names matching *SHA256* that contain hex strings as Security Hotspots (hardcoded credential false positive). Renaming to GITLEAKS_CHECKSUM suppresses the false positive without any functional change — sha256sum -c reads the value regardless of the variable name.

Required .gitleaks.toml: The generic-api-key rule in gitleaks fires on BMAD knowledge file paths (e.g. api-request.md, auth-session.md in _bmad/ directories) because their names contain substrings gitleaks treats as API-key indicators. Every adopting repo needs a config file that allowlists these paths; --config .gitleaks.toml is now part of the canonical Run step so omitting the file is a hard failure rather than a silent miss.

Test plan

  • Verify push-protection.md Layer 3 canonical job YAML is well-formed (correct step indentation, no stray nesting)
  • Verify standards/gitleaks.toml is valid TOML (tomlq . standards/gitleaks.toml or equivalent)
  • Adopt in a BMAD repo: copy standards/gitleaks.toml.gitleaks.toml, add the secret-scan job with GITLEAKS_CHECKSUM, confirm SonarCloud reports no Security Hotspot for the env var
  • Confirm gitleaks detect --config .gitleaks.toml does not fire on _bmad/ path fixtures

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Require a root-level secret-scan config in every repository; add explicit onboarding step to add and configure it; update troubleshooting to reference config-based allowlists and fixture guidance
  • CI / Security
    • CI installs a pinned secret-scanner binary and verifies it via checksum; CI fails fast if repo config is missing; add an organization-level license secret and an audit check that the secret-scan job is present
  • Push Protection
    • Updated incident guidance to prefer adding allowlist paths for CI false positives and to recognize both legacy and binary-based scanner setups

Copilot AI review requested due to automatic review settings April 28, 2026 18:04
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Warning

Rate limit exceeded

@don-petry has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minute and 19 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 37e53173-5509-4778-b2c4-69f4bfac11a6

📥 Commits

Reviewing files that changed from the base of the PR and between 48fc9d8 and fc6bc47.

📒 Files selected for processing (2)
  • scripts/lib/push-protection.sh
  • standards/ci-standards.md
📝 Walkthrough

Walkthrough

Adds a standardized gitleaks secret-scan: requires a repository-root .gitleaks.toml, pins and verifies a gitleaks binary via GITLEAKS_CHECKSUM, switches the CI job to run gitleaks detect --config .gitleaks.toml, updates onboarding and documentation, and extends push-protection detection to accept both action and binary-install patterns.

Changes

Gitleaks Secret-Scan Standardization

Layer / File(s) Summary
Configuration Template
standards/gitleaks.toml
Adds repository-level gitleaks config with title and an [allowlist] that includes _bmad/.
Data / Policy
standards/ci-standards.md
Adds Secret Scanning section requiring a root .gitleaks.toml, introduces GITLEAKS_LICENSE org secret entry, mandates GITLEAKS_CHECKSUM usage, updates onboarding to copy standards/gitleaks.toml, and revises CI failure remediation to cover missing config and allowlist usage.
Core CI Job Implementation
standards/push-protection.md
Replaces gitleaks/gitleaks-action with pinned binary-install steps using GITLEAKS_VERSION + GITLEAKS_CHECKSUM, verifies tarball, installs binary, updates PATH, runs gitleaks detect --source . --config .gitleaks.toml --redact --verbose --exit-code 1, and changes job permission from security-events: write to contents: read. Includes .gitleaks.toml template guidance and fixture-handling notes.
Audit / Enforcement Logic
scripts/lib/push-protection.sh
Extends CI-job detection to recognize either legacy gitleaks-action usage or the canonical binary-install pattern; raises a finding only if neither pattern is present.
Documentation / Troubleshooting
standards/push-protection.md, standards/ci-standards.md
Adds allowlist template and guidance for BMAD repos, updates remediation steps to prefer .gitleaks.toml allowlists over .gitleaksignore, and documents handling of realistic test fixtures and incident response for false positives.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer (repo)
  participant CI as GitHub Actions Runner
  participant GL as Gitleaks Binary
  participant Script as push-protection.sh
  participant Org as Org Secrets Store

  Dev->>CI: Push/PR triggers workflow (.github/workflows/ci.yml)
  CI->>Org: read GITLEAKS_CHECKSUM & GITLEAKS_LICENSE
  CI->>GL: download gitleaks@GITLEAKS_VERSION
  CI->>GL: verify tarball using GITLEAKS_CHECKSUM
  CI->>GL: install and add to PATH
  CI->>GL: run gitleaks detect --config .gitleaks.toml --redact --exit-code 1
  GL-->>CI: report findings / exit code
  CI->>Script: run audit check secret_scan_ci_job_present (pattern match)
  Script-->>CI: pass/fail enforcement result
  CI-->>Dev: report status with remediation guidance
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main changes: renaming GITLEAKS_SHA256 to GITLEAKS_CHECKSUM and adding a .gitleaks.toml template, which align with the primary modifications across the PR files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gitleaks-standard-checksum-and-toml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

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

Updates the security standards around gitleaks-based secret scanning by switching the canonical CI job from the gitleaks/gitleaks-action to a manual binary install pattern, standardizing the checksum env var name, and introducing a required .gitleaks.toml template to suppress known false positives (notably BMAD paths).

Changes:

  • Replace the Layer 3 canonical secret-scan job to download/verify/install the gitleaks binary and run gitleaks detect --config .gitleaks.toml.
  • Add a canonical standards/gitleaks.toml template and document the repo-root .gitleaks.toml requirement.
  • Update CI standards docs to reflect .gitleaks.toml requirements, failure modes, and onboarding checklist updates.

Reviewed changes

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

File Description
standards/push-protection.md Updates the canonical secret-scan job and adds a .gitleaks.toml template section.
standards/gitleaks.toml Adds a new template config intended to be copied to repo root as .gitleaks.toml.
standards/ci-standards.md Documents the required .gitleaks.toml artifact, checksum env var naming, updates failure table, and onboarding checklist.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread standards/push-protection.md Outdated
Comment on lines +236 to +238
wget -q "${url}" -O /tmp/gitleaks.tar.gz
echo "${GITLEAKS_CHECKSUM} /tmp/gitleaks.tar.gz" | sha256sum -c
tar -xzf /tmp/gitleaks.tar.gz -C /usr/local/bin gitleaks
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

The install step extracts gitleaks into /usr/local/bin without elevated permissions. On GitHub-hosted ubuntu-latest runners, /usr/local/bin is root-owned, so this will typically fail with permission denied and the job won’t reach the scan step. Install into a writable location (e.g., $RUNNER_TEMP/$HOME/.local/bin and add it to $GITHUB_PATH) or use sudo for the extract/install step.

Suggested change
wget -q "${url}" -O /tmp/gitleaks.tar.gz
echo "${GITLEAKS_CHECKSUM} /tmp/gitleaks.tar.gz" | sha256sum -c
tar -xzf /tmp/gitleaks.tar.gz -C /usr/local/bin gitleaks
install_dir="${RUNNER_TEMP}/gitleaks-bin"
mkdir -p "${install_dir}"
wget -q "${url}" -O /tmp/gitleaks.tar.gz
echo "${GITLEAKS_CHECKSUM} /tmp/gitleaks.tar.gz" | sha256sum -c
tar -xzf /tmp/gitleaks.tar.gz -C "${install_dir}" gitleaks
chmod +x "${install_dir}/gitleaks"
echo "${install_dir}" >> "${GITHUB_PATH}"

Copilot uses AI. Check for mistakes.
Comment thread standards/ci-standards.md
Comment on lines +278 to +289
**Required repo artifact — `.gitleaks.toml`:**

Every repo using the `secret-scan` job MUST ship a `.gitleaks.toml` at the
repository root. The `Run gitleaks` step passes `--config .gitleaks.toml`;
without the file the job fails immediately with a file-not-found error.

Copy [`standards/gitleaks.toml`](gitleaks.toml) as a starting point and extend
the `paths` allowlist for any repo-specific false-positive paths. BMAD Method
repos **must** include `'''_bmad/'''` in the allowlist — the `generic-api-key`
rule fires on knowledge file paths such as `api-request.md` and
`auth-session.md`.

Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

This new .gitleaks.toml requirement callout is good, but the surrounding section still describes the setup as “gitleaks action” and shows an env: snippet including GITHUB_TOKEN. Since push-protection.md now documents a manual binary install, consider updating this section to match (remove the action-specific wording/token, and show where GITLEAKS_LICENSE should be set for org repos) to avoid adopters copy/pasting conflicting instructions.

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

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@standards/ci-standards.md`:
- Line 302: Update the guidance for the "Secrets found" table entry to stop
implying allowlisting is an acceptable default: change the cell that currently
reads "Legitimate secrets in the code | Add the path to `.gitleaks.toml`
`allowlist.paths`, or remove the secret" to instruct that real secrets must be
removed and rotated, and that adding paths to `.gitleaks.toml` `allowlist.paths`
is only allowed for confirmed false positives after documented justification and
approval; reference the "Secrets found" table header and the `.gitleaks.toml`
`allowlist.paths` symbol when making the change so reviewers can locate and
tighten the remediation text accordingly.

In `@standards/push-protection.md`:
- Around line 258-282: The document currently conflicts on which gitleaks
artifact to use: it mandates `.gitleaks.toml` in the “.gitleaks.toml template”
section but still instructs using `.gitleaksignore` in the “Writing tests and
fixtures” section; update the “Writing tests and fixtures” text to reference
`.gitleaks.toml` (and any example commands or file names there) so all guidance
consistently uses `.gitleaks.toml` and remove or replace any mention of
`.gitleaksignore`.
- Around line 227-241: Update the audit function secret_scan_ci_job_present in
scripts/lib/push-protection.sh (current logic at ~180-206 and similar check at
~250-255) so it no longer only greps for "uses: gitleaks/.*-action" but also
recognizes the new canonical job pattern by looking for the job name "name:
Install gitleaks" combined with the CLI invocation "gitleaks detect --config
.gitleaks.toml" (or the presence of both the install step and the detect
command); also update the compliance table description string that refers to the
old action to mention the new standard (Install gitleaks + gitleaks detect
--config .gitleaks.toml) so compliant repos are correctly classified.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 94305ad7-e024-461f-97cf-4874528512bd

📥 Commits

Reviewing files that changed from the base of the PR and between af066a7 and c01d02c.

📒 Files selected for processing (3)
  • standards/ci-standards.md
  • standards/gitleaks.toml
  • standards/push-protection.md

Comment thread standards/ci-standards.md Outdated
Comment thread standards/push-protection.md
Comment thread standards/push-protection.md
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
standards/ci-standards.md (1)

302-302: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Tighten secret-remediation guidance to avoid allowlisting real leaks.

Line 302 currently implies allowlisting is acceptable for any "Secrets found" failure. This weakens incident response: real secrets should be removed/rotated, and allowlist should be limited to confirmed false positives.

The guidance should clarify that adding paths to .gitleaks.toml allowlist.paths is only permitted for verified false positives after proper review, while actual secrets must always be removed and rotated immediately.

🔒 Suggested documentation fix
-| Secrets found | Legitimate secrets in the code | Add the path to `.gitleaks.toml` `allowlist.paths`, or remove the secret |
+| Secrets found | Secret detection triggered | Remove and rotate the secret immediately; use `.gitleaks.toml` `allowlist.paths` only for confirmed false positives |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@standards/ci-standards.md` at line 302, Update the guidance for the "Secrets
found" row so it no longer implies blanket allowlisting: specify that adding
paths to `.gitleaks.toml` `allowlist.paths` is only allowed for verified false
positives after a documented review/approval, and that any actual secrets
discovered must be removed and rotated immediately; reference `.gitleaks.toml`
and `allowlist.paths` explicitly and add a short required checklist (verify
false positive, obtain approval, document decision) to accompany any allowlist
entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@standards/ci-standards.md`:
- Line 302: Update the guidance for the "Secrets found" row so it no longer
implies blanket allowlisting: specify that adding paths to `.gitleaks.toml`
`allowlist.paths` is only allowed for verified false positives after a
documented review/approval, and that any actual secrets discovered must be
removed and rotated immediately; reference `.gitleaks.toml` and
`allowlist.paths` explicitly and add a short required checklist (verify false
positive, obtain approval, document decision) to accompany any allowlist entry.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 57784b43-e376-4a35-b6e6-81879df5f308

📥 Commits

Reviewing files that changed from the base of the PR and between c01d02c and dd3d3e2.

📒 Files selected for processing (1)
  • standards/ci-standards.md

@github-actions github-actions Bot requested a review from a team as a code owner May 4, 2026 20:31
@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

@dev-lead - please fix this PR

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

This was referenced May 25, 2026
@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

@don-petry
Copy link
Copy Markdown
Contributor Author

Auto-rebase failed — merge conflict — this branch has conflicts with main that must be resolved.

dev-lead will attempt to resolve this automatically. If it cannot, a follow-up comment will explain what needs manual attention.

To resolve manually instead:

git fetch origin
git merge origin/main
# resolve conflicts, then:
git add .
git commit
git push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants