Skip to content

Commit 4fde98f

Browse files
Merge pull request #21459 from cevich/simpler_to_read
[skip-ci] Make leak-detection readable by humans
2 parents f7afaf9 + 28856b6 commit 4fde98f

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

.github/workflows/scan-secrets.yml

+29-5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,28 @@ jobs:
7373
run: |
7474
echo "depth=$((${{ github.event.pull_request.commits }} + 1))" >> $GITHUB_OUTPUT
7575
76+
# A force-push to a PR can obscure Cirrus-CI logs, but not GHA logs.
77+
# Provide handy URL for examination of secret leaks for all events that
78+
# trigger this action.
79+
80+
- if: github.event_name == 'synchronize' || github.base_ref == ''
81+
name: Provide URL showing code that needs human eyes (force-push or merge)
82+
shell: bash
83+
run: |
84+
echo "Please review force-push or merged-pr changes for secret-leaks:"
85+
before=$(jq -r -e '.before' $GITHUB_EVENT_PATH)
86+
after=$(jq -r -e '.after' $GITHUB_EVENT_PATH)
87+
echo "https://github.com/${{ github.repository }}/compare/${before}...${after}"
88+
89+
- if: github.event_name == 'opened'
90+
name: Provide URL showing code that needs human eyes (newly opened PR)
91+
shell: bash
92+
run: |
93+
echo "Please review new PR changes for secret-leaks:"
94+
before=$(jq -r -e '.github.event.pull_request.base.sha' $GITHUB_EVENT_PATH)
95+
after=$(jq -r -e '.github.event.pull_request.head.sha' $GITHUB_EVENT_PATH)
96+
echo "https://github.com/${{ github.repository }}/compare/${before}...${after}"
97+
7698
- name: Show important context details
7799
shell: bash
78100
run: |
@@ -123,12 +145,11 @@ jobs:
123145
mkdir ${{ github.workspace }}/_report
124146
touch ${{ github.workspace }}/_report/gitleaks-report.json
125147
126-
# A force-push to a PR can obscure Cirrus-CI logs, but not GHA logs
127-
- name: Show content being scanned
148+
- name: Log all content being scanned to file for archiving
128149
shell: bash
129150
run: |
130151
set -exuo pipefail
131-
${{ env.gitlogcmd }} ${{ steps.gitlog.outputs.range }}
152+
${{ env.gitlogcmd }} ${{ steps.gitlog.outputs.range }} >> ${{ github.workspace }}/git_commits.log
132153
133154
# Unfortunately gitleaks provides several in-built ways to
134155
# completely bypass an alert within PR-level commits. Assume
@@ -183,12 +204,15 @@ jobs:
183204
$glfqin \
184205
detect $glargs --log-opts=${{ steps.gitlog.outputs.range }}
185206
186-
- name: Collect scan report artifact
207+
- name: Collect git commits log and gitleaks scan report
187208
if: ${{ !cancelled() }}
188209
uses: actions/upload-artifact@v4
189210
with:
190211
name: gitleaks-report
191-
path: ${{ github.workspace }}/_report/gitleaks-report.json
212+
path: |
213+
${{ github.event_path }}
214+
${{ github.workspace }}/git_commits.log
215+
${{ github.workspace }}/_report/gitleaks-report.json
192216
193217
# Nobody monitors the actions-tab for failures, and may not see this
194218
# fail on push to a nefarious PR. Send an e-mail alert to unmask

0 commit comments

Comments
 (0)