Static analysis report#
The CLI used by bazel run :docs and :live_preview summarizes SARIF files
before Sphinx starts and writes <build-output>/static_analysis_summary.json.
The score-static-analysis-report directive in the module verification report
renders this summary per component.
Input#
The CLI reads static-analysis-report/ relative to the workspace root:
*.sarifdirectly in the directory describe the workspace itself.Every file in a subdirectory named after a repository, e.g.
static-analysis-report/score_baselibs+/, describes that repository analysed as its own Bazel workspace. Its paths are relative to that repository, and findings outside it are ignored. Tools need not merge their output, e.g. the per-target reports of rules_lint can be copied as they are.
Empty and non-SARIF files are skipped. Results of kind pass or
notApplicable are not findings.
Processing#
Path cleanup.
uriBaseIdchains are resolved. Bazel prefixes (.../execroot/<workspace>/,./,bazel-out/<config>/bin/) are removed, and a_virtual_includescopy of a header is mapped back to its source file.De-duplication. A finding is identified by tool, rule, file, line, column and message. Linters running per target report a shared header once per including target; it is counted once and stays open if any copy is open.
Rule identification. See Rule identification.
Classification. See Classification.
Assignment. Findings are assigned to components through the same code-file lists as the coverage report. Findings in files no component owns are counted as unassigned. Findings with an accepted SARIF suppression are counted as suppressed and not classified.
Rule identification#
The result’s
ruleId(orrule.id), as written by CodeQL or clippy.Otherwise, for tools whose rules_lint SARIF has no rule ID, the message text:
clang-tidy: the check name in brackets at the end, e.g.
... [bugprone-use-after-move]givesbugprone-use-after-move.ruff: the code at the start, e.g.
S603 ...givesS603.
Otherwise
unknown.
Classification#
Every finding gets one of the classes required by
gd_req__verification_sca_classification: critical, high, medium or low.
The sources below are checked in order; the first one that applies decides.
# |
Source |
critical |
high |
medium |
low |
|---|---|---|---|---|---|
1 |
Rule property |
9.0 or more |
7.0 to 8.9 |
4.0 to 6.9 |
below 4.0 |
2 |
Rule tag |
mandatory |
required |
advisory |
|
3a |
clang-tidy check family |
|
|
|
|
3b |
ruff code prefix |
|
|
|
|
4 |
SARIF |
|
|
|
Only security-severity yields critical. A clang-tidy check of another family
(e.g. llvm-) falls through to the level. The clang-tidy and ruff mappings are
preliminary: rules_lint reports every clang-tidy check as warning and every
ruff rule as error, so their level says nothing.
MISRA obligation#
MISRA C++:2023 assigns every guideline an obligation: mandatory (no deviation permitted), required (deviation only with a documented deviation record) or advisory (recommended). The CodeQL coding standards packs write it as a rule tag, for example:
{
"id": "cpp/misra/a-mixed-use-macro-argument-subject-to-expansion",
"properties": {
"tags": [
"external/misra/id/rule-19-3-3",
"external/misra/obligation/required"
]
},
"defaultConfiguration": { "level": "error" }
}
This rule is classified medium. Its level error would give high, but the
obligation is checked first.
Supported tools#
Any tool writing SARIF is supported; without a more specific source its findings are classified by level.
Tool |
Rule ID |
Classified by |
|---|---|---|
CodeQL with MISRA coding standards packs |
|
MISRA obligation; |
clang-tidy (rules_lint, driver |
message text |
check family, else level |
ruff (rules_lint) |
message text |
code prefix |
clippy (rules_lint) |
|
level (rules_lint reports |
other SARIF tools |
|
|
Stability#
The class depends only on the rule: its metadata, the tool, the rule ID and the SARIF level. The same rule gets the same class in every run, independent of file, component, safety rating or number of findings. It changes only with
a new version of the tool or rule pack that changes the rule’s metadata,
a new version of docs-as-code that changes the mappings above, or
for tools classified by level, a tool configuration that changes the reported level (e.g. a clippy lint set to
denyreportserror).
Output#
static_analysis_summary.json lists the tools with their number of findings,
the number of unassigned findings and, per component (primary Need), the
selected and affected files, the open findings per class, the suppressed
findings and the ten most critical rules.
In the module verification report, .. score-static-analysis-report:: <need id>
shows the open findings per class as a bar chart; with :rules: it shows the
table of the most critical rules. Without any SARIF input it states that no
static analysis data is available.