Skip to content

Commit 8026496

Browse files
security: remove .gitleaksbaseline + secrets-audit + simplify secret-scan
These files were a security liability: even though Secret/Match fields were redacted, they still mapped attackers to exactly which files, commits, authors, and line numbers historically contained credentials. An external contributor cloning the repo could read them and know where to look in git history for extractable keys. Removed: .gitleaksbaseline (JSON: 49 findings, commit SHAs, file paths) docs/secrets-audit.md (human-readable table — even more exploitable) docs/starter-apps.md (not security-sensitive, but low-value + drifts fast; the 5 starter repos are discoverable on the org page, and release.yml already clones them at runtime for consumer validation) Simplified .github/workflows/secret-scan.yml: - No longer uses --baseline-path (redundant with incremental scans) - Scans only the commit range introduced by the event: PR: base.sha..HEAD push: before..HEAD new branch: HEAD~1..HEAD (fallback for zero before-SHA) - Historical secrets from before the range are naturally ignored because they're outside it — no committed-in-repo list needed. If a secret is actually leaked in a future commit, gitleaks will catch it. Historical leaks are audited once (internally, off-repo) and the relevant keys rotated; keeping an on-repo map of them was protecting nothing and advertising everything. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6e4dc13 commit 8026496

4 files changed

Lines changed: 27 additions & 1156 deletions

File tree

.github/workflows/secret-scan.yml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ name: Secret Scanning
77
# Uses the project-level .gitleaks.toml for RunAnywhere-specific patterns.
88
#
99
# Strategy:
10-
# - Pull requests: scan ONLY the PR's commits (not full history). Catches
11-
# new secrets without tripping on the 49 known historical findings.
12-
# - Push to main: scan the pushed commits with a baseline file so known
13-
# findings are skipped and only genuinely new leaks fail CI.
10+
# - Pull requests: scan ONLY the PR's commits (base.sha..HEAD). Catches
11+
# new secrets without tripping on historical findings.
12+
# - Push to main: scan only the pushed commits (before..HEAD). Redundant
13+
# with PR scan but catches direct pushes / merge commits.
14+
#
15+
# No baseline file is used. A baseline would leak metadata about known
16+
# secrets (file paths, commit SHAs, authors) into the committed repo —
17+
# pointing attackers at exactly where and when each secret was introduced.
18+
# Incremental diff-only scans achieve the same "ignore historical noise"
19+
# goal without that disclosure.
1420
#
1521
# Uses gitleaks CLI directly (MIT-licensed, free) instead of
1622
# gitleaks-action@v2 which requires a paid license for organizations.
@@ -42,33 +48,31 @@ jobs:
4248
sudo mv gitleaks /usr/local/bin/
4349
gitleaks version
4450
45-
- name: Run Gitleaks
51+
- name: Run Gitleaks (incremental)
4652
env:
4753
EVENT_NAME: ${{ github.event_name }}
54+
PR_BASE: ${{ github.event.pull_request.base.sha }}
55+
PUSH_BEFORE: ${{ github.event.before }}
4856
run: |
57+
set -euo pipefail
58+
4959
CONFIG_ARG=""
5060
[ -f .gitleaks.toml ] && CONFIG_ARG="--config .gitleaks.toml"
5161
62+
# Pick a commit range based on the trigger event.
5263
if [ "$EVENT_NAME" = "pull_request" ]; then
53-
# PR mode: only scan the commits in this PR, not full history.
54-
# This naturally ignores all historical secrets without needing
55-
# a baseline file (which can drift between local and CI clones).
56-
echo "PR mode: scanning only PR commits"
57-
gitleaks detect --source . $CONFIG_ARG --redact --verbose \
58-
--log-opts="${{ github.event.pull_request.base.sha }}..HEAD"
64+
RANGE="${PR_BASE}..HEAD"
65+
echo "PR mode — scanning range: $RANGE"
5966
else
60-
# Push-to-main mode: scan the pushed commits. Fall back to
61-
# baseline-based full scan if the before SHA is unavailable.
62-
echo "Push mode: scanning pushed commits"
63-
BEFORE="${{ github.event.before }}"
64-
if [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ]; then
65-
gitleaks detect --source . $CONFIG_ARG --redact --verbose \
66-
--log-opts="${BEFORE}..HEAD"
67-
elif [ -f .gitleaksbaseline ]; then
68-
gitleaks detect --source . $CONFIG_ARG --redact --verbose \
69-
--baseline-path .gitleaksbaseline
67+
# push to main. If PUSH_BEFORE is missing or zero (new branch,
68+
# never-seen-before), fall back to just the top commit.
69+
if [ -n "${PUSH_BEFORE:-}" ] && [ "$PUSH_BEFORE" != "0000000000000000000000000000000000000000" ]; then
70+
RANGE="${PUSH_BEFORE}..HEAD"
7071
else
71-
echo "::warning::No baseline and no before-SHA; running full scan"
72-
gitleaks detect --source . $CONFIG_ARG --redact --verbose
72+
RANGE="HEAD~1..HEAD"
7373
fi
74+
echo "Push mode — scanning range: $RANGE"
7475
fi
76+
77+
gitleaks detect --source . $CONFIG_ARG --redact --verbose \
78+
--log-opts="$RANGE"

0 commit comments

Comments
 (0)