Repository navigation
166 lines (153 loc) · 8.1 KB
/
Copy pathcodeql.yml
File metadata and controls
166 lines (153 loc) · 8.1 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: CodeQL
# commitwork's own CodeQL scan, gated on every push. A sweep can self-scan too, but only when a
# human starts it, and its output lands in a gitignored tree where nothing gates a push on it and
# nobody outside that machine sees the result. A scanner that exempts itself from its own
# enforcement is a defect.
#
# THE EXCLUSIONS BELOW MUST TRACK manifests/codeql-filters.txt, AND THE SYNTAX IS NOT THE SAME.
# That file is the RAW extractor format (LGTM_INDEX_FILTERS), read by all ten sast-codeql-* lanes
# in security-baseline.json. `paths-ignore` here is a DIFFERENT layer that the CodeQL action
# converts into that one. A trailing `/**` is legal here and ILLEGAL there — `exclude:reports/**`
# fails the build outright with "Illegal use of '**' in exclude path". So these are not a copy of
# those lines and must not be made into one; they are the same four decisions expressed in the
# format this layer takes. If you change one side, change the other and say why in the manifest,
# where the evidence for each exclusion is recorded.
#
# WHY THESE FOUR. Unfiltered, a self-scan reports commitwork's own generated output as well as its
# source, and the output is self-amplifying: each sweep writes report HTML that the next sweep
# indexes, so the headline grows with the number of areas scanned rather than with risk. Excluding
# generated trees keeps the count a measure of the source.
#
# The over-exclusion risk is real and is stated rather than hidden: an exclude that removes genuine
# source is a false clean, the worst failure this platform has. Each path below is a directory this
# repository generates, not a category guessed at.
on:
workflow_dispatch:
push:
# Skip prose-only pushes: most pushes go to main, and a docs edit should not cost a full CodeQL
# analysis. Test fixtures are markdown too, so they are re-included last (later patterns win).
paths:
- '**'
- '!**/*.md'
- '!docs/**'
- '**/test/fixtures/**'
pull_request:
# Skip prose-only pull requests: a docs edit should not cost a full CodeQL analysis. Test
# fixtures are markdown too, so they are re-included last (later patterns win).
paths:
- '**'
- '!**/*.md'
- '!docs/**'
- '**/test/fixtures/**'
schedule:
# Weekly, so a newly published query finds old code. Push-triggered analysis only ever asks
# about code somebody touched; the CVE that matters is usually in code nobody has touched for
# months. Monday 04:17 UTC — an odd minute deliberately, because on-the-hour schedules queue
# behind everyone else's on-the-hour schedules.
- cron: '17 4 * * 1'
# Keyed by event as well as ref, so the weekly scheduled scan is never cancelled by a push to main.
concurrency:
group: codeql-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
analyze:
name: Analyze JavaScript
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
# security-events: write is what lets the result reach the Security tab. Without it the job
# runs, passes, and uploads nothing — green, and measuring nothing anybody can read. That is
# the false-clean shape, so it is granted here at the job rather than inherited.
security-events: write
contents: read
actions: read
steps:
# Actions pinned to commit SHAs, not tags: a tag can be silently repointed by the action owner
# (the trivy-action / tj-actions compromise class). The trailing comment names the release each
# SHA was resolved from via `git ls-remote --tags`, and bin/pin-actions.mjs verifies every one
# of these lines against the upstream tag on demand.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Initialise CodeQL
uses: github/codeql-action/init@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
languages: javascript-typescript
# security-and-quality, not the default security-extended. The quality queries are the
# half that catches the unreachable branch and the always-true condition, which in a
# codebase whose failures are overwhelmingly "a check that could not fire" is the more
# relevant family. A noisier suite is affordable here because the findings land in the
# Security tab for triage rather than gating the push.
queries: security-and-quality
config: |
paths-ignore:
# commitwork's own generated report tree — gitignored, regenerated every sweep, and
# the direct source of the 638 above.
- 'reports/**'
# The modernization map's generated output. The engine SOURCE under map/*.mjs stays
# indexed; only the generated tree goes.
- 'map/data/**'
# Vendored third-party assets carried for offline/file:// rendering. Named explicitly
# rather than '**/vendor' so the rule cannot swallow a directory called `vendor` that
# holds real source. NOTE the tracked coverage hole this leaves, recorded in
# manifests/codeql-filters.txt: a manifest-less vendored bundle is covered by no
# dependency lane either, because all four are gated on a package manifest.
- 'sitemap/vendor/**'
# Evaluation corpora and cycle artifacts: JSON/markdown evidence, never executed.
# Absent from a clone in any case — evaluations/ is a symlink to a private sidecar.
- 'evaluations/**'
# No autobuild step, and its absence is a decision rather than an omission. commitwork has no
# compile step — zero runtime dependencies is the point — so for javascript-typescript the
# extractor reads the source directly. An autobuild here would succeed at doing nothing and
# leave a step in the log implying a build happened.
- name: Analyze
uses: github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
category: /language:javascript-typescript
# fact: code scanning on a private repository needs GitHub Advanced Security; without it the
# upload fails the job after a complete analysis. Public: upload. Private: keep the SARIF.
upload: ${{ github.event.repository.private && 'never' || 'always' }}
output: codeql-results
- name: Keep the SARIF when it was not uploaded
if: ${{ github.event.repository.private }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: codeql-sarif
path: codeql-results
retention-days: 30
# The workflows are code too, and the javascript-typescript extractor never reads them: an
# injection in a `run:` step is invisible to the job above. A separate job rather than a matrix,
# so the job name branch protection may already hold for JavaScript does not change.
analyze-actions:
name: Analyze GitHub Actions
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
security-events: write
contents: read
actions: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Initialise CodeQL
uses: github/codeql-action/init@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
languages: actions
build-mode: none
queries: security-and-quality
- name: Analyze
uses: github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
category: /language:actions
upload: ${{ github.event.repository.private && 'never' || 'always' }}
output: codeql-actions-results
- name: Keep the SARIF when it was not uploaded
if: ${{ github.event.repository.private }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: codeql-actions-sarif
path: codeql-actions-results
retention-days: 30