Repository navigation
ci(hrr): run C++ CodeQL on the capture code - #13888
andraghetti wants to merge 2 commits into
Conversation
The ROCm security baseline skips C/C++ CodeQL in repositories with more than 1,000 C/C++ files, so the HRR capture writer has no scan in CI and the world-writable file creation fixed in #12253 could come back unnoticed. hrr-capture-codeql.yml runs on changes under projects/clr/hipamd/src/hrr and on develop. In the public rocm/dev-ubuntu-22.04:7.2 image it traces a build of the four capture sources alone, with HIP_HRR_CAPTURE_ENABLED and the flags amdhip64 gives them, runs security-extended, keeps only results located in projects/clr/hipamd/src/hrr (the rocclr headers they include raise nine alerts that are not capture's), uploads the SARIF to code scanning and fails if any capture alert is left. Capture has none on develop, so any one is new. The cpp/path-injection false positive from the 1 October one-off run does not reproduce with CodeQL 2.27.2; the workflow says how to dismiss it if it does. Jira: AIRUNTIME-2873
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
There was a problem hiding this comment.
🟡 Changes recommended
The filtering step uses Bash-only syntax under the container’s default shell, blocking SARIF uploads.
1 open issue
What changed in this PR
Adds focused C++ CodeQL coverage for HRR capture, filling the gap left by the repository-wide security baseline.
Changes:
- Adds a containerized workflow for capture changes and develop baselines.
- Compiles capture sources independently and filters results to capture locations.
- Adds nine filter tests and fails the job when capture alerts remain.
| File | Description |
|---|---|
.github/workflows/hrr-capture-codeql.yml |
Orchestrates scanning, filtering, upload and alert gating. |
.github/scripts/tests/hrr_capture_codeql_filter_test.py |
Tests filtering and command-line output. |
.github/scripts/hrr_capture_codeql_filter.py |
Retains and counts capture-related SARIF results. |
.github/scripts/hrr_capture_codeql_build.sh |
Compiles capture sources for CodeQL tracing. |
Review effort: Balanced
|
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. |
danielbolsson
left a comment
There was a problem hiding this comment.
Checked 30cfa63: the build script compiles only projects/clr/hipamd/src/hrr/*.cpp, the filter keeps results with a primary location in that directory (and those with none), its tests cover the prefix-sharing and absolute-URI cases, and the action pins resolve. Nothing blocking.
|
Closed. HRR will wait for the ROCm security baseline to turn on C/C++ CodeQL for rocm-systems, which needs larger runners. |

Motivation
The ROCm security baseline skips C/C++ CodeQL in repositories with more than 1,000 C/C++ files. So rocm-systems gets no C/C++ scan, and HRR capture gets none either. A one-off run on 1 October found world-writable file creation in the capture writer. #12253 fixed it. Nothing in CI stops it from coming back. This change adds a C++ CodeQL job that scans the capture code and nothing else.
Technical Details
.github/workflows/hrr-capture-codeql.ymlruns on pull requests and develop pushes that touchprojects/clr/hipamd/src/hrr/**. It also runs when its own files change. The develop run gives code scanning a base, so it can call a PR alert new.rocm/dev-ubuntu-22.04:7.2, pinned by digest, for the ROCm headers. Init, build and analyze all run in this container, because the tracer only sees compilers started in its own environment.actions/checkoutdownloads the whole repository instead of the sparse tree..github/scripts/hrr_capture_codeql_build.shcompiles the.cppfiles inprojects/clr/hipamd/src/hrrwithHIP_HRR_CAPTURE_ENABLED. There are five on this base. A new file is picked up without a change here. It uses the definitions and include paths that amdhip64 and rocclr give them on Linux. It does not run CMake and builds nothing else in hipamd or rocclr.security-extendedsuite, which iscpp-security-extendedfor C++..github/scripts/hrr_capture_codeql_filter.pykeeps only results whose primary location is underprojects/clr/hipamd/src/hrr/. CodeQLpathsfilters do not apply to C/C++, so the filtering happens on the SARIF. The capture files include rocclr headers, which raise nine alerts of their own. Those are not this job's. A result with no location is kept./hrr-capture. The job then fails if any capture alert is left. Capture has none on develop, so any alert is new.cpp/path-injectionfalse positive inwrite_code_object(). It does not reproduce with CodeQL 2.27.2, so nothing is excluded for it. The workflow header says to dismiss it once in code scanning if it returns: the file name is a hex hash of the code object..github/scripts/tests/hrr_capture_codeql_filter_test.pyhas nine unittest cases for the filter. They use unittest because the image has Python but no pytest. The job runs them before the scan.hrr-capture-codeql*orhrr_capture_codeql_*. A replay CodeQL job (AIRUNTIME-2874) can then add its own files without conflicts.Issue Tracking
JIRA ID: AIRUNTIME-2873
Test Plan
The workflow cannot run without a push, so I ran its commands by hand on gbt350. They ran on CPU in the same image, with CodeQL CLI 2.27.2. The commit was
0062c180fe, on develop 25c7cab4d1. The MI350X gate did not run, because the change touches no C++, CMake or capture code.cpp-security-extendedanalysis, then the filter.projects/clr/hipamd/src/hrrfrom before fix(hrr): keep capture archives private and refuse planted links #12253 (83201fcd49^). I also ran the filter tests with a filter that keeps every result. Both ran on the earlier base 8394703, with commit549f9a32b3. The rebase changed neither the filter nor its tests.Test Result
elfio.hpp,device.hpp,command.hppcpp/world-writable-file-creationinhip_capture_writer.cpp(lines 450, 566, 1303), job failsNot tested: the GitHub side. That covers checkout and the CodeQL actions inside the container, the upload to code scanning, the alert display on a PR, and uploads from fork PRs. The first run of this PR will exercise them. Windows-only branches of the capture code are not compiled, so they are not scanned.
Submission Checklist