codeql: run noop JS analysis on every PR/push to satisfy Scorecard SAST check#44769
Closed
codeql: run noop JS analysis on every PR/push to satisfy Scorecard SAST check#44769
Conversation
…rd SAST check
- Remove paths: filter from on.push (workflow now triggers on every push to
main and every PR to main, not just those touching include/** or source/common/**)
- Add 'Detect C++ changes' step that sets CPP_CHANGED=true|false by diffing
HEAD against main (PR) or HEAD^1 (push) over source/ and include/
- Guard bind-mounts, free-disk, second-checkout, get-build-targets,
install-deps, build, and clean-artifacts with env.CPP_CHANGED == 'true'
- Split Initialize CodeQL into two conditional steps:
cpp path (CPP_CHANGED==true): languages: cpp + existing config-file
noop path (CPP_CHANGED!=true): languages: javascript, no config-file
- Guard Build with env.BUILD_TARGETS != '' in addition to CPP_CHANGED==true
so that if bazel query yields nothing analyze still runs
- Remove 'Set default build target' step and assert_lib fallback entirely
- Keep 'Perform CodeQL Analysis' unconditional so every run posts a
github-code-scanning check run with conclusion 'success' (Scorecard SAST)
- Add explanatory comments on the early checkout and the JS noop init step
Agent-Logs-Url: https://github.com/envoyproxy/envoy/sessions/e5515741-10c2-462f-83b5-8636d7c72991
Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update CodeQL trigger to run on all PRs
codeql: run noop JS analysis on every PR/push to satisfy Scorecard SAST check
Apr 30, 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.
OpenSSF Scorecard's SAST check iterates the last ~30 merge commits and counts how many have a
github-code-scanningcheck run with conclusionsuccess/neutral. Thepaths:filter onon.pushmeant commits not touchinginclude/**/source/common/**produced no check run, penalizing the SAST score and generating alert #54.Changes
Remove
paths:filter fromon.push— workflow now triggers on every push tomainand every PR, unconditionally.Add "Detect C++ changes" step — diffs
HEADagainstmain(PR) orHEAD^1(push) oversource/andinclude/, setsCPP_CHANGED=true|false.Noop path (
CPP_CHANGED=false) — runs onlycodeql-action/initwithlanguages: javascript(no compiler, no build toolchain, ~30s) thenanalyze. Skips bind-mounts, disk cleanup, clang install, bazel build, and artifact cleanup entirely.C++ path (
CPP_CHANGED=true) — existing behavior preserved exactly: clang install,bazel buildagainst computed targets,initwithlanguages: cpp+codeql-config.yml,analyze.Perform CodeQL Analysisalways runs — this is the step that posts thegithub-code-scanningcheck run Scorecard requires.Remove
assert_libfallback — the expensive default build target is dropped. TheBuildstep is additionally guarded byenv.BUILD_TARGETS != ''; if bazel query yields nothing despite C++ changes, build is skipped butanalyzestill runs.Original prompt
Background
.github/workflows/codeql-push.ymlis currently gated at the trigger level:Because most PRs do not touch
source/common/**orinclude/**, CodeQL produces nogithub-code-scanningcheck run for them. OpenSSF Scorecard's SAST check (source) iterates the last ~30 merge commits and counts how many have a check run from thegithub-code-scanningapp with conclusionsuccess/neutral. Commits without such a check run drop the SAST score, and Scorecard's SARIF gets uploaded to code scanning, producing alerts like https://github.com/envoyproxy/envoy/security/code-scanning/54.Goal
Make
github/codeql-action/analyzeexecute (successfully) on every PR andmainpush, while doing no expensive work when the change does not touch C++ source. Do not run a C++ build for irrelevant changes —assert_libis too expensive.Approach
Edit
.github/workflows/codeql-push.ymlas follows:Remove the
paths:filter fromon.pushso the workflow triggers on every push tomainand every pull_request. Keep the existingbranches:filters.Add an early step that detects whether the diff against
main(orHEAD^1for push) contains any files undersource/**orinclude/**. Set a job-level output / env var, e.g.CPP_CHANGED=true|false. Reuse the existinggit diff --name-onlymachinery already present in the "Get build targets" step rather than adding a third-party action.Branch the workflow on
CPP_CHANGED:CPP_CHANGED == 'true'(current behavior): runinitwithlanguages: cpp, install clang, run thebazel buildstep against the computedBUILD_TARGETS, thenanalyze. Keep the existing logic intact.CPP_CHANGED == 'false'(the noop path): runinitwithlanguages: javascript(abuild-mode: nonelanguage — no compiler/toolchain install, no bazel build, finishes in ~30s) and thenanalyze. Skip clang install,Get build targets,Build,Clean Artifacts,Free disk space, and thebind-mountsstep entirely on this path by guarding them withif: env.CPP_CHANGED == 'true'.Ensure the
Initialize CodeQLandPerform CodeQL Analysissteps always run. They are the steps Scorecard cares about — they post thegithub-code-scanningcheck run.The existing
config-file: ./.github/codeql/codeql-config.ymlis C++-specific (path filters, queries for cpp). It's fine to keep applying it on the cpp path. On the javascript noop path, omit theconfig-file(or pass nothing) so default JS queries run against whatever JS happens to live in the repo. Do not add new javascript queries — the goal is a fast, valid analysis, not findings.Remove the now-unused
MINIMAL_BUILD_TARGET=//source/common/common:assert_libfallback, since the cpp path will only execute when there are real changes that produce realBUILD_TARGETS. IfBUILD_TARGETSis empty on the cpp path (e.g. only doc/comment-level changes insidesource/), keep a tiny safe fallback or simply skip analyze — but prefer: ifCPP_CHANGED=truealways run analyze with whatever bazel produced, falling back to the smallest practical target only if absolutely needed.Acceptance criteria
mainand every pull_request tomainproduces agithub-code-scanningcheck run with conclusionsuccess(orneutral).bazel build.source/**orinclude/**retain the current C++ CodeQL behavior unchanged (same languages, same config file, same build command)..github/workflows/codeql-daily.ymlis unrelated and must not be modified..github/workflows/scorecard.ymlis unrelated and must not be modified.Files to edit
.github/workflows/codeql-push.yml(only)Reference
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: this one is annoying - we intentionally dont run codql on all commits - but then that is greating an alert and reducing our score - how to resolve
Assistant: The alert at
envoyproxy/envoy/security/code-scanning/54is being produced by the OpenSSF Scorecard workflow (.github/workflows/scorecard.yml), not by CodeQL itself. Scorecard's SAST check runs, sees that CodeQL doesn't analyze every PR/commit onmain, and uploads that finding as a SARIF result to GitHub code scanning — which is why it shows up under/security/code-scanning.There are really only two levers here, and the...
This pull request was created from Copilot chat.