ci/codeql: ignore bundled libc++ headers in CodeQL analysis#44600
Closed
ci/codeql: ignore bundled libc++ headers in CodeQL analysis#44600
Conversation
Agent-Logs-Url: https://github.com/envoyproxy/envoy/sessions/6bc67f1c-5f73-403e-aa63-3bc189986d89 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CodeQL alert cpp/new-free-mismatch in vector allocator
ci/codeql: ignore bundled libc++ headers in CodeQL analysis
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CodeQL alert #1881 (
cpp/new-free-mismatch) repeatedly opens/closes onmainwith locationbin/clang18.1.8/include/c++/v1/vector:492— a false positive inside libc++'sstd::vectorallocator path. The alert yo-yos because the CodeQL workflows download and untar the clang toolchain intobin/clang18.1.8/inside$GITHUB_WORKSPACE, causing CodeQL to treat bundled libc++ headers as project source files.Changes
.github/codeql/codeql-config.yml(new): CodeQL config with a narrowly-scopedpaths-ignoretargeting only libc++ v1 headers (**/include/c++/v1/**). Intentionally does not broaden tobin/**orinclude/c++/**(libstdc++). Includes a comment explaining the rationale and scope constraint.codeql-push.yml,codeql-daily.yml: Addconfig-file: ./.github/codeql/codeql-config.ymlto theInitialize CodeQLstep in both workflows so push-time and weekly scans use the same exclusion and the alert cannot flip state across the two runs.Original prompt
Background
CodeQL alert #1881 (
cpp/new-free-mismatch, CWE-401) repeatedly opens/reappears/closes onmain. Its location is:That path is libc++ from the clang toolchain that both CodeQL workflows download and untar into the workspace:
The bazel build is then invoked with
--repo_env=BAZEL_LLVM_PATH="$(realpath bin/clang18.1.8)", which surfaces libc++ headers through the compile commands CodeQL observes. The alert is a dataflow-precision false positive insidestd::vector's allocator path — there's nothing to fix in Envoy source, and no Envoy code change can retire it. Its yoyoing "Fixed/Reappeared" history (observable on the alert page) is a function of which 1–3 targets the push workflow happens to build, not of any code change.What to do
Add a CodeQL configuration file in the repo that tells CodeQL to ignore results whose location is inside the bundled libc++ headers, and reference that config from both CodeQL workflows via
github/codeql-action/init'sconfig-fileinput. Keep the scope as narrow as possible:include/c++/v1/**tree shipped in the downloaded clang bundle. Do not broaden tobin/**,include/c++/**(libstdc++), or any rule-wide exclusion..github/codeql/rather than inliningpaths-ignoreblocks into each workflow. The config must live in a single place and be referenced (not duplicated) by both workflows.Files to change
1. New file:
.github/codeql/codeql-config.ymlCreate with contents similar to:
The comment block above MUST be preserved so reviewers/future-maintainers understand why the exclusion exists and why it's scoped the way it is.
2. Modify
.github/workflows/codeql-push.ymlLocate the existing
Initialize CodeQLstep:Add a
config-fileinput pointing at the new file:Do not change any other part of the workflow.
3. Modify
.github/workflows/codeql-daily.ymlApply the identical change to the corresponding
Initialize CodeQLstep in the daily workflow. Both workflows must reference the same config file so that push-time and weekly scans agree on what is in-scope; otherwise the alert would keep flipping state across the two runs.Do not change any other part of the workflow.
Constraints
source/,test/,contrib/, or similar. This PR is CI-configuration only.paths-ignore: ['bin/**']or anything that would hide genuine findings in Envoy source that merely happens to live under a similarly named path.query-filters/ global rule exclusions. Keep the mechanism topaths-ignoreagainst libc++ v1 headers only.github/codeql-action/initexactly as it currently is in each workflow. No action-version bumps.config-fileMUST be./.github/codeql/codeql-config.yml(leading./is conventional for the CodeQL action's resolver).Verification
yamllint(or equivalent) should pass on the new file and the modified workflows.config-file: ./.github/codeql/codeql-config.yml) under...This pull request was created from Copilot chat.