Skip to main content

Module sarif

Module sarif 

Source
Available on crate feature sarif only.
Expand description

SARIF 2.1.0 export for Report and MultiReport.

Maps fail-verdict and warn-verdict CheckResults to SARIF results. Pass and skip checks are intentionally NOT emitted — SARIF is a defect report format, not a test-result format. Use crate::junit (or the native JSON schema) when you need every check.

Severity → SARIF level:

SeveritySARIF level
Critical, Errorerror
Warningwarning
Infonote
None (unreachable for fail/warn)none

Evidence payloads of kind EvidenceData::FileRef become SARIF physicalLocation entries with region.startLine / region.endLine when the FileRef carries a line range. Line numbers below 1 are not valid SARIF and are left out.

SARIF requires artifactLocation.uri to be a URI reference, so the file path is converted: backslashes become /, absolute paths become file:// URIs (C:\src\lib.rs becomes file:///C:/src/lib.rs, \\server\share\x.rs becomes file://server/share/x.rs, /home/x.rs becomes file:///home/x.rs), relative paths stay relative, and characters that are not allowed in a URI (spaces, %, non-ASCII) are percent-encoded.

For a MultiReport, each constituent Report becomes a separate SARIF run, so consumers can tell which producer emitted which finding.

Available with the sarif feature.

Functions§

multi_to_sarif
Render multi as a SARIF 2.1.0 document with one run per constituent Report.
to_sarif
Render report as a SARIF 2.1.0 document.