Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Secret scan (Gitleaks)

on:
push:
pull_request:

permissions:
contents: read

jobs:
gitleaks:
name: Scan changed commits for secrets
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out full history
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Download and verify Gitleaks
shell: bash
run: |
set -euo pipefail
archive="$RUNNER_TEMP/gitleaks.tar.gz"
curl --fail --location --silent --show-error \
https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz \
--output "$archive"
printf '%s %s\n' \
'551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb' "$archive" \
| sha256sum --check --status
tar -xzf "$archive" -C "$RUNNER_TEMP" gitleaks
"$RUNNER_TEMP/gitleaks" version

- name: Scan new commits (redacted output)
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_BEFORE: ${{ github.event.before }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
COMMIT_SHA: ${{ github.sha }}
run: |
set -euo pipefail
base=''
if [[ "$EVENT_NAME" == "pull_request" ]]; then
base="$PR_BASE_SHA"
elif [[ -n "$EVENT_BEFORE" && ! "$EVENT_BEFORE" =~ ^0+$ ]]; then
base="$EVENT_BEFORE"
fi

if [[ -n "$base" ]] && git cat-file -e "${base}^{commit}" 2>/dev/null; then
"$RUNNER_TEMP/gitleaks" git --redact --log-opts="${base}..${COMMIT_SHA}" .
else
# Initial pushes have no before/base commit; scan available history.
"$RUNNER_TEMP/gitleaks" git --redact .
fi
Loading