Repository navigation
ci: scan every branch and tag for credentials with gitleaks (CIC-12) - #159
Conversation
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
left a comment
There was a problem hiding this comment.
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:
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.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-Verbosewould record them, with no values.quality-gates.yml:408:release.yml:40-41lists 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
|
Round 1: 3 fixed, 0 not changed
The upstream finding about the script's own help is fadwen/ai-powershell-standards#76, as the review says. New head 🤖 Generated with Claude Code |
fadwen-ai
left a comment
There was a problem hiding this comment.
Round 2: all three round-1 findings are fixed in d51db92 and their threads are resolved.
- The
quality-gates.ymlheader 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.ymllists 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
Summary
Adds a credential scan to CI (CIC-12, CIC-23). The new
credentialsjob 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.ps1and.gitleaks.toml, written by the standards installer (Install-CopilotStandards.ps1 -IncludeCredentialScan gitleaks, standardsmainat d7e28a3). The script belongs to the standards; the configuration belongs to this repository and adds nothing to gitleaks' built-in rules.credentialsjob at the end ofquality-gates.yml, in place of thecredential-scan.ymlthe installer writes.release.ymlcallsquality-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 hasfetch-depth: 0, without which the script refuses to scan.quality-gates.ymldescribes the sixth job.docs/StandardsDecisions.mdnow records the scan as built, and dependency scanning as not fitting (RequiredModules = @()).CLAUDE.mdlists 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 writecredential-scan.ymlagain and run the scan twice.CONTRIBUTING.mdandCHANGELOG.mdmention the scan, and the comment above thegatesjob inrelease.ymllists it.-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.mdand thepowershell-loggingskill in three places). Those were reverted here and are left to the weekly sync's pull request.Verification
./.github/scripts/Invoke-CredentialScan.ps1 -Scanner gitleakson 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.tomland the (absent).gitleaksignoreleave nothing out../Build/Invoke-Analysis.ps1: clean, 355 files../Build/Test-MarkdownLink.ps1: 27 links in 10 files, none broken.credentialsjob itself runs for the first time on this pull request.Notes
.gitleaks.toml, a future.gitleaksignore, the scan script and thecredentialsjob 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.