-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (114 loc) · 4.7 KB
/
Copy pathcodeql.yml
File metadata and controls
127 lines (114 loc) · 4.7 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
name: CodeQL
env:
# Read by the GitHub Packages repository credentials in
# settings.gradle.kts; the Kotlin analysis has to resolve those clients to
# build. GITHUB_ACTOR comes from the runner, GITHUB_TOKEN does not.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Advanced CodeQL setup. To take effect, GitHub's managed "default setup"
# must be turned off:
# Settings -> Code security -> CodeQL analysis -> Tool: CodeQL ->
# switch from "Default" to "Advanced".
# While default setup is enabled, the analyze step fails with
# "Code Scanning could not process the submitted SARIF: default setup
# is enabled". The two cannot run side by side.
#
# Triggers mirror the other pull-request checks: `pull_request` so code
# scanning can attribute alerts to the pull request that introduced them,
# `push` on main so a base analysis always exists to diff against, and the
# weekly schedule. Scanning every push on every branch instead meant a
# branch push had no pull request to hang results off, and each push
# cancelled the previous run's traced Kotlin build mid-flight.
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Weekly re-scan so newly published queries flag latent issues even
# when no code changed. Monday 06:17 UTC — off the top of the hour to
# avoid the cron stampede.
- cron: '17 6 * * 1'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# actions + javascript-typescript extract straight from source
# (build-mode none): fast, no toolchain, safe to run on every PR.
analyze-buildless:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
security-events: write
packages: read
actions: read
contents: read
strategy:
fail-fast: false
matrix:
language: [actions, javascript-typescript]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Initialize CodeQL
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
with:
languages: ${{ matrix.language }}
build-mode: none
config-file: ./.github/codeql/codeql-config.yml
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
with:
category: '/language:${{ matrix.language }}'
# The backend is Kotlin-only, and CodeQL's standalone extractor cannot
# see Kotlin without a traced build (build-mode none yields "no source
# code seen"). Tracing the Gradle + kapt compile is slow, so it lands
# several minutes after the two buildless analyses — default setup never
# scanned Kotlin at all, so this is a strict improvement over the
# baseline.
analyze-kotlin:
name: Analyze (java-kotlin)
runs-on: ubuntu-latest
timeout-minutes: 90
permissions:
security-events: write
packages: read
actions: read
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Initialize CodeQL
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
with:
languages: java-kotlin
build-mode: manual
config-file: ./.github/codeql/codeql-config.yml
- name: Set up Java + Gradle
uses: ./.github/actions/setup-java-gradle
with:
java-version: '25'
# compileKotlin on the api drags in the shared lib and the generated
# clients it depends on, which is the whole main source tree CodeQL
# needs to trace. Tests are out of scope for these queries.
#
# --rerun-tasks (not --build-cache): CodeQL build-mode manual only sees
# source it actually compiles. With the build cache, a run that doesn't
# touch api/kotlin-common serves compileKotlin from cache — nothing is
# compiled, so CodeQL traces nothing and fails with "didn't build any of
# it". Forcing the compile tasks to rerun guarantees a traced build.
- name: Build Kotlin sources for analysis
env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g"
run: |
./gradlew --no-daemon --rerun-tasks \
-Pkotlin.daemon.jvmargs=-Xmx3g \
:services:api:compileKotlin \
:libs:kotlin-common:compileKotlin
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4
with:
category: '/language:java-kotlin'