Skip to content

ci: add a CodeQL scan of the Go code - #945

Merged
amiddavid merged 3 commits into
mainfrom
ci/codeql
Nov 8, 2026
Merged

amiddavid merged 3 commits into
mainfrom
ci/codeql

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a CodeQL scan of the Go code.
  • The main ruleset needs CodeQL results. Until now none came, so every merge bypassed the rule.

What changed

  • New file .github/workflows/codeql.yaml.
  • Runs on push to main, on pull requests to main, and weekly.
  • Build mode: manual, CGO_ENABLED=0 go build ./.... The default build is pure Go. One explicit command is the same as make build.
  • Query suite: default.
  • No paths-ignore: the rule needs a result on every PR.

No behavior change of the proxy or library. No data dependence (CI only).

What is scanned

  • The code in the shipped (untagged) binary only.
  • _test.go files are not scanned.
  • The cg_record and cg_skeleton build tags are not scanned.
  • Reason: they are not in the release binary. An alert in test code would block merges for code that no user runs.

How it was tested

  • The CodeQL job runs on this PR.

Open questions

  • Findings that block the rule get their own PRs.

🤖 Generated with Claude Code

The main ruleset has a code_scanning rule for CodeQL. No workflow
produced results, so the rule waited and every merge bypassed it.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 1bcab631e0fc approve

Verdict: approve

Findings

None.

Non-blocking

  • .github/workflows/codeql.yaml:31 — the scan covers only the default build. go build ./... runs without build tags. Code behind cg_skeleton (tree-sitter parsers) and cg_record (the OTLP session recorder, which adds a network listener) is not analyzed. The comment in the file says this is deliberate: one command, same as make build. If you want the recorder scanned, add a second job that builds with -tags cg_record. Not needed for this PR.
  • .github/workflows/codeql.yaml:19 — the job sets no timeout-minutes. The GitHub default is 360 minutes. A hung scheduled run blocks a runner for up to 6 hours. timeout-minutes: 30 would be enough; the live run took 1m43s. Style point only; ci.yaml sets none either.
  • .github/workflows/codeql.yaml:12 — actions: read is not needed. The repo is public. GitHub requires that permission only for private repositories. Harmless to keep.

What I checked

  • Read the full diff: one new file, .github/workflows/codeql.yaml (41 lines). No code, no library, no proxy change. The fail-open and data-dependence rules do not apply.
  • Verified the action inputs against the real github/codeql-action at tag v4: the tag exists, and init accepts build-mode: manual for compiled languages, including Go.
  • Verified the run on this PR (run 42475718773). The analyze job passed in 1m43s. The log shows: --build-mode=manual database init, the traced go build ./... with the CodeQL Go extractor environment set, TRAP files imported, 36 queries evaluated (including the ExtractionErrors and SuccessfullyExtractedFiles diagnostics), and the SARIF uploaded. The scan is not empty.
  • Verified the stated goal: the ruleset's CodeQL check now reports pass on this PR. Before this workflow, that check had no result source, as the first commit message says.
  • Compared with ci.yaml: same actions/checkout@v4, same actions/setup-go@v5 with go-version-file: go.mod, same CGO_ENABLED: "0" for plain builds. The record job in ci.yaml already proves go build ./... succeeds with CGO_ENABLED=0.
  • Checked the triggers: push and pull_request target main only; the weekly cron 17 5 * * 1 matches the comment "Monday 05:17 UTC". No paths filter on pull_request is deliberate and documented in the file: the code_scanning rule needs a result on every PR.
  • Checked the permissions block: contents: read, security-events: write are the minimum for uploading CodeQL results.
  • Checked both commit messages: DCO sign-off present, Assisted-By: attribution, conventional-commit titles.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 1bcab631e0fc blocking

Verdict: blocking

Findings

  1. .github/workflows/codeql.yaml:38 — the scan sees no test code: go build ./... never compiles _test.go files, so 664 of 992 tracked Go files stay outside the CodeQL database
    • What fails: CodeQL in manual build mode extracts only what the build step compiles. go build ./... compiles no test file. So the scan skips every one of the 664 _test.go files (67% of the Go code). The PR title says "a CodeQL scan of the Go code", and the ruleset now tells every PR "CodeQL passed". A reader will believe tests are scanned. They are not. Nothing in the workflow or the PR says so.
    • Proof:
      • GitHub docs, "CodeQL code scanning for compiled languages": "For C/C++, C#, Go, Java, Kotlin, and Swift, CodeQL will analyze whatever source code is built by your specified build steps." Troubleshooting page: "CodeQL only scans files that are built during the analysis."
      • CodeQL Go extractor source, go/extractor/cli/go-extractor/go-extractor.go in github/codeql (fetched today): during a traced manual build the CLI re-runs extraction with --mimic go <command>. Test extraction turns on only for the test subcommand: return parseFlags(args[i+1:], true, command == "test"). The comment at the top says extractTests is set "(b) if we're mimicking a go test command". For go build, packages.Load runs with Tests: false. The env option CODEQL_EXTRACTOR_GO_OPTION_EXTRACT_TESTS cannot override this: the --mimic branch discards it.
      • go build ./... does not compile test files. This is Go toolchain behavior.
      • Counts at this head: git ls-files '*_test.go' = 664; non-test *.go = 328.
    • Fix: make the Build step compile the tests too, for example:
      run: |
        go build ./...
        go test -p 1 -count=1 -run='^$' ./...
      -run='^$' selects no test, so the binaries only compile and start. -p 1 runs them one at a time; ci.yaml serializes test binaries for the same reason. Or, if test code is out of scope on purpose, say so in the workflow comment and the PR description. Then no reader believes tests are scanned.

