Skip to content

Capture Trivy fix status and package class on vulnerability findings - #217

Merged
LarsLaskowski merged 4 commits into
mainfrom
claude/issue-207-1vrhhu
Jul 27, 2026
Merged

Capture Trivy fix status and package class on vulnerability findings#217
LarsLaskowski merged 4 commits into
mainfrom
claude/issue-207-1vrhhu

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Added Status to TrivyVulnerability and Target, Class and Type to TrivyResult.
  • TrivyVulnerabilityProvider now projects over (result, vulnerability) pairs instead of a bare SelectMany, so the block-level class and type are attributed to the vulnerabilities inside that block.
  • New VulnerabilityFixStatus enum (NotSet, Fixed, Affected, WillNotFix, FixDeferred, EndOfLife) with case-insensitive mapping from Trivy's status strings.
  • VulnerabilityAdvisoryData and VulnerabilityFinding carry FixStatus, PackageClass and PackageType; mapping added to VulnerabilityFindingConfiguration and persisted through migration Update7.
  • VulnerabilityEnrichmentService.UpdateFindingFromAdvisory copies the new values on both insert and update.

Why

"Fixable" was inferred solely from a non-empty FixedVersion, so an empty value could equally mean "upstream will not fix", "fix deferred", "end of life" or "the provider reported nothing". Trivy distinguishes these through its per-vulnerability Status field and the per-result-block Class/Type, but all of it was discarded on parse. Storing the provider's own values lets downstream features separate "you can fix this by updating the image" from "upstream has no fix" instead of guessing from a missing field.

Linked issues

Closes #207

Review notes

  • Finding identity is unchanged — the new values are deliberately not part of CreateFindingKey, so a re-scan after the migration updates existing rows rather than creating new ones.
  • Trivy's own unknown status maps to NotSet alongside unrecognized and missing values; consumers must treat NotSet as "no information" and fall back to the FixedVersion heuristic rather than reporting "not fixable".
  • Existing rows keep NotSet until the image is scanned again, since the migration only adds the columns.
  • DockerScoutVulnerabilityProvider and DefaultVulnerabilityProvider do not supply the data and leave the values at NotSet / null.

Follow-up work

None — surfacing the new values in the UI is left to the consuming feature.

claude and others added 4 commits July 27, 2026 17:39
Trivy reports a per-vulnerability Status and a per-result-block Class and
Type, all of which were discarded on parse. The Trivy payload records now
carry these values, the provider projects each vulnerability together with
its owning result block so the block-level classification is attributed
correctly, and the values flow through the advisory transport into the
persisted finding via migration Update7. Unknown or missing statuses map to
the new VulnerabilityFixStatus.NotSet, and the finding identity remains
AdvisoryId plus AffectedPackage so a re-scan does not duplicate rows.

Refs #207
The quality gate reported 72.9 percent coverage on new code because the
Update7 migration contributed 23 uncovered lines. Update7MigrationTests now
asserts the added columns, their defaults and the rollback following the
Update6 pattern, and MappingTests checks the new mapping and round-trip plus
the unchanged finding identity index. Additional tests cover blank and padded
Trivy block values, Docker Scout advisories leaving the fields unset, and a
reactivated finding taking over the reported values.

Refs #207
@sonarqubecloud

Copy link
Copy Markdown

@LarsLaskowski
LarsLaskowski merged commit 9e9c96e into main Jul 27, 2026
4 checks passed
@LarsLaskowski
LarsLaskowski deleted the claude/issue-207-1vrhhu branch July 27, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Capture Trivy finding status and package class to distinguish fixable from upstream-unfixable findings

2 participants