Repository navigation
157 lines (143 loc) · 5.65 KB
/
Copy pathcodeql.yml
File metadata and controls
157 lines (143 loc) · 5.65 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
name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '17 3 * * 0'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: codeql-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-24.04
timeout-minutes: 60
permissions:
contents: read
actions: read
security-events: write
strategy:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
- language: go
build-mode: manual
- language: java-kotlin
build-mode: manual
- language: python
build-mode: none
steps:
- name: Check out analysis source
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
- name: Record source identity
shell: bash
env:
EVENT_SHA: ${{ github.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
EVENT_REF: ${{ github.ref }}
run: |
set -Eeuo pipefail
printf 'event_sha=%s\npr_head_sha=%s\nevent_ref=%s\n' \
"$EVENT_SHA" "$PR_HEAD_SHA" "$EVENT_REF"
printf 'checked_out_sha=%s\nchecked_out_tree=%s\n' \
"$(git rev-parse HEAD)" "$(git rev-parse HEAD^{tree})"
test "$(git rev-parse HEAD)" = "$EVENT_SHA"
- name: Set up the production Go compiler
if: matrix.language == 'go'
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
# server/Dockerfile.web-compose-release ARTIFACT_HELPER_IMAGE.
go-version: '1.27.2'
check-latest: false
cache: false
- name: Set up the production Java compiler
if: matrix.language == 'java-kotlin'
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5
with:
# server/Dockerfile TEMURIN_JDK25_VERSION.
distribution: temurin
java-version: '25.0.4+7.0.LTS'
check-latest: false
- name: Initialize CodeQL
uses: github/codeql-action/init@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
config: |
name: PastureStack complete extended analysis
queries:
- uses: security-extended
threat-models: local
- name: Build the Go console broker for analysis
if: matrix.language == 'go'
working-directory: server/console-broker
shell: bash
env:
CGO_ENABLED: '0'
GOOS: linux
GOARCH: amd64
GOTOOLCHAIN: local
run: |
set -Eeuo pipefail
test "$(go env GOVERSION)" = 'go1.27.2'
mkdir -p "$RUNNER_TEMP/codeql-go-build"
go build \
-mod=readonly \
-trimpath \
-buildvcs=false \
-ldflags='-s -w -buildid=' \
-o "$RUNNER_TEMP/codeql-go-build/pasturestack-console-broker" .
- name: Compile Java sources with the production Engine libraries
if: matrix.language == 'java-kotlin'
shell: bash
run: |
set -Eeuo pipefail
dockerfile=server/Dockerfile.web-compose-release
read_arg() {
local arg_name="$1"
local -a values
mapfile -t values < <(sed -n "s/^ARG ${arg_name}=//p" "$dockerfile" | sort -u)
test "${#values[@]}" -eq 1 || return 1
test -n "${values[0]}" || return 1
printf '%s' "${values[0]}"
}
release_base="$(read_arg ORCHESTRATION_ENGINE_RELEASE_BASE_URL)"
release_tag="$(read_arg ORCHESTRATION_ENGINE_RELEASE_TAG)"
artifact="$(read_arg ORCHESTRATION_ENGINE_ARTIFACT)"
expected_sha256="$(read_arg ORCHESTRATION_ENGINE_ARTIFACT_SHA256)"
test "$release_base" = 'https://github.com/PastureStack/orchestration-engine/releases/download'
[[ "$release_tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
test "$artifact" = cattle.jar
[[ "$expected_sha256" =~ ^[0-9a-f]{64}$ ]]
build_root="$RUNNER_TEMP/codeql-java-build"
mkdir -p "$build_root/lib" "$build_root/classes"
archive="$build_root/cattle.jar"
curl --fail --silent --show-error --location \
--proto '=https' --proto-redir '=https' \
--retry 3 --connect-timeout 15 --max-time 600 \
--output "$archive" "$release_base/$release_tag/$artifact"
printf '%s %s\n' "$expected_sha256" "$archive" | sha256sum --check --strict
unzip -j -q "$archive" 'WEB-INF/lib/*.jar' -d "$build_root/lib"
compgen -G "$build_root/lib/*.jar" > /dev/null
# Compile every tracked Java source; the reviewed tree contains one
# PatchV1GlobalSubscribe.java and no Kotlin sources or Maven project.
# Failing on future Kotlin additions avoids silently omitting them.
mapfile -d '' -t kotlin_sources < <(git ls-files -z '*.kt' '*.kts')
test "${#kotlin_sources[@]}" -eq 0
mapfile -d '' -t java_sources < <(git ls-files -z '*.java')
test "${#java_sources[@]}" -gt 0
javac -cp "$build_root/lib/*" -d "$build_root/classes" "${java_sources[@]}"
- name: Analyze and upload CodeQL results
uses: github/codeql-action/analyze@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
with:
category: '/language:${{ matrix.language }}'
wait-for-processing: true