Skip to content

fix(CodeQL Go scan): bump Go to 1.22.5 and add wrapper-script tracer#198

Merged
nechvatalp merged 5 commits into
devfrom
imenkov/codeql_fix
Jun 10, 2026
Merged

fix(CodeQL Go scan): bump Go to 1.22.5 and add wrapper-script tracer#198
nechvatalp merged 5 commits into
devfrom
imenkov/codeql_fix

Conversation

@imenkov

@imenkov imenkov commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix for CodeQL Go scanning for this repo, which has been producing empty databases (No source code was built for go in CodeQL Finalize).

Root causes

  1. Go toolchain too old for CodeQL Go extractor. The pipeline pinned GoTool@0 to 1.13.5, but the CodeQL Go extractor requires Go ≥ 1.21.
  2. Go ≥ 1.21 statically links the toolchain. The CodeQL preload tracer can no longer intercept calls to the real go binary, so even with a working extractor, no Go source was being captured.
  3. CGO build failure on Mariner-2 agent. The hosted agent has no C toolchain or libc headers, so cgo-enabled builds fail with stdlib.h: No such file or directory.
  4. Single-package build. The original Go@0 command: build only built the root azuredevops package, leaving the ~70 subpackages out of the database.

Changes

All edits are scoped to azure-pipelines.yml:

  • Bump Go toolchain to 1.22.5 (meets CodeQL ≥ 1.21 requirement; modules still declare go 1.12 in go.mod, so SDK consumers are unaffected).
  • Set job-level CGO_ENABLED: 0 so the pure-Go runtime is used on the Mariner-2 agent.
  • Replace the autobuild step with a single bash: task that:
    1. Creates a thin shell wrapper around go in $AGENT_TEMPDIRECTORY/codeql-go-tracing.
    2. Prepends that directory to PATH so the CodeQL preload tracer can intercept invocations.
    3. Runs go build ./... from the same script step, covering every package in the azuredevops module.

@imenkov imenkov changed the title Fix CodeQL Go scan: bump Go to 1.22.5 and add wrapper-script tracer Fix CodeQL Go scan: bump Go to 1.22.5 for CodeQL scanning and add wrapper-script tracer Jun 9, 2026
@imenkov imenkov changed the title Fix CodeQL Go scan: bump Go to 1.22.5 for CodeQL scanning and add wrapper-script tracer fix(CodeQL Go scan): bump Go to 1.22.5 and add wrapper-script tracer Jun 9, 2026
Rimobul
Rimobul previously approved these changes Jun 10, 2026
@nechvatalp nechvatalp merged commit dd0480f into dev Jun 10, 2026
18 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the Azure Pipelines configuration to make CodeQL’s Go extraction work reliably for this repository by using a supported Go toolchain and ensuring the CodeQL tracer can observe go build executions across all packages.

Changes:

  • Bump the pipeline Go toolchain from 1.13.5 to 1.22.5 to satisfy CodeQL Go extractor requirements.
  • Disable cgo at the job level (CGO_ENABLED: 0) to avoid toolchain/header issues on the Mariner-2 hosted agent.
  • Replace the Go build task with a single Bash step that installs a go wrapper on PATH and runs go build ./... to cover all subpackages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread azure-pipelines.yml
Comment on lines +59 to +62
# Go 1.21 made the toolchain statically linked, so the CodeQL Go
# the database ends up empty. The fix is to put a thin extractor's
# preload tracer can no longer intercept `go` calls and wrapper script
# ahead of the real `go` on PATH and invoke `go build` from the SAME script step
Comment thread azure-pipelines.yml
Comment on lines +67 to +70
WHICH_GO="$(which go)"
cat > "$WORKAROUND_DIR/go" <<EOF
#!/bin/bash
exec "$WHICH_GO" "\$@"
Comment thread azure-pipelines.yml
EOF
chmod +x "$WORKAROUND_DIR/go"
export PATH="$WORKAROUND_DIR:$PATH"
echo "Using go wrapper at: $(which go)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants