bug(sarif): SARIF report output silently drops container image vulnerability runs in combined scans
Description
When running Kubescape with --format sarif in a combined scan that evaluates both cluster/workload posture and container images (e.g. scans where both posture and container image scanning data are present), all container image vulnerability runs are silently omitted from the SARIF report output.
While the OASIS SARIF 2.1.0 specification natively supports multiple runs in a single document (report.Runs), SARIFPrinter.ActionPrint in core/pkg/resultshandling/printer/v2/sarifprinter.go exclusively branches on opaSessionObj:
if opaSessionObj == nil {
if len(imageScanData) == 0 {
return fmt.Errorf("failed to write results in sarif format: no data provided")
}
// image scan
if err := sp.printImageScan(imageScanData); err != nil {
logger.L().Ctx(ctx).Error("failed to write results in sarif format", helpers.Error(err))
return fmt.Errorf("failed to write results in sarif format: %w", err)
}
} else {
// configuration scan
if err := sp.printConfigurationScan(ctx, opaSessionObj); err != nil {
logger.L().Ctx(ctx).Error("failed to write results in sarif format", helpers.Error(err))
return fmt.Errorf("failed to write results in sarif format: %w", err)
}
}Because of this if/else block, whenever opaSessionObj != nil, imageScanData is completely ignored and all image vulnerability results are dropped from the emitted SARIF file.
Environment
OS: macOS / Linux
Version: v3.0.x / master
Steps To Reproduce
- Execute a scan with both posture scan and container image scan enabled, outputting to SARIF format:
kubescape scan framework nsa --include-images --format sarif --output report.sarif - Inspect the generated
report.sariffile. - Observe that only the posture scan run (
report.runs[0]) is present. Zero container image vulnerability runs or Grype/vulnerability findings are included in therunsarray.
Expected behavior
In combined scans, the SARIF report should include both the configuration/posture scan run and the container image vulnerability runs in the top-level runs array, allowing downstream consumers (e.g. GitHub Code Scanning, IDE viewers, and security dashboards) to consume posture and image vulnerability findings in a single report.
Actual Behavior
Image vulnerability runs are completely omitted from the SARIF output during combined scans.
Additional context
In sarifprinter.go, image scanning already builds well-structured SARIF runs with patched tool driver names, VEX status enrichment, and finding fingerprints. By allowing writeConfigurationSARIF to accept additional runs and appending them to the streamed runs array, combined scans can emit both posture and image runs seamlessly without breaking backward compatibility or standalone scan behaviors.
Source: kubescape/kubescape