{"slug":"powershell-credential-scan-2","title":"powershell-credential-scan","summary":"Add a credential scan to the CI of a PowerShell project with betterleaks, gitleaks, or trufflehog, and deal with what it reports. Use when asked to add, set up, or repair secret scanning, credential scanning, or leak detection, or to handle the findings of such a scan.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-11-27T19:12:19.303341Z","repo":{"url":"https://github.com/fadwen/ai-powershell-standards","stars":24,"forks":4,"license":"MIT","updatedAt":"2026-11-26T19:42:48Z"},"bodyHtml":"<hr>\n<h2>name: powershell-credential-scan\ndescription: Add a credential scan to the CI of a PowerShell project with betterleaks, gitleaks, or trufflehog, and deal with what it reports. Use when asked to add, set up, or repair secret scanning, credential scanning, or leak detection, or to handle the findings of such a scan.</h2>\n<h1>Add a credential scan</h1>\n<p>A credential that was committed stays in the repository after the commit that removes it. This\nskill adds a scan of the history and the files to the project's CI (CIC-23), with the scanner that\nthe user chooses, and deals with what the first run reports.</p>\n<p>Read these first, unless they are already loaded:</p>\n<ul>\n<li><code>.github/copilot-instructions.md</code>, or <code>AGENTS.md</code> if the repository has no such file</li>\n<li><code>.github/instructions/powershell-cicd.instructions.md</code></li>\n<li><code>.github/instructions/powershell-security.instructions.md</code></li>\n</ul>\n<p>Every statement about a scanner below was measured with betterleaks 1.10.1, gitleaks 8.30.1, and\ntrufflehog 3.100.1 on Linux, macOS, and Windows.</p>\n<h2>Steps</h2>\n<ol>\n<li><p>Look for a scan that the project already has: a workflow job or a hook that runs betterleaks,\ngitleaks, trufflehog, or another scanner, and files such as <code>.betterleaks.toml</code>,\n<code>.gitleaks.toml</code>, and <code>.gitleaksignore</code>. A scan that works is left as it is. Do not replace it,\nadd a second one beside it, or move it to the form below unless the user asks for that.</p>\n</li>\n<li><p>Ask the user which scanner to use, and say that the scan runs on every pull request and every\npush to the default branch, which uses the project's CI time. Do not choose for them. The\nthree differ in what they report:</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>betterleaks</th>\n<th>gitleaks</th>\n<th>trufflehog</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>A quoted word after such a name, as in <code>$password = 'qwerty'</code></td>\n<td>Reported</td>\n<td>Not reported</td>\n<td>Not reported</td>\n</tr>\n<tr>\n<td>A quoted random value after such a name</td>\n<td>Reported</td>\n<td>Reported for some values and not for others</td>\n<td>Not reported</td>\n</tr>\n<tr>\n<td><code>$password = [System.Security.SecureString]::new()</code></td>\n<td>Reported without the installed configuration</td>\n<td>Not reported</td>\n<td>Not reported</td>\n</tr>\n<tr>\n<td>A key in the form of a known service</td>\n<td>Reported</td>\n<td>Reported</td>\n<td>Reported</td>\n</tr>\n<tr>\n<td>Leaving out one finding</td>\n<td>Fingerprint in <code>.betterleaksignore</code></td>\n<td>Fingerprint in <code>.gitleaksignore</code></td>\n<td>Fingerprint in <code>.trufflehogignore</code>, which the scan script reads</td>\n</tr>\n</tbody>\n</table>\n</li>\n<li><p>Install the scan with the installer of the standards repository, from a clone at the reference\nthat the project's sync workflow names (<code>STANDARDS_REPO</code> and <code>STANDARDS_REF</code>), or <code>main</code>. Give\nthe path of the project and the scanner that the user chose, here gitleaks:</p>\n<pre><code>./Tools/Install-CopilotStandards.ps1 -ProjectPath '../MyModule' -IncludeCredentialScan gitleaks\n</code></pre>\n<p>It writes <code>.github/scripts/Invoke-CredentialScan.ps1</code>, <code>.github/workflows/credential-scan.yml</code>,\nand the configuration of the scanner in the root of the project. The script belongs to the\nstandards and later updates replace it. The workflow and the configuration belong to the\nproject, and a file that is already there is not replaced.</p>\n</li>\n<li><p>When the project has one workflow that its release also runs, move the job from\n<code>credential-scan.yml</code> into that workflow with its three <code>env</code> values and remove the separate\nfile, so that a release cannot go out past the scan. Keep <code>fetch-depth: 0</code>: the script refuses\na clone that does not hold the whole history.</p>\n</li>\n<li><p>Say that the ignore file, the configuration, the scan script, and the workflow decide what the\nscan reports, and that a pull request runs its own copies of them, so a change can leave out\nthe finding that it adds. When the project has more than one maintainer, offer to require a\nreview for those paths with entries in its CODEOWNERS file, here for gitleaks:</p>\n<pre><code>/.gitleaks.toml @owner\n/.gitleaksignore @owner\n/.github/scripts/Invoke-CredentialScan.ps1 @owner\n/.github/workflows/credential-scan.yml @owner\n</code></pre>\n<p>Put them after the other lines, because the last pattern that matches a file decides, and say\nthat the entries require nothing until the branch rule \"Require review from Code Owners\" is\non. Do not turn that rule on unasked. When the project has one maintainer, say that no such\nrule binds the author of a change, and that the warning which the scan writes in every run,\n\"Left out of this scan\", is the check to read.</p>\n</li>\n<li><p>Run the scan. On a computer where the scanner may run:</p>\n<pre><code>./.github/scripts/Invoke-CredentialScan.ps1 -Scanner gitleaks\n</code></pre>\n<p>The script downloads the scanner, and an application control policy can refuse to start a\ndownloaded program. Do not look for a way around the policy: push the branch and read the\nresult of the workflow instead.</p>\n</li>\n<li><p>Read every finding, as the next section says, until the scan passes. Then report.</p>\n</li>\n</ol>\n<h2>Reading a finding</h2>\n<p>The scan reports a place, never a value: the rule, the file, the line, the commit for a finding in\nthe history, and a fingerprint. Look at the place itself, with <code>git show &lt;commit&gt;:&lt;file&gt;</code> for the\nhistory.</p>\n<ul>\n<li><strong>A real credential.</strong> Tell the user at once, and that it has to be revoked at the service that\nissued it before anything else. Removing it from the file does not remove it from the history,\nand everyone who can read the repository can read it there. Only after it is revoked does its\nfingerprint go into the ignore file, with a comment that says so. Rewriting the history is the\nuser's decision, not a step of this skill.</li>\n<li><strong>A placeholder in a file</strong>, such as a password in a test or a sample. Prefer changing the value\nso that the scanner no longer reports it: build it at run time, or use a value that is not in\nthe form of a credential.</li>\n<li><strong>A placeholder in the history.</strong> A commit does not change, so the value cannot be changed\nthere. Its fingerprint goes into the ignore file, under a comment that says what it is.</li>\n<li><strong>A form that is never a credential</strong>, reported in many places. For betterleaks and gitleaks,\nadd an <code>[[allowlists]]</code> entry to the configuration that names the rule and the form. gitleaks\nrefuses a configuration that names a rule which it does not have. For trufflehog, leave a path\nout in <code>.trufflehog-exclude.txt</code> only when nothing in that path can be a credential.</li>\n</ul>\n<p>An entry in an ignore file or an exception in a configuration MUST NOT be added to make the scan\npass. Each one is a finding that was read. A rule MUST NOT be switched off with <code>disabledRules</code>,\nreplaced by a rule of the same name, or filtered for that either: the scan runs again without the\nconfiguration, and its warning counts every place that the configuration leaves out. Show the\nuser the list before it is committed: the user decides what is left out.</p>\n<p>To change the scanner later, change the three <code>env</code> values of the workflow to the name, the\nversion, and the SHA-256 of the archive for the runner, as the checksum file of that release gives\nit, and add the configuration of the new scanner. To change the version, change the version and\nthe hash together and read what the new version reports: its built-in rules belong to it. The\nscript supports betterleaks 1.x, gitleaks 8.x, and trufflehog 3.x.</p>\n<h2>Report</h2>\n<p>Say which scanner the user chose and which files were added or changed. List every finding of the\nfirst run with its place and what was done about it: revoked, changed, or left out, with the\nreason. Quote the \"Left out of this scan\" warning of the last run, so that the user sees how much\nthe scan does not report. Say whether the scan was run on this computer or only in the workflow, and what its last\nrun reported. If a real credential was found, say so first.</p>\n","files":[{"path":"SKILL.md","sizeBytes":7642,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-11-27T19:15:06.788373Z","sha256":"9562A484A1F2ECB8DBC1A7937BA387C5B23987BAEA4E847FC8B3F64AB4E4CFE7","sizeBytes":3071},"review":null,"source":{"repositoryUrl":"https://github.com/fadwen/ai-powershell-standards","path":".claude/skills/powershell-credential-scan","license":"MIT","commit":"fbf1a1774b64492b5c11c5519d387ea3ead78e1b","subtreeSha":"F56DE14A594DE04DAF2D4619A6AA1B890644C49DC7826B33A0675E358894FF3F","lastSyncedAt":"2026-11-27T19:12:17.594057Z"},"reviewedAt":"2026-11-27T19:25:15.732658Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/fadwen/ai-powershell-standards/tree/main/.claude/skills/powershell-credential-scan"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install fadwen-ai-powershell-standards@llmmart"},{"target":"git","command":"git clone https://github.com/fadwen/ai-powershell-standards.git"}]}