Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# Pre-commit hook: scan the staged changes with gitleaks. Installed by `pnpm install`
# (the prepare step runs scripts/secret-scan/install-hook.mjs). Without gitleaks on PATH it says
# how to install it and lets the commit through; the Secret scan job in CI still checks the push.
if ! command -v gitleaks >/dev/null 2>&1; then
echo "pre-commit: gitleaks is not on PATH, so the staged changes were NOT scanned." >&2
echo " Install gitleaks 8.30.1 or newer (winget install Gitleaks.Gitleaks, brew install gitleaks," >&2
echo " or the release page: https://github.com/gitleaks/gitleaks/releases), then commit again." >&2
exit 0
fi
root="$(git rev-parse --show-toplevel)" || exit 1
exec gitleaks git --staged --redact --no-banner --verbose --config "$root/.gitleaks.toml"
48 changes: 48 additions & 0 deletions .github/workflows/secret-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Secret scan

# One job: the gitleaks CLI at a pinned version, checked against a pinned sha256 before it runs.
# No third-party action and no repository secret. The config is .gitleaks.toml, byte for byte
# the copy in gateweave-ops. The `secret-scan-test/**` trigger lets a throwaway branch prove
# that a generated fixture fails this job.

on:
pull_request:
push:
branches:
- main
- "secret-scan-test/**"

permissions:
contents: read

env:
GITLEAKS_VERSION: 8.30.1
# sha256 of gitleaks_8.30.1_linux_x64.tar.gz, equal to the line in the release's checksums file.
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb

jobs:
gitleaks:
name: Secret scan (gitleaks)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Install gitleaks (pinned version and checksum)
run: |
set -euo pipefail
file="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
curl --proto '=https' --tlsv1.2 -fsSL -o "$RUNNER_TEMP/$file" \
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${file}"
echo "${GITLEAKS_SHA256} $RUNNER_TEMP/$file" | sha256sum --check -
mkdir "$RUNNER_TEMP/gitleaks"
tar -xzf "$RUNNER_TEMP/$file" -C "$RUNNER_TEMP/gitleaks" gitleaks
- name: Scan the history
# Only the history reachable from the commit this run checked out, never every branch that
# fetch-depth 0 brought in: a throwaway test branch must not fail other pushes or pull requests.
# Include each merge's diff against its parents so the scan covers changes made in a merge.
run: |
"$RUNNER_TEMP/gitleaks/gitleaks" git --redact --no-banner --verbose \
--config .gitleaks.toml --exit-code 1 --log-opts="--diff-merges=separate $(git rev-parse HEAD)"
Loading
Loading