Skip to content

Capture Trivy fix status and package classification per finding - #218

Closed
LarsLaskowski wants to merge 1 commit into
mainfrom
claude/issue-207-vajkb5
Closed

Capture Trivy fix status and package classification per finding#218
LarsLaskowski wants to merge 1 commit into
mainfrom
claude/issue-207-vajkb5

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Parses the per-vulnerability Status and the per-result-block Class, Type and Target from the Trivy report and persists the fix status and package classification with each vulnerability finding.

  • TrivyVulnerability gains Status; TrivyResult gains Target, Class and Type.
  • TrivyVulnerabilityProvider projects each vulnerability together with its own result block instead of flattening with a bare SelectMany, so block-level values are attributed to the vulnerabilities inside that block. Blank block values are normalized to null.
  • New VulnerabilityFixStatus enum (NotSet, Fixed, Affected, WillNotFix, EndOfLife, FixDeferred), mapped case-insensitively from the Trivy status strings.
  • VulnerabilityAdvisoryData and VulnerabilityFinding carry FixStatus, PackageClass and PackageType; migration Update7 adds the three columns.
  • VulnerabilityEnrichmentService.UpdateFindingFromAdvisory copies the new values like the other mutable fields.

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, but the information was discarded on parse. Capturing it lets downstream features state upstream unfixability as a fact from the provider instead of inferring it from a missing field.

Linked issues

Closes #207

Review notes

  • Finding identity is unchanged — CreateFindingKey still uses AdvisoryId plus AffectedPackage, so a re-scan updates existing rows rather than creating new ones.
  • Trivy's own unknown status maps to NotSet, as do unrecognized and missing status strings. Consumers must treat NotSet as "no information" and fall back to the FixedVersion heuristic rather than reporting "not fixable".
  • The values only become visible after a re-scan; existing rows keep NotSet and null until then.
  • Docker Scout and the default provider supply none of this data and leave the fields unset.

Follow-up work

None

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 own result block so the block-level class and type are attributed
correctly, and the values travel through the advisory transport into the
new FixStatus, PackageClass and PackageType columns added by migration
Update7. Unrecognized and unknown status strings fall back to NotSet, and
finding identity stays AdvisoryId plus AffectedPackage so a re-scan updates
existing rows instead of duplicating them. Refs #207
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
67.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@LarsLaskowski

Copy link
Copy Markdown
Owner Author

PR was created twice

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