CodeQL Python analysis guarded for fork PRs with offline CI test
This push adds an offline validation gate that enforces CodeQL Python analysis on every pull request targeting main, including fork PRs. A new test script asserts the workflow triggers on all main‑bound PRs without path or branch filters, preserves the required check name, and fails closed if the configuration drifts.
Implementation: offline test validates workflow shape
A new script scripts/ci/codeql-workflow-test.py loads the CodeQL workflow and asserts that the pull_request trigger targets main with no paths, paths-ignore, or branches-ignore filters. It requires the opened, synchronize, and reopened event types, ensures the analyze-python job exists with the exact name CodeQL Python, forbids an if condition that could exclude fork PRs, disallows continue-on-error, and checks for minimal permissions (contents: read, security-events: write). The test also validates that the upload step uses the expected SARIF category and that the Chainguard CodeQL action remains pinned. Negative fixtures cover missing check names, fork exclusions, filtered events, ignored failures, and disabled analysis uploads.
Verification: offline gate integrated into CI
scripts/ci/offline-checks.sh now invokes python3 -I scripts/ci/codeql-workflow-test.py alongside the existing offline checks. The validation-gates documentation was updated to record that the offline gate runs this test, including its negative fixtures. The gate runs in CI before any workflow execution, catching drift early.
Platform engineering: fail‑closed guards for required security checks
The pattern of an offline schema test that fails closed on configuration drift applies broadly. Any platform team can codify required check names, trigger shapes, permissions, and step contracts in a standalone test, run it in an offline gate, and document the negative cases. This keeps security‑critical workflows executable on fork PRs and prevents silent gaps when workflow files are refactored.