Skip to content

Commit f517494

Browse files
committed
Merge remote-tracking branch 'upstream/main' into maintenance/jsonnet-format-workflows
2 parents 609167e + dcb6a5e commit f517494

File tree

13 files changed

+497
-68
lines changed

13 files changed

+497
-68
lines changed

.github/CodeQL-README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
```markdown
21
# CodeQL scanning for this repository
32

43
This repository uses C++ (C++20 / moving to C++23) built with CMake under the phlex-src directory, plus some Python and CI bits (Bash). The repository includes a CodeQL GitHub Actions workflow on branch `copilot/codeql-workflow` that:
@@ -9,44 +8,51 @@ This repository uses C++ (C++20 / moving to C++23) built with CMake under the ph
98
- Uses RelWithDebInfo build type in CI so debug symbols are present while keeping realistic optimization.
109

1110
Important workflow-specific notes
11+
1212
- The workflow sets `autobuild: false` during the CodeQL init so the repository's own configure / build steps run. This is intentional: the Phlex build actions are used to build exactly what you ship.
1313
- The workflow tries to locate and copy a compile_commands.json (from `phlex-src/build/` or `phlex-build/`) to the workspace root so diagnostic tools and manual inspection have a predictable path.
1414
- The workflow runs inside the repository container image (if provided) so it uses the same toolchain and environment your CI expects.
1515

1616
How the workflow is targeted at phlex-src
17+
1718
- The CMake configure & build steps are run with `-S phlex-src -B phlex-src/build` (or your Phlex-specific helpers are invoked in that context) so compile units, compiler flags, and generated compile_commands reference files under `phlex-src`.
1819
- The CodeQL config (`.github/codeql/codeql-config.yml`) contains an explicit `paths.include: - phlex-src/**` entry and excludes common vendor/build directories. This ensures CodeQL focuses on the intended code and not third-party or generated artifacts.
1920

2021
Recommended build type for CodeQL runs
22+
2123
- Use RelWithDebInfo (the workflow is already set to use this). Rationale:
2224
- RelWithDebInfo produces debug symbols (required for better mapping of findings to source/stack traces) while compiling with optimizations closer to production.
2325
- Pure Debug (-O0 -g) can be used for local triage of tricky alerts but is slower and sometimes produces analysis results that differ from optimized builds.
2426
- Release (no debug info) is not recommended for CodeQL because missing debug symbols reduce the quality of evidence and traces in findings.
2527

2628
How to run CodeQL locally (examples)
27-
1. Install the CodeQL CLI: https://codeql.github.com/docs/codeql-cli/getting-started/
29+
30+
1. Install the CodeQL CLI: <https://codeql.github.com/docs/codeql-cli/getting-started/>
2831
2. Create a C++ database for the phlex-src tree (example):
2932
- From repository root:
3033
codeql database create codeql-db --language=cpp --command="cmake -S phlex-src -B phlex-src/build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake --build phlex-src/build -- -j$(nproc)"
3134
3. Analyze the database:
3235
- codeql database analyze codeql-db --format=sarifv2 --output=results-cpp.sarif github/codeql/cpp-security-and-quality
3336
4. Python example (if you need to build a Python DB):
34-
- codeql database create codeql-python-db --language=python --command="python3 -m pip install -r phlex-src/requirements.txt"
37+
- codeql database create codeql-python-db --language=python --command="python3 -m pip install -r phlex-src/requirements.txt"
3538
- codeql database analyze codeql-python-db --format=sarifv2 --output=results-py.sarif github/codeql/python-security-and-quality
3639
5. Open the SARIF in VS Code via the CodeQL extension or upload results via the GitHub UI.
3740

3841
Triage tips and workflows
42+
3943
- Start with high-confidence, high-severity alerts.
4044
- Use the evidence shown in the CodeQL alert to locate the vulnerable trace. RelWithDebInfo gives better evidence than Release.
4145
- When marking false positives, add a short rationale in the Code Scanning UI (this helps future auditors).
4246
- If the repo has many historical findings, consider a triage sprint to baseline or create a SARIF baseline to ignore existing alerts temporarily while blocking new ones.
4347

4448
How to add or change query packs
49+
4550
- The repository currently selects the language security-and-quality packs for C++ and Python. That is a good default.
4651
- If you want to add additional packs (experimental or specialized) you can:
4752
- Edit `.github/codeql/codeql-config.yml` and add additional packs there (use the canonical pack name), or
4853
- Add them to the init step in the workflow (`with: queries:`).
4954
- Example of adding packs in the workflow init:
55+
5056
```yaml
5157
uses: github/codeql-action/init@v4
5258
with:
@@ -59,12 +65,14 @@ How to add or change query packs
5965
```
6066
6167
Action-specific / workflow scanning
68+
6269
- There are CodeQL query packs that specifically analyze GitHub Actions workflow files (YAML) to find insecure patterns (for example: unsafe use of secrets, untrusted inputs in workflow run steps, usage of unpinned actions, etc.). If you rely on custom workflows or pass secrets/inputs to actions, consider enabling the GitHub Actions query pack if it is available in your CodeQL pack index.
6370
- To discover whether an official GitHub Actions pack exists or to find its exact name, see the CodeQL packs index (the canonical source) or search the public CodeQL repository:
64-
- https://github.com/github/codeql/tree/main/packs
71+
- <https://github.com/github/codeql/tree/main/packs>
6572
- Search for "github-actions" or "actions" in the CodeQL repo to find action-related packs and their exact pack names.
6673
6774
Recommended query packs for this repository (starting point)
75+
6876
- github/codeql/cpp-security-and-quality
6977
- Purpose: Core security and quality queries for C and C++ codebases. Good coverage of common memory safety, API misuse, and typical C/C++ pitfalls.
7078
- Why: Phlex is primarily C++, so this pack is the most important starting point.
@@ -73,6 +81,7 @@ Recommended query packs for this repository (starting point)
7381
- Why: Phlex contains some Python; include this pack so those files are analyzed.
7482
7583
Other useful pack categories to consider
84+
7685
- Language experimental packs (e.g., "cpp-experimental" / "python-experimental")
7786
- These provide newer/experimental queries that are not yet in the stable security-and-quality pack. Use cautiously: they can produce more findings and more false positives.
7887
- Action/workflow packs (GitHub Actions specific)
@@ -81,15 +90,17 @@ Other useful pack categories to consider
8190
- If Phlex heavily uses a certain third-party library that has its own pack, consider enabling it to get library-specific rules.
8291
8392
How to find the exact pack names and descriptions
93+
8494
- Official source: the GitHub CodeQL packs and QL repos:
85-
- https://github.com/github/codeql/tree/main/packs
86-
- https://github.com/github/codeql/tree/main/ql
95+
- <https://github.com/github/codeql/tree/main/packs>
96+
- <https://github.com/github/codeql/tree/main/ql>
8797
- CodeQL CLI (partial support for pack discovery):
8898
- You can use `codeql pack` and `codeql resolve` commands to inspect installed packs. The CodeQL CLI documentation shows usage for installing and listing packs.
8999
- GitHub docs:
90100
- Code scanning docs and the CodeQL repo README often list recommended packs and query categories.
91101

92102
Suggested immediate next steps
103+
93104
1. Keep the current packs (cpp-security-and-quality and python-security-and-quality) enabled in `.github/codeql/codeql-config.yml` — they are the right baseline.
94105
2. Search the CodeQL packs index for any GitHub Actions pack and enable it if you want workflow-level checks.
95106
3. If you want more thorough coverage, enable the experimental packs temporarily in a non-blocking run, review the alerts, then decide whether to include them in CI permanently.
@@ -125,4 +136,3 @@ When a PR is opened from a fork, the `GITHUB_TOKEN` does not have permission to
125136
## Contact / Ownership
126137

127138
- Consider adding a CODEOWNERS file for the phlex-src tree so triage notifications reach the most appropriate maintainers.
128-
```

0 commit comments

Comments
 (0)