Skip to content

Keep image versions enriched by a run out of its stale finding pass - #213

Merged
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-205-ueqq91
Jul 27, 2026
Merged

Keep image versions enriched by a run out of its stale finding pass#213
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-205-ueqq91

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

VulnerabilityEnrichmentService.RefreshAsync now collects the identifiers of the image versions it enriched and passes them into DeactivateStaleFindingsAsync. A finding is only treated as stale when its image version is in neither the live inventory nor the processed set. LiveImageInventoryQueryService is unchanged.

Why

The enrichment step selects image versions with a broad predicate (ObservedImages.Any() || ContainerSnapshots.Any() || BaseRelationships.Any()), which matches any historical container snapshot. The stale pass immediately afterwards only retained the narrower live inventory — the image versions of the latest runtime-container scan run per Docker instance, plus observed images and their base images. An image version enriched at the start of a run therefore had its freshly written findings resolved again at the end of the same run and repopulated on the next one, producing a permanent resolve/re-insert cycle that surfaced as an identical count of new and resolved findings.

Linked issues

Closes #205

Review notes

  • Failed enrichments count as processed: ProcessImageVulnerabilitiesAsync returns early on a provider failure without touching findings, so a provider outage no longer resolves the finding set of every image it could not scan.
  • Image versions that are neither live nor processed are still deactivated and keep recording ResolvedByScanRunId.
  • Three new tests in VulnerabilityEnrichmentServiceTests cover an enriched-but-not-live image version surviving the stale pass, a failed enrichment keeping its findings, and two consecutive refreshes over an unchanged fleet leaving every finding active without adding rows. All three fail without the service change.

Follow-up work

None

The vulnerability refresh enriched every image version with any historical
container snapshot, observed image, or base relationship, while the stale
pass only kept the narrower live inventory. Image versions that were
enriched a few lines earlier therefore had their fresh findings resolved
again in the same run and repopulated on the next one. The identifiers of
the processed image versions are now passed into the stale pass and
excluded from deactivation, which also protects images whose provider call
failed. Refs #205
@sonarqubecloud

Copy link
Copy Markdown

@LarsLaskowski
LarsLaskowski merged commit 56907f4 into main Jul 27, 2026
4 checks passed
@LarsLaskowski
LarsLaskowski deleted the claude/issue-205-ueqq91 branch July 27, 2026 17:16
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.

[BUG] Stale-finding cleanup deactivates image versions that were enriched in the same refresh run

2 participants