-
Notifications
You must be signed in to change notification settings - Fork 0
/
secrets_leaks.sh
30 lines (18 loc) · 1.28 KB
/
secrets_leaks.sh
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
#!/usr/bin/env bash
REVIEWDOG_GIT_TOKEN=$1
set -e
export REVIEWDOG_GITHUB_API_TOKEN="${REVIEWDOG_GIT_TOKEN}"
echo "TIZONA - Secrets leaks analysis: Secrets leaks discovery"
FILE_REPORT=report-secrets.json
git config --global --add safe.directory /github/workspace
echo "TIZONA - Secrets leaks analysis: Running gitleaks"
gitleaks detect --no-git -f sarif --exit-code 0 -r $FILE_REPORT
set +Eeuo pipefail
echo "TIZONA - Secrets leaks analysis: Formatting findings"
jq '.runs[0].results[] | "\(.locations[0].physicalLocation.artifactLocation.uri):\(.locations[0].physicalLocation.region.endLine):\(.locations[0].physicalLocation.region.startColumn): \(.message.text)"' < $FILE_REPORT | sed 's/"//g'
echo "TIZONA - Secrets leaks analysis: Runnning reviewdog"
jq '.runs[0].results[] | "\(.locations[0].physicalLocation.artifactLocation.uri):\(.locations[0].physicalLocation.region.endLine):\(.locations[0].physicalLocation.region.startColumn): \(.message.text)"' < $FILE_REPORT | sed 's/"//g' | reviewdog -efm="%f:%l:%c: %m" -reporter=github-pr-check -fail-on-error=true
reviewdog_return="${PIPESTATUS[2]}" exit_code=$?
echo "TIZONA - Secrets leaks analysis: set-output name=reviewdog-return-code: ${reviewdog_return}"
echo "TIZONA - Secrets leaks analysis: Gitleaks exit ${exit_code}"
exit ${exit_code}