Non-blocking

  • Tagged build variants are outside the scan. go build ./... passes no tags, so the 5 cg_record files and 6 cg_skeleton files are never extracted. The release binary is the untagged build, so the scan matches what ships. If you want the recorder variant scanned, add one more build command with -tags cg_record (it is pure Go).
  • The job sets no timeout-minutes. A hung analysis holds a runner for the 6-hour default. GitHub's own CodeQL examples set timeout-minutes.
  • The workflow sets no concurrency group. Rapid pushes to main run scans in parallel. ci.yaml has the same gap, so this is optional.

What I checked

  • The full diff of both commits (63fa6631, 1bcab631). One new file, 41 lines, no code outside .github/workflows/.
  • YAML syntax, triggers, and permissions. security-events: write and actions: read are both present. actions: read is required by the analyze step; codeql-action issue #2117 documents the failure without it.
  • build-mode: manual is valid for Go when one language runs per job (init action.yml of codeql-action). No matrix here, so the input applies.
  • go-version-file: go.mod — same pattern as ci.yaml. go.mod declares go 1.26.4.
  • CGO_ENABLED: "0" matches make build and the shipped binary. The goreleaser config builds untagged, CGO_ENABLED=0.
  • The main ruleset claim in the comment. Verified through the GitHub API: the ruleset has a code_scanning rule with tool CodeQL, alerts threshold errors, security alerts threshold high_or_higher. The comment is accurate.
  • Fork PR behavior. Fork pull_request runs get a read-only GITHUB_TOKEN. GitHub's code-scanning docs say upload is always allowed when the pull_request event triggers the run, so the required check still gets its result.
  • No Dependabot config exists in the repo, so the known Dependabot read-only failure mode does not apply.
  • Live tests were not run (not approved). All evidence above comes from the diff, the repo, the CodeQL action and extractor sources, and GitHub docs.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 replies.

  • Test code is not scanned (reviewer 1): not changed, on purpose. The scan matches the shipped build. Test code and the cg_record / cg_skeleton tags are not in the release binary. An alert there would block merges for code no user runs. Fixed in cc190a9: the workflow comment and a new "What is scanned" section in the PR body say this.
  • No time limit (both reviewers): fixed in cc190a9. The analyze job has timeout-minutes: 30.
  • actions: read (reviewer 2): not changed. It is harmless, and the repo needs it if it becomes private.
  • No concurrency group: not changed. ci.yaml has none either.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 cc190a958871 approve

Verdict: approve

Findings

None.

Earlier findings

  1. Reviewer 1, round 1 — test code outside the scan. The author rejected the "compile the tests" fix and chose the other fix I offered: document the scope. Commit cc190a95 adds the scope note to the Build step (.github/workflows/codeql.yaml:37-40), and the PR body has a new "What is scanned" section.

    • I checked the rejection reason. The ruleset blocks a merge on any error or high+ security alert from CodeQL. Test code and the cg_record / cg_skeleton tags are not in the release binary (the goreleaser config builds the untagged binary only). So an alert in test code would block merges for code no user runs. The reason is right. I accept it.
    • My defect claim was "nothing says tests are out of scope". That is fixed, in both the workflow and the PR body.
  2. Reviewer 1, round 1 (non-blocking) — no timeout-minutes. Fixed in cc190a95: the job now sets timeout-minutes: 30. Reviewer 2 measured the live run at 1m43s, so 30 minutes is ample.

  3. Reviewer 1, round 1 (non-blocking) — tagged variants outside the scan. Covered by the same documented scope decision. Not changed. Fine.

  4. Reviewer 1, round 1 (non-blocking) — no concurrency group. Rejected: ci.yaml has none either. Was optional. Fine.

  5. Reviewer 2, round 1 — actions: read not needed. Rejected: harmless, and needed if the repo becomes private. Checked: the starter workflow marks actions: read as required only for private repositories. Keeping it is safe. Fine.

Non-blocking

  • None new. The concurrency suggestion stays declined and that is fine.

What I checked

  • Last review: round 1, 1bcab631e0fc80ed2453b81436b7a85a4adac686, 2026-11-08T11:43:00Z.
  • New commits read: 1 — cc190a95 "ci: add a time limit to CodeQL and say what it scans".
  • Read in full: 2 reviews, 2 comments, 0 inline comments (from the three saved files).
  • New items since my last review:
    • Commit cc190a95: 5 added lines in .github/workflows/codeql.yaml. timeout-minutes: 30 at job level, correct placement. The new comment states the scan scope. Its claims match what I proved in round 1: go build ./... covers only the untagged, non-test code.
    • Author comment at 2026-11-08T11:44:06Z: the round-1 replies. Each reply checked above.
    • Updated PR body: new "What is scanned" section. Read in full. It states the scope and the reason, and both are accurate.
    • Reviewer 2's round-1 review (posted 11:30:51Z, before my round-1 post; I read it now for the first time per round-2 rules). It approved with three non-blocking notes. I checked each: scan scope (same as my finding, resolved by documentation), timeout (fixed), actions: read (declined, fine). I agree with its conclusions; nothing new to add.
    • GitHub bot comment at 11:25:14Z: the standard code-scanning welcome note. Nothing to do.
  • The full diff from base f43d9fa5 to head cc190a95: one file, 47 lines, CI only. No library, proxy, or behavior change. No data dependence.
  • Live tests were not run (not approved).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 cc190a958871 approve

Verdict: approve

Findings

None.

Earlier findings

  • My round-1 notes: all addressed or accepted.
    • Scan scope (tests and tagged variants not scanned): the author documented the scope in the workflow comment and a new "What is scanned" section in the PR body. I checked both; see below. Accepted.
    • No timeout-minutes: fixed in cc190a95. The job now sets timeout-minutes: 30. The live run on the new head took 1m33s, so 30 minutes leaves room.
    • actions: read not needed: the author kept it, with the reason "the repo needs it if it becomes private". The reason is right. Harmless today. Closed.
  • Reviewer 1, finding 1 (test code is not scanned): the facts are right, and I accept the author's rejection. I checked the core claim myself: go build ./... compiles no _test.go file, and CodeQL manual build mode extracts only what the build compiles. So test code is outside the database. The author's reason is sound: the ruleset blocks a PR on an error-level alert, and test code does not run in the shipped binary. The scope is now stated in the workflow (lines 37-40) and in the PR body. A reader can no longer believe tests are scanned. I do not repeat the finding.

Non-blocking

  • .github/workflows/codeql.yaml:37 — "the code in the shipped (untagged) binary only" is broader in reality. go build ./... compiles every untagged non-test package, including dash, examples/llm-d-service and other commands that are not in the release binary. The scan covers more than the shipped binary. The excluded items (tests, cg_record, cg_skeleton) are stated correctly, so the comment does its job. If you touch the file again, say "untagged non-test Go code" instead of "the shipped binary".

What I checked

  • Last review: round 1, 1bcab63, 2026-11-08T11:30:51Z.
  • New commits read: 1 (cc190a95, "ci: add a time limit to CodeQL and say what it scans").
  • Read in full: 2 reviews, 2 comments, 0 inline comments (from the three files). No inline comments exist on this PR.
  • New items since my last review, and what I did about each:
    • Reviewer 1's round-1 review (11:43:00Z, blocking, one finding). Read in full. Checked the finding's facts myself; see "Earlier findings".
    • The author's round-1 replies (11:44:06Z). Read in full. Verified each claim: timeout-minutes: 30 is in cc190a95; the workflow scope comment is in cc190a95; the "What is scanned" section is in the current PR body; actions: read and no concurrency group are unchanged, as stated.
    • New commit cc190a95. Read the full diff (5 added lines) and the whole workflow file around it. The commit adds the time limit and the scope comment. No behavior or code change outside .github/workflows/codeql.yaml.
    • The github-advanced-security[bot] comment (11:25:14Z) is a boilerplate setup notice. Nothing to act on.
  • Verified the new head's checks (run 42477032377): analyze passed in 1m33s, and the ruleset's CodeQL check reports pass.
  • Checked the new commit message: conventional title, DCO sign-off, Assisted-By: attribution.
  • Live tests were not run (not approved). All evidence comes from the diff, the repo, the PR conversation, and GitHub check runs.

@amiddavid
amiddavid merged commit 5f9f363 into main Nov 8, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 8, 2026
amiddavid added a commit that referenced this pull request Nov 8, 2026
check-ready.sh now fails a PR whose head has no passing CodeQL check
run from GitHub's code-scanning app. RELEASING.md gets new rules:
a PR opened before #945 needs a new push before it merges; after an
--admin merge, read the merge's rule results and tell the owner of
any failed rule other than the review rule; a PR's scan covers only
its changed lines, so read main for all open alerts; a false
positive is dismissed only with the owner's yes.

Why: on 2026-11-08 #943, #937 and #944 merged past the code-scanning
rule because they were opened before the CodeQL workflow (#945).
CodeQL scans of main afterwards found no new alert. --admin does not
say which rules it bypasses, and the script did not check code
scanning.

New integrator rule: an integrator talks with many sessions and with
the owner, so its main session must stay free. Implementation work
goes to subagents, and the main session only coordinates. The owner
asked for this.

Behavior change: none. Release scripts and docs only.
Data dependence: none. The script reads GitHub check runs only.

Reviews: 2 offload reviews (GLM), round 3 (owner granted round 3), both approve at df9d719.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
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