Skip to content

Commit b63a5c5

Browse files
remigiusz-antczakclaudeRemigiusz Antczak
authored
Add free secret-scan CI workflow template (#2293)
* Add free secret-scan CI workflow template Opt-in templates/secret-scan.yml: gitleaks pinned by version and sha256, checkout pinned by SHA with persist-credentials false, PR scan of base..head, full-history scan on push, weekly schedule and dispatch, false positives via .gitleaksignore fingerprints (no path allowlists). No license or cost. Routed from references/review-config.md; a static test pins the properties. Tests: 7/7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Harden secret-scan template: base-config reset on PRs, stronger test PR scans now reset .gitleaks.toml and .gitleaksignore to the base commit's copy so a PR cannot silence its own findings. The test pins the exact digest and version, least-privilege permissions, no expressions in run blocks, triggers, flags, install order, the base..head and full-history branches and the config reset, and proves each check fails on a seeded mutation. Logs the checkout v7.0.1 and gitleaks v8.30.1 releases in docs/standards-index.md. Tests: 19/19 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Secret-scan template: honest reset comment, anchored digest check, reset-order and dash-run checks The reset comment now says it only blocks edits to the root .gitleaks.toml and .gitleaksignore; a PR editing the workflow itself can still bypass it, so protect .github/workflows/ with CODEOWNERS and required review and make the check required. The test now anchors the digest line (ends sha256sum -c -, no ||), asserts the reset precedes the PR-path scan, and matches '- run:' step form in the no-expression check, each proven by a seeded mutation. Tests: 22/22 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Remigiusz Antczak <remigiusz@antczak.io>
1 parent d991e2f commit b63a5c5

7 files changed

Lines changed: 119 additions & 1 deletion

File tree

‎.claude/skills/deep-code-review/references/review-config.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,5 @@ on any ungrounded gap row. Before posting, run `merge_findings.py [--cap N] [--r
9999
grounding, dedupes, ranks and caps. Rules and reasons live in the two script docstrings. Zero findings is valid: say NONE.
100100

101101
Read this when you want PR-native review in CI: `templates/perun-review.yml` is an opt-in workflow (never installed by `install.sh`); its header lists the prerequisites and hardening.
102+
103+
Read this when you want a free secret scan in CI: `templates/secret-scan.yml` is an opt-in workflow (never installed by `install.sh`) that runs a pinned, sha256-checked gitleaks binary with no license or secrets; a PR scans base..head, push and the weekly schedule scan full history, and false positives go in `.gitleaksignore`, never a path allowlist. `scripts/test-secret-scan-template.sh` pins those properties.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: secret-scan
2+
3+
# Opt-in, free secret scan: copy to `.github/workflows/secret-scan.yml`. Never installed by `install.sh`.
4+
# No license key, no paid action, no secrets: it runs the open-source gitleaks binary,
5+
# pinned by version and sha256 (bump both together; the digest is in the release's checksums file).
6+
# A pull request scans only base..head; push, the weekly schedule and manual dispatch scan the full history.
7+
# Handle a false positive by adding its fingerprint (printed by the scan) to `.gitleaksignore`;
8+
# never by allowlisting a path, which hides every future secret under it.
9+
# A PR scan resets .gitleaks.toml and .gitleaksignore to the base commit's copy first, so a PR cannot
10+
# silence its own findings by editing those two root files; push, schedule and dispatch use the committed config.
11+
# This does not stop a PR that edits this workflow file itself: protect .github/workflows/ with CODEOWNERS
12+
# plus required review, and make this check required.
13+
# Edit the push branch if your default branch is not `main`.
14+
15+
on:
16+
pull_request:
17+
push:
18+
branches: [main]
19+
schedule:
20+
- cron: '17 4 * * 1'
21+
workflow_dispatch:
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
gitleaks:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
with:
32+
fetch-depth: 0
33+
persist-credentials: false
34+
- name: Install gitleaks v8.30.1
35+
run: |
36+
curl -sSfL -o gitleaks.tgz https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz
37+
echo "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb gitleaks.tgz" | sha256sum -c -
38+
tar -xzf gitleaks.tgz gitleaks
39+
- name: Scan
40+
env:
41+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
42+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
43+
run: |
44+
if [ -n "$BASE_SHA" ]; then
45+
for f in .gitleaks.toml .gitleaksignore; do git show "$BASE_SHA:$f" > "$f" 2>/dev/null || rm -f "$f"; done
46+
./gitleaks git --redact --exit-code 1 -v --log-opts="$BASE_SHA..$HEAD_SHA"
47+
else
48+
./gitleaks git --redact --exit-code 1 -v
49+
fi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Added
2+
- templates/secret-scan.yml: opt-in free secret-scan workflow (pinned gitleaks with sha256, SHA-pinned checkout, PR base..head scan, full-history on push/weekly/dispatch, `.gitleaksignore` for false positives), routed from references/review-config.md and pinned by scripts/test-secret-scan-template.sh (with seeded mutations). PR scans reset the ignore config to the base commit first.
3+
4+
size-budget-raise: .claude/skills/deep-code-review/references/review-config.md 6472→6888 secret-scan template route

‎docs/INDEX.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Generated by `python3 .claude/skills/agentic-delivery/scripts/focus_kit.py docs-
2323
| `docs/scoreboard.md` | Perun scoreboard: Generated by scripts/scoreboard.py from committed results | 5143 |
2424
| `docs/security-heldout-table-1026/table.md` | Security held-out table, 2026-10-26: Generated by results.py (offline, $0, byte-identical on rerun). | 1847 |
2525
| `docs/self-improvement.md` | How Perun improves itself: Perun is improved by running Perun on Perun: its own review skill (deep-code-review), idea attack (idea-critic),… | 1268 |
26-
| `docs/standards-index.md` | Standards index: Every standard the skill relies on, split into what was verified by direct fetch for this release and what is referenced b… | 102774 |
26+
| `docs/standards-index.md` | Standards index: Every standard the skill relies on, split into what was verified by direct fetch for this release and what is referenced b… | 103167 |
2727
| `docs/team-install.md` | Team-wide install through a Claude Code plugin marketplace: This repository is its own marketplace (.claude-plugin/marketplace.json, name p… | 478 |
2828
| `docs/technical-overview.md` | Technical overview: you want the engineering detail that used to sit in the top-level README.md: the mechanisms table, the full "what you g… | 2288 |
2929
| `docs/token-cost-tips.md` | Token cost tips for teams: the biggest savings come from sending less context, using the cheapest model tier that clears its own gate, and… | 2127 |

‎docs/standards-index.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,3 +1945,5 @@ Verification date: **2026-11-05**. Raw-byte sha256 of each fetch and the item id
19451945
| CWE Top 25 (2025) | https://cwe.mitre.org/top25/archive/2025/2025_cwe_top25.html | 25 ranked CWEs. |
19461946
| OWASP Top 10 for LLM Applications 2025 | https://genai.owasp.org/llm-top-10/ | LLM01:2025–LLM10:2025, 10 items. |
19471947
| OWASP Top 10 for Agentic Applications 2026 (announcement, 2025-12-09) | https://genai.owasp.org/2025/12/09/owasp-top-10-for-agentic-applications-the-benchmark-for-agentic-security-in-the-age-of-autonomous-ai/ | ASI01–ASI10, 10 items. The resource landing page (https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/) was also fetched but does not list titles; the PDF was not fetched. |
1948+
| actions/checkout — v7.0.1 release | https://github.com/actions/checkout/releases/tag/v7.0.1 | Tag v7.0.1 resolves to commit 3d3c42e5aac5ba805825da76410c181273ba90b1 (checked via the GitHub API). Pinned in `templates/secret-scan.yml`. Verified 2026-11-11. |
1949+
| gitleaks — v8.30.1 release | https://github.com/gitleaks/gitleaks/releases/tag/v8.30.1 | Published 2026-03-21 (checked via the GitHub API). Pinned with its sha256 in `templates/secret-scan.yml`. Verified 2026-11-11. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bash scripts/test-secret-scan-template.sh
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
# Static checks on templates/secret-scan.yml, then seeded mutations: each must make a check fail.
3+
set -uo pipefail
4+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
F="$ROOT/.claude/skills/deep-code-review/templates/secret-scan.yml"
6+
T=$(mktemp -d "${TMPDIR:-/tmp}/dcr-test-ssc.XXXXXX"); trap 'rm -rf "$T"' EXIT
7+
DIGEST=551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb
8+
# failing check names for file $1 (empty = all pass)
9+
fails() {
10+
local b; b=$(grep -v '^ *#' "$1")
11+
ck() { local d=$1; shift; "$@" <<<"$b" >/dev/null 2>&1 || echo "$d"; }
12+
ck "digest pinned" grep -qE "^ *echo \"$DIGEST gitleaks\.tgz\" \| sha256sum -c -\$"
13+
ck "version in URL" grep -q 'releases/download/v8\.30\.1/gitleaks_8\.30\.1_linux_x64\.tar\.gz'
14+
ck "checkout SHA" grep -qE 'uses: actions/checkout@[0-9a-f]{40}( |$)'
15+
ck "persist-credentials" grep -q 'persist-credentials: false'
16+
ck "permissions only contents read" bash -c "[ \"\$(sed -n '/^permissions:/,/^[a-z]/p' | grep '^ ')\" = ' contents: read' ]"
17+
ck "no expression in run" bash -c "! awk '/^ *(- )?run: /{r=1;i=match(\$0,/[^ ]/);if(\$0~/\\\$\\{\\{/)f=1;next} r&&/^ *[^ ]/{if(match(\$0,/[^ ]/)<=i)r=0; else if(\$0~/\\\$\\{\\{/)f=1} END{exit !f}'"
18+
ck "pull_request trigger" grep -qE '^ pull_request:'
19+
ck "push trigger" grep -qE '^ push:'
20+
ck "schedule trigger" grep -qE '^ schedule:'
21+
ck "no gitleaks-action" bash -c '! grep -qi gitleaks-action'
22+
ck "no path allowlist" bash -c "! grep -qiE 'allowlist|--config|\\[\\[allowlists|paths *=|--gitleaks-ignore-path'"
23+
ck "--redact" grep -q -- '--redact'
24+
ck "--exit-code 1" grep -q -- '--exit-code 1'
25+
ck "sha256sum before tar" bash -c "awk '/sha256sum -c/{s=NR} /tar -x/{t=NR} END{exit !(s&&t&&s<t)}'"
26+
ck "BASE_SHA guard" grep -qF 'if [ -n "$BASE_SHA" ]'
27+
ck "else full history" grep -qE '^ +else$'
28+
ck "PR scan base..head" grep -qF 'BASE_SHA..$HEAD_SHA'
29+
ck "reset before PR scan" bash -c 'awk '"'"'/git show/{r=NR} /BASE_SHA\.\.\$HEAD_SHA/{p=NR} END{exit !(r&&p&&r<p)}'"'"
30+
ck "base config reset" grep -qF 'git show "$BASE_SHA:$f"'
31+
}
32+
pass=0 total=0
33+
chk() { total=$((total + 1)); if [ "$1" -eq 0 ]; then pass=$((pass + 1)); echo "PASS $2"; else echo "FAIL $2"; fi; }
34+
out=$(fails "$F"); [ -z "$out" ]; chk $? "shipped template passes every check${out:+ (failed: $out)}"
35+
mut() { # name, sed args: the mutant must fail some check
36+
sed "${@:2}" "$F" >"$T/m.yml"; cmp -s "$F" "$T/m.yml" && { chk 1 "mutation $1 changed nothing"; return; }
37+
[ -n "$(fails "$T/m.yml")" ]; chk $? "mutation caught: $1"
38+
}
39+
mut digest 's/551f6fc8/551f6fc9/'
40+
mut version 's/v8\.30\.1\/gitleaks_8\.30\.1/v8.30.0\/gitleaks_8.30.0/'
41+
mut checkout-tag 's/checkout@[0-9a-f]\{40\}/checkout@v4/'
42+
mut persist 's/persist-credentials: false/persist-credentials: true/'
43+
mut permissions 's/ contents: read/ contents: write/'
44+
mut run-expr 's/tar -xzf gitleaks.tgz gitleaks/echo ${{ github.actor }}/'
45+
mut no-pr 's/^ pull_request:/ pull_request_x:/'
46+
mut no-push 's/^ push:/ pushx:/'
47+
mut no-schedule 's/^ schedule:/ schedulex:/'
48+
mut action 's#./gitleaks git --redact --exit-code 1 -v$#uses: gitleaks/gitleaks-action@v2#'
49+
mut allowlist 's/--redact/--config=allowlist.toml --redact/'
50+
mut redact 's/--redact //g'
51+
mut exit-code 's/--exit-code 1/--exit-code 0/g'
52+
mut order -e '/sha256sum -c/{h;d;}' -e '/tar -xzf/G'
53+
mut guard 's/-n "\$BASE_SHA"/-z "$BASE_SHA"/'
54+
mut else 's/^\( *\)else$/\1elif false; then/'
55+
mut range 's/BASE_SHA\.\.\$HEAD_SHA/HEAD_SHA/'
56+
mut reset 's/git show "\$BASE_SHA:\$f"/git show "HEAD:$f"/'
57+
mut digest-or 's/ | sha256sum -c -$/ | sha256sum -c - || true/'
58+
mut run-dash 's/^ - name: Install gitleaks v8.30.1$/ - run: echo ${{ github.actor }}/'
59+
mut reset-order -e '/git show/{h;d;}' -e '/--log-opts/G'
60+
echo "Tests: $pass/$total"; [ "$pass" -eq "$total" ]

0 commit comments

Comments
 (0)