-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (62 loc) · 2.39 KB
/
Copy pathgitleaks.yml
File metadata and controls
68 lines (62 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Gitleaks
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: gitleaks-${{ github.ref }}
cancel-in-progress: true
jobs:
scan:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
# Full history for `gitleaks detect --log-opts="--all"` on push to main.
# PR runs only need the diff range (resolved below).
fetch-depth: 0
- name: Install gitleaks (pinned + checksum-verified)
# GITLEAKS_SHA256 is the SHA-256 of gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz
# from the upstream gitleaks_${GITLEAKS_VERSION}_checksums.txt file. Without
# this, a poisoned GitHub release would silently install a backdoored gitleaks
# on every CI run. When bumping GITLEAKS_VERSION, fetch the upstream checksum
# in the same commit; reviewers should re-fetch and confirm.
env:
GITLEAKS_VERSION: '8.30.1'
GITLEAKS_SHA256: '551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb'
run: |
set -euo pipefail
TARBALL=/tmp/gitleaks.tar.gz
curl -sSL -o "$TARBALL" \
"https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
echo "${GITLEAKS_SHA256} ${TARBALL}" | sha256sum -c -
tar -xz -C /tmp -f "$TARBALL" gitleaks
sudo install -m 0755 /tmp/gitleaks /usr/local/bin/gitleaks
gitleaks version
- name: Detect secrets
# --redact masks any matched secret in CI logs.
# PR: scan only the diff range to keep PR cycles fast.
# push to main: scan full history to catch any rewrites.
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
gitleaks detect \
--source=. \
--no-banner \
--redact \
--log-opts="origin/${{ github.base_ref }}..HEAD" \
--report-format json \
--report-path /tmp/leaks.json \
-v
else
gitleaks detect \
--source=. \
--no-banner \
--redact \
--log-opts="--all" \
--report-format json \
--report-path /tmp/leaks.json \
-v
fi