File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -212,3 +212,32 @@ jobs:
212
212
shared-key : windows-rust-testing
213
213
- name : ' cargo check'
214
214
run : cargo check --workspace --all-targets --features windows
215
+
216
+ # Check that all `actions/checkout` in CI jobs have `persist-credentials: false`.
217
+ check-no-persist-credentials :
218
+ runs-on : ubuntu-latest
219
+
220
+ env :
221
+ GLOB : .github/workflows/*.@(yaml|yml)
222
+
223
+ steps :
224
+ - uses : actions/checkout@v5
225
+ with :
226
+ persist-credentials : false
227
+ sparse-checkout : ' .github/workflows'
228
+ - name : Generate workflows list to scan
229
+ run : |
230
+ shopt -s extglob
231
+ printf '%s\n' ${{ env.GLOB }} | grep -v .github/workflows/publish.yaml >workflows.list
232
+ cat workflows.list
233
+ echo "Note that publish.yaml is excluded until it's ensured to not need this feature"
234
+ - name : Scan workflows
235
+ run : |
236
+ shopt -s extglob
237
+ yq '.jobs.*.steps[]
238
+ | select(.uses == "actions/checkout@*" and .with.["persist-credentials"]? != false)
239
+ | {"file": filename, "line": line, "name": (.name // .uses)}
240
+ | .file + ":" + (.line | tostring) + ": " + .name
241
+ ' -- $(cat workflows.list) >query-output.txt
242
+ cat query-output.txt
243
+ test -z "$(<query-output.txt)" # Report failure if we found anything.
You can’t perform that action at this time.
0 commit comments