Repository navigation
99 lines (91 loc) · 4.37 KB
/
Copy pathcodeql.yml
File metadata and controls
99 lines (91 loc) · 4.37 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
# codeql.yml — CodeQL advanced setup.
#
# Why this file exists (replacing GitHub's "default setup"): default setup does
# NOT analyze pull requests from forks
# (https://docs.github.com/en/code-security/concepts/code-scanning/setup-types),
# but `CodeQL` is a required status check on main. So every external-contributor
# (fork) PR was permanently blocked — its head commit never got a CodeQL run.
# Advanced setup runs on a plain `pull_request` event, which DOES fire for public
# fork PRs, and its code-scanning upload works even under the read-only token a
# fork PR gets — GitHub's upload endpoint carves out PR uploads from forks (the
# same reason security-scan.yml's Trivy upload-sarif already succeeds on fork
# PRs). The required check is named `CodeQL` and comes from the code-scanning
# app, not these Actions jobs, so branch protection stays unchanged after the
# migration.
#
# Migration note: while default setup is still enabled, the `analyze` step here
# is rejected ("Upload with CodeQL results rejected due to 'default setup'"), so
# this workflow's own jobs go red on the introducing PR — expected, and harmless
# because they are not required checks and default setup still supplies the
# required `CodeQL` for a same-repo PR. Disable default setup (Settings →
# Advanced Security → Code scanning → CodeQL analysis → Switch to advanced →
# Disable CodeQL) and this workflow takes over.
name: CodeQL
on:
# No path filters, and no job-level `if:` that can skip: default setup ran on
# every PR, and a filtered advanced workflow would produce no `CodeQL` check on
# (say) a docs-only PR, leaving that PR permanently blocked on a missing
# required check.
pull_request:
push:
branches: [main]
# push + schedule are load-bearing, not optional: a PR's results are diffed
# against the base branch's most recent analysis, which these keep fresh.
schedule:
- cron: "27 6 * * 1"
permissions:
contents: read
concurrency:
group: codeql-${{ github.ref }}
# Supersede an in-flight PR analysis on a new push; never cancel a push/
# schedule analysis of main (that is the baseline PRs diff against).
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
security-events: write # upload code-scanning results
actions: read
contents: read
strategy:
fail-fast: false
matrix:
# Same languages default setup analyzed (JS + TS are one CodeQL
# language). The interpreted/config languages support build-mode: none
# (no build, fully fork-safe). Go is compiled and CodeQL rejects `none`
# for it ("Go does not support the none build mode"), so it uses
# autobuild — `go build`, which does not execute the analysed code and
# runs in the isolated fork-PR runner.
include:
- { language: actions, build-mode: none }
- { language: go, build-mode: autobuild }
- { language: javascript-typescript, build-mode: none }
- { language: python, build-mode: none }
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
# Go's autobuild runs `go build`, which needs the go.mod toolchain; the
# other languages build nothing. Same pinned setup-go SHA as release.yml.
- name: Set up Go
if: matrix.language == 'go'
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
# Same pinned action SHA as security-scan.yml's upload-sarif, so Renovate/
# Dependabot bump init/analyze/upload in lockstep (scripts/repocheck
# enforces SHA pinning).
- name: Initialize CodeQL
uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# Parity with the default setup this replaces, which ran the
# "extended" query suite — without this the migration silently
# narrows coverage.
queries: security-extended
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
with:
category: "/language:${{ matrix.language }}"