11name : " CodeQL"
22
3+ # Supply-chain hardening (TASK-090): every action below is pinned to a full
4+ # 40-hex commit SHA, mirroring the convention in verify-build.yml. The trailing
5+ # `# vX.Y.Z` comment records the upstream release tag each SHA corresponds to,
6+ # for rotation.
7+ #
8+ # Pinned actions and how to rotate them (read-only `gh` API; dereference the
9+ # annotated tag to its commit SHA):
10+ # actions/checkout v4.2.2 -> 11bd71901bbe5b1630ceea73d27597364c9af683
11+ # (kept identical to verify-build.yml so both workflows rotate together)
12+ # gh api repos/actions/checkout/git/refs/tags/v4.2.2 --jq .object.sha
13+ # github/codeql-action/* v3.36.3 -> 411c4c9a36b3fca4d674f06b6396b2c6d23522c6
14+ # init AND analyze ship from one repo/release and MUST share one SHA.
15+ # SHA=$(gh api repos/github/codeql-action/git/refs/tags/v3.36.3 --jq .object.sha)
16+ # gh api repos/github/codeql-action/git/tags/$SHA --jq .object.sha # deref annotated tag
17+ # (@v1/@v2 of codeql-action are deprecated; v3 is the current major.)
18+
319on :
420 push :
521 branches : [master]
925 schedule :
1026 - cron : ' 0 4 * * 4'
1127
28+ # Least-privilege GITHUB_TOKEN: restrict to exactly what the CodeQL scan
29+ # needs. `security-events: write` is required by github/codeql-action/analyze
30+ # to upload the SARIF report to the security dashboard. `contents: read` is
31+ # required by actions/checkout. `actions: read` is required on some GitHub
32+ # plans/repository configurations to read the workflow run. Without an
33+ # explicit block the token defaults to the repository's global setting.
34+ permissions :
35+ actions : read
36+ contents : read
37+ security-events : write
38+
1239jobs :
1340 analyze :
1441 name : Analyze
2552
2653 steps :
2754 - name : Checkout repository
28- uses : actions/checkout@v2
55+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2956 with :
3057 # We must fetch at least the immediate parents so that if this is
3158 # a pull request then we can checkout the head.
@@ -36,38 +63,55 @@ jobs:
3663 - run : git checkout HEAD^2
3764 if : ${{ github.event_name == 'pull_request' }}
3865
39- - name : Install libmicrohttpd dependency
66+ - name : Fetch libmicrohttpd from cache
67+ id : cache-libmicrohttpd
68+ uses : actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
69+ with :
70+ path : libmicrohttpd-1.0.3
71+ key : ${{ runner.os }}-libmicrohttpd-1.0.3-codeql
72+
73+ - name : Build libmicrohttpd dependency (if not cached)
74+ # Supply-chain: libmicrohttpd-1.0.3.tar.gz is sha256-pinned. The digest
75+ # must match the value used in verify-build.yml; both workflows track the
76+ # same release. To rotate the libmicrohttpd version, update both the URL
77+ # and the digest in the same PR (keep this file and verify-build.yml in
78+ # sync). Obtain the new digest by downloading the tarball and running:
79+ # sha256sum libmicrohttpd-<version>.tar.gz
80+ # Cross-check against the libmicrohttpd project's official release page.
81+ # rotate: sha256 7816b57aae199cf5c3645e8770e1be5f0a4dfafbcb24b3772173dc4ee634126a
4082 run : |
41- curl https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-1.0.3.tar.gz -o libmicrohttpd-1.0.3.tar.gz ;
83+ curl -fsSL https://s3.amazonaws.com/libhttpserver/libmicrohttpd_releases/libmicrohttpd-1.0.3.tar.gz -o libmicrohttpd-1.0.3.tar.gz ;
84+ echo "7816b57aae199cf5c3645e8770e1be5f0a4dfafbcb24b3772173dc4ee634126a libmicrohttpd-1.0.3.tar.gz" | sha256sum -c ;
4285 tar -xzf libmicrohttpd-1.0.3.tar.gz ;
4386 cd libmicrohttpd-1.0.3 ;
4487 ./configure --disable-examples ;
4588 make ;
46- sudo make install ;
89+ timeout-minutes : 30
90+ if : steps.cache-libmicrohttpd.outputs.cache-hit != 'true'
91+
92+ - name : Install libmicrohttpd dependency
93+ run : cd libmicrohttpd-1.0.3 ; sudo make install ;
94+ timeout-minutes : 30
4795
4896 # Initializes the CodeQL tools for scanning.
4997 - name : Initialize CodeQL
50- uses : github/codeql-action/init@v1
98+ uses : github/codeql-action/init@411c4c9a36b3fca4d674f06b6396b2c6d23522c6 # v3.36.3
5199 with :
52100 languages : ${{ matrix.language }}
53101
54- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55- # If this step fails, then you should remove it and run the build manually (see below)
56- # - name: Autobuild
57- # uses: github/codeql-action/autobuild@v1
58-
59- # ℹ️ Command-line programs to run using the OS shell.
60- # 📚 https://git.io/JvXDl
61-
62- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63- # and modify them (or add more) to build your code if your project
64- # uses a compiled language
65-
66- - name : Manual steps to build the library
102+ # CodeQL's C/C++ database extractor traces the actual compile commands, so
103+ # the library is built explicitly here rather than via the CodeQL Autobuild
104+ # action (autobuild guesses the build and is intentionally not used). The
105+ # build must be a clean from-scratch `make` so every TU is extracted; the
106+ # in-source build (--enable-same-directory-build) keeps object files where
107+ # the extractor expects them.
108+ - name : Build the library (CodeQL manual mode)
67109 run : |
68110 ./bootstrap ;
69- ./configure --enable-same-directory-build;
111+ ./configure --enable-same-directory-build ;
70112 make ;
113+ timeout-minutes : 30
71114
72115 - name : Perform CodeQL Analysis
73- uses : github/codeql-action/analyze@v1
116+ uses : github/codeql-action/analyze@411c4c9a36b3fca4d674f06b6396b2c6d23522c6 # v3.36.3
117+ timeout-minutes : 30
0 commit comments