From a3127ab20092e245a7d570b8b597c0bb05cb717c Mon Sep 17 00:00:00 2001 From: Mike Wolf Date: Tue, 17 Nov 2026 20:21:01 -0500 Subject: [PATCH 1/2] ci: add secret scanning Runs TruffleHog and the gitleaks CLI on every pull request and every push to main, as two checks. A standalone copy of the org's shared workflow, which a public repository cannot call. Part of PF-1540 Co-Authored-By: Claude Fable 5.2 --- .github/workflows/security-checks.yml | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/security-checks.yml diff --git a/.github/workflows/security-checks.yml b/.github/workflows/security-checks.yml new file mode 100644 index 0000000..b1d941d --- /dev/null +++ b/.github/workflows/security-checks.yml @@ -0,0 +1,54 @@ +# Secret scan on every pull request and every push to main: TruffleHog and gitleaks, as two checks. +# This repository is public, so it cannot call the shared workflow in the private +# Blockworks-Projects/workflows repository. This is a copy of its security-checks.yml; +# keep the pins in step with it. + +name: Security checks + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +jobs: + # TruffleHog: a credential its provider confirms is live, or could not test. + secrets-verified: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + fetch-depth: 0 + persist-credentials: false + - name: TruffleHog + uses: trufflesecurity/trufflehog@3bd2b5887eb0efb8fa18bfd1d296032924e4ffdc # v3.99.9 + with: + version: 3.99.9@sha256:2ec535840f860aa27f11fee20222fb790326ecd66325c96bd49d02ec6af46eca # image; `latest` if unset + extra_args: --results=verified,unknown + - if: failure() + run: echo "TruffleHog found a secret. Rotate it first, then remove it." >> "$GITHUB_STEP_SUMMARY" + + # gitleaks CLI: known key formats and high-entropy strings. + secrets-patterns: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + fetch-depth: 0 + persist-credentials: false + - name: gitleaks + env: + GITLEAKS_IMAGE: ghcr.io/gitleaks/gitleaks:v8.30.1@sha256:c00b6bd0aeb3071cbcb79009cb16a60dd9e0a7c60e2be9ab65d25e6bc8abbb7f + FROM: ${{ github.event.pull_request.base.sha || github.event.before }} + TO: ${{ github.event.pull_request.head.sha || github.event.after }} + run: | + # The event's commits, or the whole history when there is no usable range. + range=() + if [ -n "$(git rev-list -1 "$FROM..$TO" 2>/dev/null)" ]; then range=(--log-opts="$FROM..$TO"); fi + docker run --rm -v "$PWD:/repo" -w /repo "$GITLEAKS_IMAGE" git --redact --verbose --no-banner "${range[@]}" /repo + - if: failure() + run: echo "gitleaks found something that looks like a secret. Real - rotate it first, then remove it. False alarm - add its Fingerprint to .gitleaksignore." >> "$GITHUB_STEP_SUMMARY" From e22aaf5a151617bcd9c8214b3ebe299b132db580 Mon Sep 17 00:00:00 2001 From: Mike Wolf Date: Wed, 18 Nov 2026 23:01:48 -0500 Subject: [PATCH 2/2] Sync the scan with the shared security-checks workflow Brings this copy in line with the shared workflow's three later changes: - the checkout no longer fails on a broken submodule entry - TruffleHog scans the checkout in place instead of copying it first - gitleaks findings are annotated on their line in the pull request diff - the step that explains a failed scan has a name, so a passing run no longer lists its message as a step Co-Authored-By: Claude Fable 5.2 --- .github/workflows/security-checks.yml | 30 +++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/security-checks.yml b/.github/workflows/security-checks.yml index b1d941d..5e68d96 100644 --- a/.github/workflows/security-checks.yml +++ b/.github/workflows/security-checks.yml @@ -22,13 +22,15 @@ jobs: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: fetch-depth: 0 - persist-credentials: false - name: TruffleHog + id: scan uses: trufflesecurity/trufflehog@3bd2b5887eb0efb8fa18bfd1d296032924e4ffdc # v3.99.9 with: version: 3.99.9@sha256:2ec535840f860aa27f11fee20222fb790326ecd66325c96bd49d02ec6af46eca # image; `latest` if unset - extra_args: --results=verified,unknown - - if: failure() + # --trust-local-git-config scans the checkout in place; by default TruffleHog copies the repository first. + extra_args: --results=verified,unknown --trust-local-git-config + - name: Explain the failure # named so a passing run does not list the message below as a step + if: failure() && steps.scan.outcome == 'failure' run: echo "TruffleHog found a secret. Rotate it first, then remove it." >> "$GITHUB_STEP_SUMMARY" # gitleaks CLI: known key formats and high-entropy strings. @@ -39,8 +41,8 @@ jobs: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: fetch-depth: 0 - persist-credentials: false - name: gitleaks + id: scan env: GITLEAKS_IMAGE: ghcr.io/gitleaks/gitleaks:v8.30.1@sha256:c00b6bd0aeb3071cbcb79009cb16a60dd9e0a7c60e2be9ab65d25e6bc8abbb7f FROM: ${{ github.event.pull_request.base.sha || github.event.before }} @@ -49,6 +51,22 @@ jobs: # The event's commits, or the whole history when there is no usable range. range=() if [ -n "$(git rev-list -1 "$FROM..$TO" 2>/dev/null)" ]; then range=(--log-opts="$FROM..$TO"); fi - docker run --rm -v "$PWD:/repo" -w /repo "$GITLEAKS_IMAGE" git --redact --verbose --no-banner "${range[@]}" /repo - - if: failure() + # The report goes outside the checkout, into a directory the image's user can write to. + out="$RUNNER_TEMP/gitleaks" + install -d -m 777 "$out" + status=0 + docker run --rm -v "$PWD:/repo" -v "$out:/out" -w /repo "$GITLEAKS_IMAGE" git --redact --verbose --no-banner \ + --report-format json --report-path /out/findings.json "${range[@]}" /repo || status=$? + # One annotation per finding, which GitHub shows on that line in the pull request's "Files changed" tab. + if [ -s "$out/findings.json" ]; then + jq -r ' + def msg: gsub("%"; "%25") | gsub("\r"; "%0D") | gsub("\n"; "%0A"); + def prop: msg | gsub(":"; "%3A") | gsub(","; "%2C"); + .[] | "::error file=\(.File | prop),line=\(.StartLine),title=\("gitleaks: " + .RuleID | prop)::" + + ("Looks like a secret, added in commit \(.Commit[0:7]). Real: rotate it first, then remove it. False alarm: add this line to .gitleaksignore: \(.Fingerprint)" | msg) + ' "$out/findings.json" || echo "Could not turn the gitleaks report into annotations; the findings are in the log above." + fi + exit "$status" + - name: Explain the failure # named so a passing run does not list the message below as a step + if: failure() && steps.scan.outcome == 'failure' run: echo "gitleaks found something that looks like a secret. Real - rotate it first, then remove it. False alarm - add its Fingerprint to .gitleaksignore." >> "$GITHUB_STEP_SUMMARY"