Repository navigation
167 lines (157 loc) 路 6.6 KB
/
Copy pathcodeql.yml
File metadata and controls
167 lines (157 loc) 路 6.6 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
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:
- ".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/**"
push:
branches:
- main
schedule:
- cron: "0 6 * * *"
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) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
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:
contents: read
outputs:
matrix: ${{ steps.scope.outputs.matrix }}
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: Select security languages
id: scope
env:
CODEQL_CHECKOUT_OUTCOME: ${{ steps.checkout.outcome }}
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");
}
const policy = files.some((file) =>
file === ".github/workflows/codeql.yml" || file.startsWith(".github/codeql/"));
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.");
}
}
const include = categories
.filter((category) => 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 }));
security-high:
needs: scope
name: Security High (${{ matrix.category }})
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: ${{ 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 }}"