Repository navigation
104 lines (92 loc) · 4.33 KB
/
Copy pathcodeql.yml
File metadata and controls
104 lines (92 loc) · 4.33 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
name: CodeQL
on:
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]
schedule:
- cron: "0 16 * * 0"
workflow_dispatch:
permissions: {}
concurrency:
group: codeql-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
analyse:
name: Analyse Java
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-26.04
timeout-minutes: 45
# Everything is denied by the empty top-level permissions above, so this states what
# the analysis needs: writing the results it uploads, and reading what it analyses.
permissions:
security-events: write
contents: read
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up JDK 17
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
java-version: "17.0.21+100000002"
distribution: "temurin"
cache: "maven"
# security-extended on top of the default suite, because Ares is itself the security
# boundary and the default suite is tuned to keep a general project quiet rather than
# to hold this one to its own claim. The wider suite trades precision for reach, so a
# finding here is a question to answer rather than a defect by itself.
- name: Initialise CodeQL
uses: github/codeql-action/init@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
with:
languages: java
build-mode: manual
queries: security-extended
# This job builds only so that CodeQL can watch it. The quality gate bound to
# package belongs to the static analysis job in maven.yml, so it is turned off here.
- name: Build
run: mvn -B -DskipTests package -Pwithout-quality-gates
# In manual build mode CodeQL sees only what the traced build compiles, and it says
# nothing about what it never saw. Maven compiles src/main and src/test of the root
# pom and nothing else, which left the one file that reads attacker-controlled input
# unanalysed: the pull request body reaches this checker verbatim from a fork. javac
# runs inside the traced window, so compiling it here is all that is needed. The
# class files are scratch and no later step reads them.
- name: Compile the pull request template checker so CodeQL sees it
run: javac -d "${RUNNER_TEMP}/pr-template-checker" .github/scripts/CheckPullRequestTemplate.java
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5
# A separate job rather than a matrix entry beside Java, so that the Java analysis keeps
# the category it has always had. CodeQL closes an alert when the analysis that raised it
# reports it gone, and it matches analyses by category, so renaming one strands its open
# alerts. The workflows need no build, hence build-mode none and no JDK here.
#
# It also runs for a pull request from a fork, where the job above does not. build-mode
# none reads the workflow files and runs nothing out of them, and a fork changing a
# workflow is the case this analysis is most worth having. Code scanning accepts the
# upload even though the token of a fork pull request is read-only.
analyse-actions:
name: Analyse Actions
runs-on: ubuntu-26.04
timeout-minutes: 15
# As in the job above: the analysis writes the results it uploads and reads what it
# analyses, and the empty top-level permissions deny everything else.
permissions:
security-events: write
contents: read
actions: read
steps:
- name: Checkout repository
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-extended
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5