Skip to content

Commit 4c9437b

Browse files
authored
ci(codeql): run nightly scans on main (#3007)
Signed-off-by: Adrien Langou <alangou@nvidia.com>
1 parent d1155aa commit 4c9437b

4 files changed

Lines changed: 45 additions & 34 deletions

File tree

.github/codeql/codeql-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ paths:
1111
- python/openshell
1212

1313
paths-ignore:
14+
# Integration-test targets are not removed by the Rust cfg override.
15+
- crates/*/tests
1416
- python/openshell/_proto
1517
- sdk/typescript/src/gen

.github/workflows/codeql.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@
44
name: CodeQL
55

66
on:
7-
pull_request:
8-
merge_group:
9-
types: [checks_requested]
10-
push:
11-
branches: [main]
127
schedule:
13-
- cron: "29 5 * * 6"
8+
- cron: "29 5 * * *"
149
workflow_dispatch:
1510

1611
permissions:
@@ -26,6 +21,9 @@ jobs:
2621
name: CodeQL (${{ matrix.language }})
2722
runs-on: ubuntu-latest
2823
timeout-minutes: 90
24+
env:
25+
# Keep Rust test fixtures out of production-focused security results.
26+
CODEQL_EXTRACTOR_RUST_OPTION_CARGO_CFG_OVERRIDES: "-test"
2927
strategy:
3028
fail-fast: false
3129
matrix:

CI.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ The GitHub ruleset should require the `OpenShell / ...` statuses published by `R
2929
## Informational security reports
3030

3131
Security analysis that does not need NVIDIA infrastructure runs directly on
32-
GitHub-hosted runners. These workflows receive no secrets and run on fork pull
33-
requests without waiting for copy-pr-bot. Scanner jobs request
34-
`security-events: write` to publish SARIF to Code Scanning. GitHub permits
35-
Code Scanning uploads from `pull_request` runs even when fork and Dependabot
36-
contexts receive a read-only `GITHUB_TOKEN`, so each scanner uploads results
37-
directly and also retains report artifacts:
32+
GitHub-hosted runners. These workflows receive no secrets. The PR-oriented
33+
reports run on fork pull requests without waiting for copy-pr-bot. Scanner jobs
34+
request `security-events: write` to publish SARIF to Code Scanning. GitHub
35+
permits Code Scanning uploads from `pull_request` runs even when fork and
36+
Dependabot contexts receive a read-only `GITHUB_TOKEN`, so those scanners upload
37+
results directly and also retain report artifacts:
3838

3939
- `Workflow Security Reports` runs Actionlint and Zizmor. Actionlint reports
4040
workflow syntax and expression findings. Zizmor reports only High severity,
@@ -46,13 +46,15 @@ directly and also retains report artifacts:
4646
a warning, so the workflow remains neutral until the repository feature is
4747
available.
4848
- `CodeQL` analyzes product Rust code, examples, and the Go, Python, and
49-
TypeScript SDKs. E2E test code is excluded. Results are uploaded to Code
50-
Scanning and always retained as workflow artifacts.
49+
TypeScript SDKs. Rust `cfg(test)` blocks, Rust integration-test targets, and
50+
E2E test code are excluded. It runs nightly on `main`, remains manually
51+
dispatchable for diagnostics, uploads results to Code Scanning, and retains
52+
workflow artifacts.
5153

5254
Findings do not fail these workflows. Tool startup, configuration, build, and
53-
analysis failures still fail so a broken scanner cannot appear healthy. These
54-
workflows also run on merge groups, but their checks are not required statuses
55-
and do not gate merges.
55+
analysis failures still fail so a broken scanner cannot appear healthy. The
56+
PR-oriented reports also run on merge groups; CodeQL is not a PR or merge-queue
57+
check. None of these reports are required statuses or gate merges.
5658

5759
Run the workflow-definition scanners locally with:
5860

@@ -184,7 +186,7 @@ The bot's full administrator documentation is internal to NVIDIA. The only comma
184186
| `.github/workflows/e2e-label-help.yml` | When a `test:e2e*` label is applied, posts a PR comment telling the maintainer the next manual step (re-run an existing workflow run, or `/ok to test <SHA>` to refresh the mirror). |
185187
| `.github/workflows/workflow-security.yml` | Runs informational Actionlint and High-severity Zizmor reports on GitHub-hosted runners. |
186188
| `.github/workflows/dependency-review.yml` | Reports dependency changes when GitHub Dependency Graph is available; otherwise publishes a neutral warning. |
187-
| `.github/workflows/codeql.yml` | Runs informational CodeQL analysis for Rust and the Go, Python, and TypeScript SDKs and retains SARIF artifacts. |
189+
| `.github/workflows/codeql.yml` | Runs nightly informational CodeQL analysis on `main` for Rust and the Go, Python, and TypeScript SDKs and retains SARIF artifacts. |
188190

189191
## Release workflows
190192

architecture/build.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,22 @@ disables emission for Rust tests, E2E runs, and release canaries. This prevents
284284
synthetic activity from contributing to product usage metrics.
285285

286286
Static security checks are deliberately outside the mirror-branch path. They run
287-
directly on GitHub-hosted runners with no secrets, so they also cover fork pull
288-
requests and consume no NVIDIA self-hosted capacity. Scanner jobs request
289-
`security-events: write` and upload SARIF to Code Scanning directly on every
290-
event they run on, including fork and Dependabot pull requests, which Code
291-
Scanning permits for `pull_request` runs despite their read-only `GITHUB_TOKEN`.
292-
Each scanner also retains its report as a workflow artifact. No privileged
293-
intermediate workflow relays those uploads.
294-
Triggers differ by workflow: `.github/workflows/workflow-security.yml` and
295-
`.github/workflows/codeql.yml` run on `pull_request`, `merge_group`, `main`, and
296-
a weekly schedule; `.github/workflows/dependency-review.yml` runs on
297-
`pull_request` and `merge_group` only, because it needs a base and head commit
298-
to compare.
287+
directly on GitHub-hosted runners with no secrets, so the pull-request-triggered
288+
ones also cover fork pull requests, and none of them consume NVIDIA self-hosted
289+
capacity. Scanner jobs request `security-events: write` and upload SARIF to Code
290+
Scanning directly on every event they run on, including fork and Dependabot pull
291+
requests, which Code Scanning permits for `pull_request` runs despite their
292+
read-only `GITHUB_TOKEN`. Each scanner also retains its report as a workflow
293+
artifact. No privileged intermediate workflow relays those uploads.
294+
Triggers differ by workflow: `.github/workflows/workflow-security.yml` runs on
295+
`pull_request`, `merge_group`, `main`, and a weekly schedule;
296+
`.github/workflows/dependency-review.yml` runs on `pull_request` and
297+
`merge_group` only, because it needs a base and head commit to compare; and
298+
`.github/workflows/codeql.yml` runs nightly on the default branch (`main`) via
299+
`schedule`, with `workflow_dispatch` kept for manual diagnostics. CodeQL does
300+
not run on `pull_request`, `merge_group`, or pushes to `main`, so it reports
301+
repository-level Code Scanning state on the default branch instead of per-PR
302+
results, and its four-language matrix stays off the per-change critical path.
299303

300304
- **Actionlint and Zizmor** analyze the workflow definitions themselves.
301305
Repository configuration lives in `.github/actionlint.yml` (self-hosted runner
@@ -311,10 +315,15 @@ to compare.
311315
reporting on its own once the feature is enabled. Reviews run in warn-only
312316
mode.
313317
- **CodeQL** analyzes product Rust code, examples, and the Go, Python, and
314-
TypeScript SDKs, scoped by `.github/codeql/codeql-config.yml`; E2E test code is
315-
excluded. Only Go requires a build; the other languages use build mode `none`.
316-
Results are uploaded to Code Scanning and always retained as workflow
317-
artifacts.
318+
TypeScript SDKs, scoped by `.github/codeql/codeql-config.yml`. Rust test code
319+
is excluded in two layers: the analyze job sets
320+
`CODEQL_EXTRACTOR_RUST_OPTION_CARGO_CFG_OVERRIDES=-test` so the extractor skips
321+
`#[cfg(test)]` blocks, and `paths-ignore` drops `crates/*/tests`, whose
322+
integration targets the cfg override does not reach. Examples remain in scope,
323+
and E2E test code stays excluded because `e2e/` is not an analyzed path. Only
324+
Go requires a build; the other languages use build mode `none`. Analysis runs
325+
on the nightly schedule or by manual dispatch. Results are uploaded to Code
326+
Scanning and always retained as workflow artifacts.
318327

319328
Findings never fail these checks; scanner and build failures do. A scanner that
320329
cannot run, a CodeQL analyzer that does not complete, and an unexpected

0 commit comments

Comments
 (0)