feat(audit): weekly CodeQL audit that files code-scanning alerts as issues
Merged
DO
1mo ago+1006+1006+0123456789012345678901234567890123456789-0-0-0123456789
Summary
Adds an org-wide CodeQL Audit, the code-scanning counterpart of the SonarCloud audit. Until now nothing turned open CodeQL alerts into work: the compliance audit only counts them into a score, and the code_scanning ruleset only blocks new merges.
scripts/codeql-audit.shreadsGET repos/{owner}/{repo}/code-scanning/alerts?state=open&tool_name=CodeQL(paginated) for every non-archived repo and groups alerts per repo × language family into one idempotent issue titledCodeQL: <family>, keyed by a hidden<!-- codeql-audit:key=<repo>/<family> -->marker.- Labels:
codeql-audit(marker),dev-lead,priority:<level>from the group's worstsecurity_severity_level(else the rule severity), andsecurityfor security alerts. It uses the same priority scale as the Sonar audit and creates shared labels only when they are missing, so their descriptions are never overwritten. - Re-runs refresh the body, comment, and re-trigger dev-lead through
scripts/lib/dev-lead-retrigger.sh. A group with no open alerts is closed automatically. .github/workflows/codeql-audit.yml: Wednesdays 17:02 UTC, between the Tuesday Sonar audit and the Friday compliance audit (minute fromcron_offset_minute). Hastarget_repoanddry_rundispatch inputs..github/workflows/codeql-audit-tests.ymlruns shellcheck and bats ontest/scripts/codeql-audit/(42 tests).- Docs:
standards/ci-standards.md§ CodeQL Audit, plus a row in the github-settings.md org-workflows table.
No duplicate issues
| Alert | Handling | Why |
|---|---|---|
actions/unpinned-tag on a combsmith/* ref | suppressed | First-party channel tags are exempt from SHA-pinning by policy. Filing them would send dev-lead to break the stubs. Today this is all 69 unpinned-tag alerts. |
actions/unpinned-tag, third-party | suppressed | Already filed as Compliance: unpinned-actions-<wf> |
actions/missing-workflow-permissions | suppressed | Already filed as Compliance: missing-permissions-<wf> |
| Scorecard SARIF alerts | excluded by tool_name=CodeQL | Owned by org-scorecard.yml |
| SonarCloud findings | n/a | The Sonar audit uses a different source, marker label, title prefix and body key, so neither audit adopts or closes the other's issues |
Suppressed alerts appear in the run summary with their reason, so they are visible but never filed.
Fail closed: if a repo's alerts can't be read (anything other than GitHub's no analysis found), the repo is marked inconclusive and its issues are left untouched. The run then fails after the summary is written.
Dry run (.github-private, local token)
[info] CodeQL audit — org=combsmith dry_run=true create_issues=true target=.github-private
[info] Scanning .github-private
[info] [dry-run] .github-private :: CodeQL: GitHub Actions workflow security [codeql-audit,dev-lead,priority:major,security] (4 alert(s))
[info] [dry-run] .github-private :: CodeQL: JavaScript/TypeScript alerts [codeql-audit,dev-lead,priority:critical,security] (32 alert(s))
[info] Done. Filed alerts: 36; suppressed: 13; groups: 2; added=0 existing=0 removed=0
Whole-org dry run: 15 repos read, 0 inconclusive, 36 alerts filed as 2 issues, 69 suppressed.
Before the first scheduled run
- Confirm
ORG_SCORECARD_TOKENhas Code scanning alerts: Read-only on all repos. The local dry run used a different token. The compliance workflow's own code-scanning read treats errors as 0, so it does not prove the scope. If the scope is missing, every repo comes back inconclusive and the run goes red; no issues are written. - Optional: dispatch with
dry_run: trueonce after merge.
Test plan
-
bats test/scripts/codeql-audit/— 42/42 -
shellcheck --severity=warning -x scripts/codeql-audit.sh,actionlint,check-cron-timing.sh, markdownlint on the changed docs - Action SHAs checked with the GitHub API (
actions/checkoutv7.0.13d3c42e5…,actions/upload-artifactv7.0.2cf430e03…, both current latest) - Local dry runs, one repo and whole org
🤖 Generated with Claude Code