CI: Add CodeQL workflow for code scanning - #104
Open
pniedzielski wants to merge 1 commit into
Open
pniedzielski wants to merge 1 commit into
pniedzielski wants to merge 1 commit into
Conversation
Contributor
Author
|
Hm... to test this, we need to disable the default codeql workflow... |
Contributor
Author
|
Swapped to the CodeQL advanced configuration. Unfortunately, this turns off CodeQL on |
pniedzielski
force-pushed
the
codeql
branch
2 times, most recently
from
September 18, 2026 22:14
660ce66 to
1ba5ed8
Compare
|
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:
For more information about GitHub Code Scanning, check out the documentation. |
pniedzielski
force-pushed
the
codeql
branch
from
September 21, 2026 22:32
1ba5ed8 to
7936bca
Compare
This repository’s CodeQL analysis had been running under GitHub’s
Default setup, which worked fine for the `actions` and `python`
languages, since neither needs a build. It never analyzed our pure
C++ layer, though: this repository wraps libbmq in hand-written C++
under `src/cpp` (`pybmq::Session` and friends), which the pure Python
layer under `src/blazingmq` reaches through a thin Cython glue layer
(`_ext.pyx`). Default setup’s autobuilder has no way to know that
building any of this requires first building BlazingMQ itself as a
dependency, so `c-cpp` analysis was silently producing nothing.
This patch adds `codeql.yaml`, an advanced (workflow-based) CodeQL
configuration that takes over analysis for all three languages. For
the three languages, we make two jobs:
1. For GitHub Actions and for Python, the workflow includes a
`analyze-light` job that replicates the default setup, as these
languages continue to need no build.
2. For C++, this workflow builds the extension module before running
CodeQL against it. In order to do so, this workflow reuses the
same “build BlazingMQ as a dependency” job that `build.yaml`
uses, kept identical (including its cache key) so the two
workflows share one set of cached build artifacts, then builds
the extension module before running CodeQL against it.
The resulting database necessarily includes Cython-generated C++
code as well as the vendored BDE/NTF/BlazingMQ headers pulled in
from the dependency build, so to avoid false findings from the
dependencies, or from generated Cython code we can do little
about, this patch strips out alerts from code not located in
`src/cpp` using `jq`. This trick is a little hacky, but the
alternatives don’t really get us what we want. CodeQL does
provide a `paths-ignore` config option, which we could use to
ignore `_ext.cpp`, but this only takes effect when using
`build-mode: none`. However, that would prevent CodeQL from
resolving BDE and BlazingMQ types (`bdlbb::Blob`,
`bmqa::Message`, …) that comprise most of the surface area of
`src/cpp` code, making the static analysis less than useful. The
cleanest thing to do is to build everything, and then filter out
the findings that are not relevant to us.
GitHub does not allow a Default and an advanced setup to run side by
side, even for different languages, so landing this patch also
requires disabling this repository’s Default CodeQL setup.
Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
pniedzielski
force-pushed
the
codeql
branch
from
September 21, 2026 22:39
7936bca to
9a6b9be
Compare
pniedzielski
marked this pull request as ready for review
September 21, 2026 22:39
This branch has not been deployed
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.
This repository’s CodeQL analysis had been running under GitHub’s Default setup, which worked fine for the
actionsandpythonlanguages, since neither needs a build. It never analyzed our pure C++ layer, though: this repository wraps libbmq in hand-written C++ undersrc/cpp(pybmq::Sessionand friends), which the pure Python layer undersrc/blazingmqreaches through a thin Cython glue layer (_ext.pyx). Default setup’s autobuilder has no way to know that building any of this requires first building BlazingMQ itself as a dependency, soc-cppanalysis was silently producing nothing.This patch adds
codeql.yaml, an advanced (workflow-based) CodeQL configuration that takes over analysis for all three languages. For the three languages, we make two jobs:For GitHub Actions and for Python, the workflow includes a
analyze-lightjob that replicates the default setup, as these languages continue to need no build.For C++, this workflow builds the extension module before running CodeQL against it. In order to do so, this workflow reuses the same “build BlazingMQ as a dependency” job that
build.yamluses, kept identical (including its cache key) so the two workflows share one set of cached build artifacts, then builds the extension module before running CodeQL against it.The resulting database necessarily includes Cython-generated C++ code as well as the vendored BDE/NTF/BlazingMQ headers pulled in from the dependency build, so to avoid false findings from the dependencies, or from generated Cython code we can do little about, this patch strips out alerts from code not located in
src/cppusingjq. This trick is a little hacky, but the alternatives don’t really get us what we want. CodeQL does provide apaths-ignoreconfig option, which we could use to ignore_ext.cpp, but this only takes effect when usingbuild-mode: none. However, that would prevent CodeQL from resolving BDE and BlazingMQ types (bdlbb::Blob,bmqa::Message, …) that comprise most of the surface area ofsrc/cppcode, making the static analysis less than useful. The cleanest thing to do is to build everything, and then filter out the findings that are not relevant to us.GitHub does not allow a Default and an advanced setup to run side by side, even for different languages, so landing this patch also requires disabling this repository’s Default CodeQL setup.