Skip to content

Commit 09eba8a

Browse files
authored
improvement(ci): move CodeQL off default setup onto Blacksmith (#6219)
* improvement(ci): move CodeQL off default setup onto Blacksmith Default setup pinned every scan to a 4-vCPU GitHub-hosted runner with no cancel-in-progress: PR scans ran 30-125 min and re-ran on every push (#6183 burned six overlapping runs). None of that is reachable from the settings UI, so the config moves into the repo. - Blacksmith 8-vCPU via the same CI_PROVIDER escape hatch as ci.yml - cancel-in-progress scoped to pull_request so push/schedule scans finish - push to main + PR to main/staging + nightly safety net - paths filter so doc-only PRs skip the run entirely - paths-ignore config drops tests/mocks/fixtures: 12,716 -> 11,128 files - languages: javascript-typescript + actions; python dropped (7 files in tree) Default setup has been disabled; the two cannot both be active. * fix(ci): restore CodeQL coverage of the data-drain test route Review round 1. - Drop the '**/test/**' and '**/tests/**' globs. A `test` directory is a routable Next.js path segment, and those globs excluded apps/sim/app/api/organizations/[id]/data-drains/[drainId]/test/route.ts — a POST handler that authorizes, decrypts destination credentials and makes an outbound request. CodeQL paths-ignore has no `!` negation to carve it back out, and the globs only covered 76 of 12,716 files. - Add `ready_for_review` to the pull_request activity types. It is not a default type, so a PR opened as a draft and later marked ready was skipped by the draft guard and never rescanned until the next push.
1 parent 83988c1 commit 09eba8a

2 files changed

Lines changed: 127 additions & 0 deletions

File tree

.github/codeql/codeql-config.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Sim CodeQL config
2+
3+
# Trims the extraction surface. CodeQL parses every matching file into a
4+
# database before a single query runs, and that phase dominates runtime on a
5+
# ~12.7k-file JS/TS tree. Test and fixture code is not attacker-reachable, so
6+
# excluding it costs no real coverage.
7+
#
8+
# paths-ignore applies to analysis. The workflow's `on.pull_request.paths`
9+
# filter is separate and decides whether the run happens at all.
10+
paths-ignore:
11+
- '**/*.test.ts'
12+
- '**/*.test.tsx'
13+
- '**/*.test.js'
14+
- '**/*.spec.ts'
15+
- '**/*.spec.tsx'
16+
- '**/__tests__/**'
17+
- '**/__mocks__/**'
18+
- '**/__fixtures__/**'
19+
- '**/e2e/**'
20+
# Deliberately no '**/test/**' or '**/tests/**'. A directory named `test` is a
21+
# routable Next.js path segment, not necessarily test code: those globs
22+
# excluded the real endpoint
23+
# apps/sim/app/api/organizations/[id]/data-drains/[drainId]/test/route.ts,
24+
# which authorizes, decrypts destination credentials, and makes an outbound
25+
# request. CodeQL's paths-ignore has no `!` negation to carve it back out
26+
# ("The filter pattern characters ?, +, [, ], and ! are not supported and will
27+
# be matched literally"), and the globs only covered 76 of 12,716 files, so
28+
# the naming convention above is the safer filter.
29+
- '**/*.d.ts'
30+
- '**/node_modules/**'
31+
- '**/dist/**'
32+
- '**/.next/**'
33+
- 'apps/docs/content/**'

.github/workflows/codeql.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: CodeQL
2+
3+
# Advanced setup, replacing the repo-settings "default setup".
4+
#
5+
# Default setup pinned every scan to a 4-vCPU GitHub-hosted runner with no
6+
# cancel-in-progress, which put PR scans at 30-125 min and re-ran them on every
7+
# push (PR #6183 burned six overlapping runs). None of that is configurable from
8+
# the settings UI, so the config moves into the repo.
9+
#
10+
# Before enabling this, disable default setup or the two will both run:
11+
# gh api -X PATCH repos/:owner/:repo/code-scanning/default-setup -f state=not-configured
12+
#
13+
# The runs-on expression is the same CI_PROVIDER escape hatch as ci.yml and must
14+
# change together with it.
15+
16+
on:
17+
# Pushes to main are infrequent (merges only), so a full scan per push is
18+
# affordable and is what GitHub recommends pairing with the PR trigger:
19+
# "Scanning code when someone pushes a change, and whenever a pull request is
20+
# created, prevents developers from introducing new vulnerabilities."
21+
push:
22+
branches: [main]
23+
pull_request:
24+
branches: [main, staging]
25+
# `ready_for_review` is not a default activity type, so it has to be listed
26+
# alongside the defaults it replaces. Without it, a PR opened as a draft and
27+
# then marked ready is skipped by the job-level draft guard and never
28+
# rescanned until the next push.
29+
types: [opened, synchronize, reopened, ready_for_review]
30+
paths:
31+
- '**/*.ts'
32+
- '**/*.tsx'
33+
- '**/*.js'
34+
- '**/*.jsx'
35+
- '**/*.mjs'
36+
- '**/*.cjs'
37+
- '.github/workflows/**'
38+
- '.github/actions/**'
39+
- '.github/codeql/**'
40+
schedule:
41+
# Safety net behind the push trigger, and the thing that keeps the
42+
# default-branch alert view fresh when main is quiet. Only fires once this
43+
# file is on the default branch — schedule events ignore other branches.
44+
- cron: '17 8 * * *'
45+
workflow_dispatch:
46+
47+
# Scheduled main scans must run to completion — only PR pushes supersede.
48+
concurrency:
49+
group: codeql-${{ github.ref }}
50+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
51+
52+
permissions:
53+
contents: read
54+
55+
jobs:
56+
analyze:
57+
name: Analyze ${{ matrix.language }}
58+
runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-latest' }}
59+
timeout-minutes: 60
60+
if: github.event.pull_request.draft != true
61+
permissions:
62+
security-events: write
63+
contents: read
64+
actions: read
65+
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
# One entry covers both JS and TS — `javascript`, `typescript` and
70+
# `javascript-typescript` all resolve to the same extractor
71+
# (github/codeql-action src/languages/builtin.json), so the three
72+
# entries default setup listed were one analysis, not three.
73+
# `javascript-typescript` is the documented spelling. Python dropped:
74+
# 7 files in the tree.
75+
language: [javascript-typescript, actions]
76+
77+
steps:
78+
- name: Checkout repository
79+
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
80+
with:
81+
persist-credentials: false
82+
83+
- name: Initialize CodeQL
84+
uses: github/codeql-action/init@18420e3271f74589575af831a523c833acda327f # codeql-bundle-v2.26.2
85+
with:
86+
languages: ${{ matrix.language }}
87+
config-file: ./.github/codeql/codeql-config.yml
88+
89+
- name: Perform CodeQL Analysis
90+
uses: github/codeql-action/analyze@18420e3271f74589575af831a523c833acda327f # codeql-bundle-v2.26.2
91+
env:
92+
NODE_OPTIONS: --max-old-space-size=8192
93+
with:
94+
category: /language:${{ matrix.language }}

0 commit comments

Comments
 (0)