Repository navigation
237 lines (225 loc) · 9.63 KB
/
Copy pathcodeql.yml
File metadata and controls
237 lines (225 loc) · 9.63 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: CodeQL
on:
workflow_dispatch:
inputs:
profile:
description: CodeQL security profile to run
required: false
default: all
type: choice
options:
- all
- security
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- ".gitattributes"
- "**/.gitattributes"
- ".github/actions/**"
- ".github/codeql/**"
- ".github/workflows/**"
- "extensions/acpx/src/**"
- "extensions/bonjour/src/advertiser.ts"
- "extensions/browser/src/browser/chrome-mcp.ts"
- "extensions/browser/src/browser/chrome.executables.ts"
- "extensions/browser/src/browser/chrome.ts"
- "extensions/codex/src/app-server/sandbox-exec-server/**"
- "extensions/codex/src/app-server/transport-stdio.ts"
- "extensions/codex/src/node-cli-sessions.ts"
- "extensions/file-transfer/src/**"
- "extensions/google-meet/src/**"
- "extensions/imessage/src/**"
- "extensions/memory-wiki/src/obsidian.ts"
- "extensions/microsoft-foundry/cli.ts"
- "extensions/ollama/src/wsl2-crash-loop-check.ts"
- "extensions/qa-lab/src/**"
- "extensions/signal/src/daemon.ts"
- "extensions/tts-local-cli/speech-provider.ts"
- "extensions/voice-call/src/**"
- "packages/**"
- "scripts/**"
- "src/**"
schedule:
- cron: "23 * * * *"
concurrency:
group: codeql-${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && format('manual-{0}', github.run_id) || github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || format('ref-{0}', github.ref) }}
# Finish the active main scan; newer hours may replace only pending work.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
permissions:
actions: read
contents: read
security-events: write
jobs:
scope:
if: ${{ ((github.event_name != 'schedule' || github.repository == 'openclaw/openclaw') && (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' || inputs.profile == 'all' || inputs.profile == 'security')) }}
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
outputs:
matrix: ${{ steps.scope.outputs.matrix }}
has_work: ${{ steps.scope.outputs.has_work }}
steps:
- name: Checkout event merge
id: checkout
continue-on-error: true
if: github.event_name == 'pull_request'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
fetch-depth: 2
fetch-tags: false
persist-credentials: false
submodules: false
- name: Checkout scheduled admission
if: github.event_name == 'schedule'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
sparse-checkout: |
.github/actions/detect-scheduled-changes
.github/codeql
persist-credentials: false
- name: Detect scheduled security changes
id: scheduled_scope
if: github.event_name == 'schedule'
uses: ./.github/actions/detect-scheduled-changes
with:
git-diff: "true"
proofs: |
{
"core-auth-secrets": {
"jobs": "Security High (core-auth-secrets)",
"codeqlConfig": ".github/codeql/codeql-core-auth-secrets-critical-security.yml"
},
"channel-runtime-boundary": {
"jobs": "Security High (channel-runtime-boundary)",
"codeqlConfig": ".github/codeql/codeql-channel-runtime-boundary-critical-security.yml"
},
"network-ssrf-boundary": {
"jobs": "Security High (network-ssrf-boundary)",
"codeqlConfig": ".github/codeql/codeql-network-ssrf-boundary-critical-security.yml"
},
"mcp-process-tool-boundary": {
"jobs": "Security High (mcp-process-tool-boundary)",
"codeqlConfig": ".github/codeql/codeql-mcp-process-tool-boundary-critical-security.yml"
},
"process-exec-boundary": {
"jobs": "Security High (process-exec-boundary)",
"codeqlConfig": ".github/codeql/codeql-process-exec-boundary-critical-security.yml"
},
"plugin-trust-boundary": {
"jobs": "Security High (plugin-trust-boundary)",
"codeqlConfig": ".github/codeql/codeql-plugin-trust-boundary-critical-security.yml"
},
"actions": {
"jobs": "Security High (actions)",
"codeqlConfig": ".github/codeql/codeql-actions-critical-security.yml"
}
}
# Extraction inputs come from each profile. Shared query/tool changes refresh all.
paths: |
.github/workflows/codeql.yml
.github/codeql/**
.github/actions/detect-scheduled-changes/**
.gitattributes
**/.gitattributes
- name: Select security languages
id: scope
env:
CODEQL_CHECKOUT_OUTCOME: ${{ steps.checkout.outcome }}
CODEQL_SCHEDULED_PROOFS: ${{ steps.scheduled_scope.outputs.proofs }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const categories = [
"core-auth-secrets",
"channel-runtime-boundary",
"network-ssrf-boundary",
"mcp-process-tool-boundary",
"process-exec-boundary",
"plugin-trust-boundary",
"actions",
];
let actions = true;
let javascript = true;
if (context.eventName === "pull_request") {
try {
if (process.env.CODEQL_CHECKOUT_OUTCOME !== "success") {
throw new Error("event checkout unavailable");
}
const result = await exec.getExecOutput("git", [
"diff", "--no-renames", "--name-only", "-z", "HEAD^1", "HEAD",
], { ignoreReturnCode: true, silent: true });
const files = result.stdout.split("\0").filter(Boolean);
if (result.exitCode !== 0 || files.length === 0) {
throw new Error("changed paths unavailable");
}
// Attributes can transform checked-out sources for either language.
const policy = files.some((file) =>
file === ".github/workflows/codeql.yml" || file.startsWith(".github/codeql/") ||
file === ".gitattributes" || file.endsWith("/.gitattributes"));
const workflow = (file) =>
file.startsWith(".github/workflows/") || file.startsWith(".github/actions/");
actions = policy || files.some(workflow);
// Any other path conservatively retains every JavaScript category.
javascript = policy || files.some((file) => !workflow(file));
} catch {
core.warning("CodeQL path selection unavailable; retaining every category.");
}
}
let scheduled = {};
try {
scheduled = JSON.parse(process.env.CODEQL_SCHEDULED_PROOFS || '{}') ?? {};
} catch {
core.warning("CodeQL scheduled selection unavailable; retaining every category.");
}
const include = categories
.filter((category) => context.eventName === "schedule"
? scheduled[category] !== false
: category === "actions" ? actions : javascript)
.map((category) => ({
language: category === "actions" ? "actions" : "javascript-typescript",
category,
runs_on: "ubuntu-24.04",
timeout_minutes: category === "actions" ? 10 : 25,
config_file: `./.github/codeql/codeql-${category}-critical-security.yml`,
}));
core.setOutput("matrix", JSON.stringify({ include }));
core.setOutput("has_work", include.length > 0);
security-high:
needs: scope
name: Security High (${{ matrix.category }})
# Gate before matrix expansion: a skip-only run must not record successful scan jobs.
if: ${{ needs.scope.outputs.has_work == 'true' }}
runs-on: ${{ matrix.runs_on }}
timeout-minutes: ${{ matrix.timeout_minutes }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.scope.outputs.matrix) }}
steps:
- name: Checkout
if: ${{ matrix.category != 'actions' }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: false
- name: Checkout Actions security sources
if: ${{ matrix.category == 'actions' }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: false
sparse-checkout: |
.github/actions
.github/workflows
.github/codeql
- name: Initialize CodeQL
uses: github/codeql-action/init@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
with:
languages: ${{ matrix.language }}
config-file: ${{ matrix.config_file }}
- name: Analyze
uses: github/codeql-action/analyze@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
with:
category: "/codeql-security-high/${{ matrix.category }}"