Repository navigation
ci: Run CodeQL on push to main as a baseline - #1820
Conversation
CodeQL ran only on pull requests, so main had no analysis. Without a base analysis, GitHub judges each PR result only by the fingerprint of an earlier alert. A PR that edits a source line brings back every old flow from that line. When an edit near the sink changed its fingerprint, the old flow failed the PR as a new alert. This happened on rossoctl#1819 (alert 359, the same flow as dismissed alert 262). Move the CodeQL job from security-scans.yaml to its own codeql.yaml, and run it on push to main as well as on PRs. Dependency Review works only on pull_request events, so the other scans stay in security-scans.yaml and do not run on push. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
Pre-merge checks:
|
clawgenti
left a comment
There was a problem hiding this comment.
Summary
The job moves out of security-scans.yaml unchanged: same SHA-pinned actions, the same security-events: write / contents: read job permissions under a top-level permissions: {}, and the same /language:<lang> categories. The new push: branches: [main] trigger is valid and does what the PR says: it uploads a CodeQL analysis for refs/heads/main. The code-scanning API shows none on main today (only Scorecard), and the PR's own run already uploads under the new .github/workflows/codeql.yaml:codeql key. Keeping Dependency Review on pull_request only is right. I have one non-blocking suggestion inline, about paths-ignore on the push trigger leaving some main commits with no baseline.
Author: huang195 (MEMBER, maintainer)
Areas reviewed: CI/GitHub Actions, YAML, Docs
Agent/IDE config (.claude/.vscode): none (.github/CLAUDE.md is documentation, not agent config)
Commits: 1 commit, all signed-off: yes
CI status: passing (CodeQL go/python legs and the CodeQL results check green)
| on: | ||
| push: | ||
| branches: [main] | ||
| paths-ignore: |
There was a problem hiding this comment.
suggestion: Consider dropping paths-ignore from the push trigger and keeping it only on pull_request. With it, a merge that changes only Markdown (a fairly common merge here) leaves that main commit with no CodeQL analysis. A PR's merge ref is based on the current tip of main, so a PR opened or synced after a docs-only merge has no analysis for its exact base commit. That is the case this PR is meant to fix, and the Code scanning results check can show a "missing analysis for base" warning or go back to fingerprint-only matching. GitHub's own example ("Avoiding unnecessary scans of pull requests" in the workflow configuration docs) puts paths-ignore only under pull_request and leaves push unfiltered. A docs-only push to main costs about 2.5 runner-minutes, and in exchange every base commit has a baseline. The same gap exists for about 2.5 minutes after any merge, while the push analysis is still running. That one is unavoidable and is worth a line in the "After merge" notes when you check the first PR.
There was a problem hiding this comment.
Applied in 1feb1f0. push has no paths-ignore now, so every main commit gets an analysis. The PR body "After merge" notes now name the 2.5-minute gap after each merge.
A PR is compared with the analysis of its exact base commit. With paths-ignore on push, a docs-only merge left that main commit with no analysis, so the next PR had no baseline. GitHub's example puts paths-ignore only under pull_request. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
1feb1f0 applies the earlier suggestion. push: branches: [main] has no paths-ignore now, and only pull_request skips **.md. That matches GitHub's documented pattern, so every main commit, docs-only merges included, gets the base analysis that a PR is compared with. The job body is the same as the one removed from security-scans.yaml: the same SHA-pinned checkout/codeql-action steps, the same job permissions under permissions: {}, and the same /language:<lang> categories and config file. The PR's own runs upload under the new .github/workflows/codeql.yaml:codeql key for both languages, and main has no CodeQL analysis yet (only Scorecard), so the push run adds no conflicting configuration. The rulesets have no rules and main has no branch protection, so neither the renamed check nor the dropped security-scans.yaml:codeql key is a required check. The .github/CLAUDE.md table and the security-scans.yaml header and comment match the change. I found no new issues.
Author: huang195 (MEMBER, maintainer)
Areas reviewed: CI/GitHub Actions, YAML, Docs
Agent/IDE config (.claude/.vscode): none (.github/CLAUDE.md is documentation, not agent config)
Commits: 2 commits, all signed-off: yes
CI status: passing (CodeQL go/python and the CodeQL results check green; the macOS peerproc leg was still pending when I checked)
Summary
CodeQL ran only on pull requests, so
mainhad no CodeQL analysis. This PR runs CodeQL on push tomaintoo, so the PR check has a base analysis to compare with.Why
Without a base analysis, GitHub judges each PR result only by the fingerprint (
primaryLocationLineHash) of an earlier alert. Two things then make an old flow fail a PR:On #1819, adding one argument to the four
hydrateSession(..., r.Header, ...)/attributeForRecording(...)call sites brought back 15 oldgo/clear-text-loggingflows. 14 matched dismissed alerts. ThelogAppendedsink incore/session/store.godid not:store.go:14969cfdef92f9bb94cc:1store.go:1120b6151c5f5c255d9c:1#1616 added comment lines above the sink, and later commits moved the function, so the hash changed. The
// codeql[go/clear-text-logging]comment there does not suppress the alert.What changed
.github/workflows/codeql.yaml(new): the CodeQL job, unchanged. It runs on everypushtomainand onpull_requesttomain. Only thepull_requesttrigger skips**.md: a PR is compared with the analysis of its exact base commit, so everymaincommit needs one, docs-only merges too..github/workflows/security-scans.yaml: the CodeQL job is removed. Dependency Review works only onpull_requestevents, so the other scans stay here and do not run on push..github/CLAUDE.md: the workflow table has the new row.Testing
yamllintwith the config that the YAML Lint job writes: clean on both workflow files.pre-commit runon the changed files: passed.pull_request. Thepushrun starts after the merge.After merge
mainanalyzes the whole tree, not only a diff. It can show open alerts in the Security tab that match no dismissed alert, such as thelogAppendedsink. Triage them one time. A push run gates nothing, so they fail no check.main. GitHub documents this comparison with the base branch. The first PR after the merge shows it.main, docs-only included (the Go leg; Python runs in parallel in about 1 minute).mainhas no required status checks, so the new check names (CodeQL / CodeQL Analysis (go)) block nothing.Assisted-By: Claude (Anthropic AI) noreply@anthropic.com