Skip to content

ci: Run CodeQL on push to main as a baseline - #1820

Merged
huang195 merged 2 commits into
rossoctl:mainfrom
huang195:ci/codeql-main-baseline
Nov 12, 2026
Merged

huang195 merged 2 commits into
rossoctl:mainfrom
huang195:ci/codeql-main-baseline

Conversation

@huang195

@huang195 huang195 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

CodeQL ran only on pull requests, so main had no CodeQL analysis. This PR runs CodeQL on push to main too, 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:

  1. CodeQL analyzes only the flows that the diff touches. A PR that edits a source line brings back every old flow from that line, even when the edit only adds an argument.
  2. A dismissal stays only while the fingerprint stays the same. An edit near the sink line changes the fingerprint.

On #1819, adding one argument to the four hydrateSession(..., r.Header, ...) / attributeForRecording(...) call sites brought back 15 old go/clear-text-logging flows. 14 matched dismissed alerts. The logAppended sink in core/session/store.go did not:

PR Sink line Fingerprint Alert
#1690 store.go:1496 9cfdef92f9bb94cc:1 262, dismissed
#1819 store.go:1120 b6151c5f5c255d9c:1 359, new, check failed

#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 every push to main and on pull_request to main. Only the pull_request trigger skips **.md: a PR is compared with the analysis of its exact base commit, so every main commit needs one, docs-only merges too.
  • .github/workflows/security-scans.yaml: the CodeQL job is removed. Dependency Review works only on pull_request events, so the other scans stay here and do not run on push.
  • .github/CLAUDE.md: the workflow table has the new row.

Testing

  • yamllint with the config that the YAML Lint job writes: clean on both workflow files.
  • pre-commit run on the changed files: passed.
  • This PR runs the new workflow on pull_request. The push run starts after the merge.

After merge

  • The first run on main analyzes the whole tree, not only a diff. It can show open alerts in the Security tab that match no dismissed alert, such as the logAppended sink. Triage them one time. A push run gates nothing, so they fail no check.
  • Not tested yet: that the PR check then ignores alerts that are open on main. GitHub documents this comparison with the base branch. The first PR after the merge shows it.
  • For about 2.5 minutes after each merge, the push analysis is still running. A PR opened or synced in that time has no base analysis yet. This gap cannot be avoided.
  • Cost: about 2.5 minutes of runner time for each push to main, docs-only included (the Go leg; Python runs in parallel in about 1 minute).
  • main has no required status checks, so the new check names (CodeQL / CodeQL Analysis (go)) block nothing.

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

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>
@huang195
huang195 requested review from a team and rubambiza as code owners November 12, 2026 01:10
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Passed 1 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 1 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread .github/workflows/codeql.yaml Outdated
on:
push:
branches: [main]
paths-ignore:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 clawgenti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@huang195
huang195 merged commit c357679 into rossoctl:main Nov 12, 2026
38 checks passed
@huang195
huang195 deleted the ci/codeql-main-baseline branch November 12, 2026 01:41
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants