Repository navigation
87 lines (79 loc) · 3.66 KB
/
Copy pathcodeql.yml
File metadata and controls
87 lines (79 loc) · 3.66 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: CodeQL
# CodeQL advanced setup: the Python analysis is configured in this file.
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
# Weekly on Sundays at 06:00 UTC, clear of the other workflows'
# cron slots.
- cron: "0 6 * * 0"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze (python)
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# build-mode: none extracts the database straight from source,
# with no build step.
- uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
with:
languages: python
build-mode: none
# analyze writes the SARIF without uploading it, the filter step
# drops one query's results on two paths, and upload-sarif uploads
# what is left. py/weak-sensitive-data-hashing flags the MD5 that
# RADIUS and STUN mandate, which their tests and
# scripts/check_fixtures.py compute over published test secrets
# with usedforsecurity=False to verify captured traffic. The
# filter removes only that query's results whose primary location
# is under tests/ or scripts/; the query still runs on src/, every
# other query on all three.
#
# upload: failure-only is the action's documented mode for a
# workflow that post-processes the SARIF: analyze uploads nothing
# when it succeeds. It still marks the analysis as completed, so
# init's post step does not upload a failed-run SARIF for a later
# step's failure either: if the filter or upload-sarif fails, the
# job goes red and no new analysis replaces the previous one
# (upload-sarif can fail after uploading, while it waits for
# processing). That fails closed; unfiltered SARIF is never
# uploaded. (Any value the action does not recognize means
# `always`, which would upload before the filter runs.)
#
# Neither analyze nor upload-sarif sets `category`, and that is
# what keeps the analysis the same one: with no category the CLI
# writes no runs[].automationDetails, and both actions then fill
# it in from the workflow path, job id and matrix,
# ".github/workflows/codeql.yml:analyze/", the same in both
# steps of this job. Existing alerts keep tracking (fixed ones
# close, the rest stay) rather than reappearing under a new
# category. Setting one on either step alone would start a second
# analysis next to the first.
- id: analyze
uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
with:
upload: failure-only
# Rewrites each *.sarif under analyze's output directory, at any
# depth and skipping symlinks (as upload-sarif finds them), in
# place and logs one line per file, by its path under the
# directory, naming every result it dropped; malformed SARIF fails
# the job instead of uploading unfiltered results.
# Stdlib only, so the runner's own python3 runs it.
- name: Drop weak-hashing results on tests/ and scripts/
env:
SARIF_DIR: ${{ steps.analyze.outputs.sarif-output }}
run: python3 scripts/filter_codeql_sarif.py "$SARIF_DIR"
- uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
with:
sarif_file: ${{ steps.analyze.outputs.sarif-output }}