Skip to content

Commit 783e25a

Browse files
committed
ci(security): add advanced CodeQL setup with path-scoped query filters
1 parent fc3aa4d commit 783e25a

2 files changed

Lines changed: 111 additions & 0 deletions

File tree

.github/codeql/codeql-config.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Hyperframes CodeQL config"
2+
3+
# Use GitHub's default security-extended suite — it's a strict superset of the
4+
# default suite (more queries, slightly higher false-positive rate). Pair it with
5+
# the query-filters below so the extra queries don't drown the dashboard.
6+
queries:
7+
- uses: security-extended
8+
9+
# Per-rule path filters. The intent is to silence rules that have known false
10+
# positives on specific file shapes (generated test artifacts, CDN-script test
11+
# fixtures, functional-cleanup regex) WITHOUT excluding those paths from all
12+
# analysis — a malicious contributor adding e.g. a command-injection sink into
13+
# a "test fixture" would still get caught.
14+
#
15+
# To audit what changed: look at PR diffs touching this file. Reviewers should
16+
# treat it like CODEOWNERS — adding a new path exclusion is a policy change.
17+
query-filters:
18+
# Generated test artifacts (golden baselines written by the producer test
19+
# harness). Every compiled.html re-rasterizes the regex-stripped composition;
20+
# the same alerts fire on every fixture and on every re-render.
21+
- exclude:
22+
id: js/incomplete-sanitization
23+
paths:
24+
- "packages/producer/tests/**/output/compiled.html"
25+
- "packages/producer/tests/**/failures/*.html"
26+
27+
# Test fixtures and skill test corpora intentionally load CDN scripts without
28+
# SRI — pinning hashes there would fight the test's purpose (we want the test
29+
# to use whatever the registry hands back, the same way a composition would).
30+
- exclude:
31+
id: js/functionality-from-untrusted-source
32+
paths:
33+
- "packages/producer/tests/**"
34+
- "skills/**/test-corpus/**"
35+
- "skills/**/assets/test-corpus/**"
36+
37+
# The hand-rolled HTML cleanup regex in our build-time tooling looks like a
38+
# sanitizer to CodeQL but isn't one — it strips framework bootstraps from
39+
# captured pages before they're fed back into our own renderer (Puppeteer,
40+
# not a user-facing DOM). Same for the text normalizer in the whisper path
41+
# (caption text → SRT/VTT, no DOM emission). Scope these exclusions to the
42+
# exact files that contain functional regex, not to whole directories, so
43+
# any new code in cli/, core/, or producer/ that LOOKS like a sanitizer
44+
# still trips the rules.
45+
- exclude:
46+
id: js/bad-tag-filter
47+
paths:
48+
- "packages/cli/src/capture/index.ts"
49+
- "packages/cli/src/whisper/normalize.ts"
50+
- "packages/core/src/lint/utils.ts"
51+
- "packages/producer/src/services/htmlCompiler.ts"
52+
- exclude:
53+
id: js/incomplete-multi-character-sanitization
54+
paths:
55+
- "packages/cli/src/capture/index.ts"
56+
- "packages/cli/src/whisper/normalize.ts"

.github/workflows/codeql.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# CodeQL advanced setup. Replaces GitHub's default code-scanning setup; the
2+
# repo must have default setup disabled in Security → Code scanning → "Set up"
3+
# before this workflow can run.
4+
#
5+
# Languages were taken from the existing default-setup config (JS/TS, Python,
6+
# Actions). Triggers mirror what default setup ran: push to main, every PR
7+
# against main, and a weekly schedule.
8+
#
9+
# The rules and path filters live in .github/codeql/codeql-config.yml so policy
10+
# changes show up as a normal PR diff.
11+
name: CodeQL
12+
13+
on:
14+
push:
15+
branches: [main]
16+
pull_request:
17+
branches: [main]
18+
schedule:
19+
# Mondays at 14:39 UTC — matches the cadence default setup was running on.
20+
- cron: "39 14 * * 1"
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
runs-on: ubuntu-latest
26+
permissions:
27+
security-events: write
28+
packages: read
29+
actions: read
30+
contents: read
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- language: actions
36+
build-mode: none
37+
- language: javascript-typescript
38+
build-mode: none
39+
- language: python
40+
build-mode: none
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
44+
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3
47+
with:
48+
languages: ${{ matrix.language }}
49+
build-mode: ${{ matrix.build-mode }}
50+
config-file: ./.github/codeql/codeql-config.yml
51+
52+
- name: Perform CodeQL Analysis
53+
uses: github/codeql-action/analyze@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3
54+
with:
55+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)