Skip to content

ci: scan every branch and tag for credentials with gitleaks (CIC-12) - #159

Merged
fadwen merged 2 commits into
mainfrom
ci/credential-scan
Nov 26, 2026
Merged

fadwen merged 2 commits into
mainfrom
ci/credential-scan

Conversation

@fadwen

@fadwen fadwen commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a credential scan to CI (CIC-12, CIC-23). The new credentials job of the quality gates scans every commit of every branch and tag, and the files of the checkout, with gitleaks. Closes #127.

Changes

  • .github/scripts/Invoke-CredentialScan.ps1 and .gitleaks.toml, written by the standards installer (Install-CopilotStandards.ps1 -IncludeCredentialScan gitleaks, standards main at d7e28a3). The script belongs to the standards; the configuration belongs to this repository and adds nothing to gitleaks' built-in rules.
  • A credentials job at the end of quality-gates.yml, in place of the credential-scan.yml the installer writes. release.yml calls quality-gates.yml, so a release cannot go out past the scan. gitleaks 8.30.1 is pinned by the SHA-256 of its Linux archive, and the checkout has fetch-depth: 0, without which the script refuses to scan.
  • The header of quality-gates.yml describes the sixth job.
  • The CIC-12 row of docs/StandardsDecisions.md now records the scan as built, and dependency scanning as not fitting (RequiredModules = @()).
  • CLAUDE.md lists the scan script among the files the weekly sync replaces, and says why the sync passes no -IncludeCredentialScan: the installer refreshes the script whenever the repository has one, and the flag would write credential-scan.yml again and run the scan twice.
  • CONTRIBUTING.md and CHANGELOG.md mention the scan, and the comment above the gates job in release.yml lists it.
  • The scan step runs with -Verbose, so a passing run records the probe values it found and the two scans it made. No value is written.

The installer also refreshed four standards files (powershell-security.instructions.md and the powershell-logging skill in three places). Those were reverted here and are left to the weekly sync's pull request.

Verification

  • ./.github/scripts/Invoke-CredentialScan.ps1 -Scanner gitleaks on Windows 11: it found the two values it plants (github-pat, stripe-access-token), then found no credential in the history or in the files. It wrote no "Left out of this scan" warning, because .gitleaks.toml and the (absent) .gitleaksignore leave nothing out.
  • ./Build/Invoke-Analysis.ps1: clean, 355 files.
  • ./Build/Test-MarkdownLink.ps1: 27 links in 10 files, none broken.
  • The credentials job itself runs for the first time on this pull request.

Notes

  • .gitleaks.toml, a future .gitleaksignore, the scan script and the credentials job decide what the scan reports, and a pull request runs its own copies of them. With one maintainer, no CODEOWNERS rule binds the author of a change. The check to read is the "Left out of this scan" warning, which a run writes only when the configuration or the ignore file leaves something out.
  • The job is not yet a required check. That is a branch rule for the owner to set once the first run on GitHub has been read.

The repository had no credential scan, and a credential that was
committed stays in the history after the commit that removes it. The
standards installer wrote the scan script and a gitleaks configuration;
the job runs in quality-gates.yml rather than a workflow of its own, so
that the release, which calls quality-gates.yml, cannot go out past it.

gitleaks writes REDACTED in place of each value, which matters because
this repository's CI logs are public. The weekly sync keeps the script
current without -IncludeCredentialScan, which would add the separate
workflow back and run the scan twice.

@fadwen-ai fadwen-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The job is wired correctly: it runs in quality-gates.yml, so release.yml's gates job (which publish needs) runs it too, the checkout has fetch-depth: 0 and the run log shows every branch and tag fetched, and the pinned SHA-256 matches the script's linux_x64 hash for gitleaks 8.30.1. The sync claim holds against the installer at d7e28a3: it refreshes .github/scripts/Invoke-CredentialScan.ps1 whenever the file carries the "Generated from" marker, with or without -IncludeCredentialScan, and .github/scripts/ is not one of the owned patterns it deletes from, so the script is neither dropped nor joined by a second workflow.

Three nits, all about what the log and the comments tell a reader:

  1. quality-gates.yml:56: the header says every run writes how much is left out under "Left out of this scan". The script writes that warning only when something is left out, and the first run on this PR wrote no line at all. The PR description's Notes say the same.
  2. quality-gates.yml:440: a passing run leaves nothing in the log. In run 45749459993 the scan step printed no output; the probe result and the clean result are verbose only. Passing -Verbose would record them, with no values.
  3. quality-gates.yml:408: release.yml:40-41 lists the gates the release runs and now leaves out this one.

Out of scope: new fadwen/ai-powershell-standards#76; already tracked none

🤖 Generated with Claude Code

Comment thread .github/workflows/quality-gates.yml Resolved
Comment thread .github/workflows/quality-gates.yml Resolved
Comment thread .github/workflows/quality-gates.yml Resolved
@fadwen

fadwen commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

Round 1: 3 fixed, 0 not changed

  • The header no longer says every run writes "Left out of this scan". It says the line appears only when something is left out, and so does the PR description.
  • The scan step runs verbose, so a passing run records the probe and the two scans, never a value.
  • release.yml lists the credential scan among the gates it runs.

The upstream finding about the script's own help is fadwen/ai-powershell-standards#76, as the review says. New head d51db92.

🤖 Generated with Claude Code

@fadwen-ai fadwen-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Round 2: all three round-1 findings are fixed in d51db92 and their threads are resolved.

  • The quality-gates.yml header and the PR description now say the "Left out of this scan" line appears only when something is left out.
  • The scan step passes Verbose = $true. In run 45750011159 the log now records the probe (github-pat, stripe-access-token), the history and files scans, and "gitleaks found no credential", with no value written.
  • release.yml lists the credential scan among the gates.

I re-read the whole diff against main. The script and .gitleaks.toml are unchanged since round 1, and I found nothing new. The Windows test jobs were still running when I submitted this.

Out of scope: new none; already tracked fadwen/ai-powershell-standards#76

🤖 Generated with Claude Code

@fadwen
fadwen merged commit ae73c8e into main Nov 26, 2026
6 checks passed
@fadwen
fadwen deleted the ci/credential-scan branch November 26, 2026 03:51
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.

CI runs no credential scan (CIC-12)

2 participants