Skip to content

Commit db4f357

Browse files
julian-rischclaude
andcommitted
ci: add CodeQL advanced setup for SAST coverage
Adds a committed CodeQL workflow (advanced setup) that runs on push and pull_request to main plus a weekly schedule, so the OpenSSF Scorecard SAST check reliably credits CodeQL via both its workflow-config and runs-on-commits probes. GitHub's "default setup" has no workflow file and is not consistently detected (see ossf/scorecard#3817). Action versions are SHA-pinned and kept fresh by Dependabot. Note: CodeQL default setup must be disabled in repo settings before merging, since GitHub does not allow default and advanced setup together. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8b6eae7 commit db4f357

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# CodeQL (SAST)
2+
#
3+
# Advanced setup for GitHub code scanning, committed as a workflow file so it is
4+
# reliably credited by the OpenSSF Scorecard SAST check:
5+
# - scorecard's CodeQL-config probe only fires when a workflow references
6+
# `github/codeql-action/analyze` (GitHub's "default setup" has no such file),
7+
# - running `on: pull_request` produces a CodeQL check on every PR's commits,
8+
# which scorecard's "runs on all commits" probe looks for.
9+
# See https://github.com/ossf/scorecard/issues/3817 for why default setup is not
10+
# enough on its own.
11+
#
12+
# IMPORTANT: GitHub does not allow advanced setup and "default setup" at the same
13+
# time. Disable CodeQL default setup under
14+
# Settings -> Code security -> Code scanning -> CodeQL analysis -> Default setup
15+
# before merging this workflow, otherwise the analyze step fails.
16+
#
17+
# Action versions are pinned by commit SHA (required by the pinned-dependencies
18+
# check) and kept fresh by Dependabot's `github-actions` updater.
19+
20+
name: CodeQL
21+
22+
on:
23+
push:
24+
branches: [main]
25+
pull_request:
26+
branches: [main]
27+
schedule:
28+
# Weekly baseline scan of the default branch.
29+
- cron: "27 4 * * 1"
30+
workflow_dispatch:
31+
32+
permissions:
33+
contents: read
34+
35+
jobs:
36+
analyze:
37+
name: Analyze (${{ matrix.language }})
38+
runs-on: ubuntu-latest
39+
permissions:
40+
# Required to upload code-scanning results to the Security tab.
41+
security-events: write
42+
# Required by codeql-action to read the workflow/CI config.
43+
actions: read
44+
contents: read
45+
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
include:
50+
# Haystack is a Python project; Python is interpreted, so no build is
51+
# needed. Add `javascript-typescript` here if the docs-website JS code
52+
# should also be scanned.
53+
- language: python
54+
build-mode: none
55+
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
59+
with:
60+
persist-credentials: false
61+
62+
- name: Initialize CodeQL
63+
uses: github/codeql-action/init@9887d98ae49f1f598651b556d8c8f02f3ea065cb # v3.27.0
64+
with:
65+
languages: ${{ matrix.language }}
66+
build-mode: ${{ matrix.build-mode }}
67+
68+
- name: Perform CodeQL Analysis
69+
uses: github/codeql-action/analyze@9887d98ae49f1f598651b556d8c8f02f3ea065cb # v3.27.0
70+
with:
71+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)