Skip to content

Commit 3a5c452

Browse files
authored
Merge pull request #104 from devakone/codex/fix-security-workflow
fix(ci): stabilize security workflow
2 parents 2799da3 + 8b6554c commit 3a5c452

1 file changed

Lines changed: 51 additions & 4 deletions

File tree

.github/workflows/security.yml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,54 @@ jobs:
4444
if: github.event_name == 'push'
4545
run: npm audit --audit-level=critical
4646

47-
- name: Trufflehog git history scan
48-
uses: trufflesecurity/trufflehog@main
49-
with:
50-
extra_args: --only-verified
47+
- name: Install TruffleHog
48+
env:
49+
TRUFFLEHOG_VERSION: v3.95.3
50+
TRUFFLEHOG_ARCHIVE: trufflehog_3.95.3_linux_amd64.tar.gz
51+
run: |
52+
set -euo pipefail
53+
curl -fsSL --retry 3 --retry-delay 2 \
54+
-o "/tmp/${TRUFFLEHOG_ARCHIVE}" \
55+
"https://github.com/trufflesecurity/trufflehog/releases/download/${TRUFFLEHOG_VERSION}/${TRUFFLEHOG_ARCHIVE}"
56+
curl -fsSL --retry 3 --retry-delay 2 \
57+
-o /tmp/trufflehog_checksums.txt \
58+
"https://github.com/trufflesecurity/trufflehog/releases/download/${TRUFFLEHOG_VERSION}/trufflehog_${TRUFFLEHOG_VERSION#v}_checksums.txt"
59+
cd /tmp
60+
grep " ${TRUFFLEHOG_ARCHIVE}\$" trufflehog_checksums.txt | sha256sum --check -
61+
tar -xzf "${TRUFFLEHOG_ARCHIVE}" trufflehog
62+
sudo install /tmp/trufflehog /usr/local/bin/trufflehog
63+
trufflehog --version
64+
65+
- name: TruffleHog git history scan
66+
env:
67+
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
68+
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
69+
PUSH_BEFORE_SHA: ${{ github.event.before }}
70+
PUSH_AFTER_SHA: ${{ github.event.after }}
71+
run: |
72+
set -euo pipefail
73+
74+
BASE=""
75+
HEAD=""
76+
77+
if [ "${{ github.event_name }}" = "pull_request" ]; then
78+
BASE="$PR_BASE_SHA"
79+
HEAD="$PR_HEAD_SHA"
80+
elif [ "${{ github.event_name }}" = "push" ]; then
81+
HEAD="$PUSH_AFTER_SHA"
82+
if [ "$PUSH_BEFORE_SHA" != "0000000000000000000000000000000000000000" ]; then
83+
BASE="$PUSH_BEFORE_SHA"
84+
fi
85+
fi
86+
87+
args=(git "file://${GITHUB_WORKSPACE}" --fail --no-update --github-actions --only-verified)
88+
89+
if [ -n "$BASE" ]; then
90+
args+=(--since-commit "$BASE")
91+
fi
92+
93+
if [ -n "$HEAD" ]; then
94+
args+=(--branch "$HEAD")
95+
fi
96+
97+
trufflehog "${args[@]}"

0 commit comments

Comments
 (0)