Skip to content

fix: skip pkgVulnFailure entries with unresolved package refs (#108) - #109

Closed
SAY-5 wants to merge 1 commit into
sysdiglabs:masterfrom
SAY-5:fix/summary-report-pkg-undefined-108
Closed

fix: skip pkgVulnFailure entries with unresolved package refs (#108)#109
SAY-5 wants to merge 1 commit into
sysdiglabs:masterfrom
SAY-5:fix/summary-report-pkg-undefined-108

Conversation

@SAY-5

@SAY-5 SAY-5 commented May 3, 2026

Copy link
Copy Markdown

Fixes #108.

addPackages skips a package when its layerRef doesn't resolve to a known layer. addPolicies then resolves rule failures via scanResult.findPackageByID(failureData.packageRef)! — the ! masked the case where the package had been skipped, so failure.pkg ended up undefined. SummaryReportPresenter.getRulePkgMessage later crashed on failure.pkg.name:

TypeError: Cannot read properties of undefined (reading 'name')
    at SummaryReportPresenter.getRulePkgMessage (SummaryReportPresenter.js:173)

The crash surfaces as a regression v6.3.4 → v6.3.5 in the wild because the new layer/package pruning paths in v6.3.5 expose more reports where a referenced package is missing.

Drop the non-null assertion, accept undefined for both pkg and the JSON vuln lookup, and continue past the failure if either can't be resolved. Same defensive shape as addPackages itself.

Added a regression test in JsonScanResultV1ToScanResultAdapter.test.ts that constructs a report whose pkgVulnFailure references a package whose layer is absent, and asserts the rule ends up with zero failures (rather than corrupt ones) — verified to fail on master and pass with this change.

npm run lint, npm run build, and npm test all green (113 passed).

Policy rule failures whose packageRef points at a package that was
filtered out during addPackages (e.g. layer not present in layers map)
previously became failures with an undefined pkg, due to the non-null
assertion on findPackageByID. SummaryReportPresenter.getRulePkgMessage
then crashed with 'Cannot read properties of undefined (reading name)'
when iterating those failures, even on otherwise-passed scans.

Drop the assertion and skip the failure if either pkg or vuln cannot be
resolved, mirroring the defensive pattern already used in addPackages.

Fixes sysdiglabs#108

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@SAY-5
SAY-5 requested a review from a team as a code owner May 3, 2026 18:17
@tembleking

Copy link
Copy Markdown
Member

Closing in favor of #110, which already covers this fix and goes further.

Your null guard in the adapter (removing the ! assertions and adding continue) is included in #110 — same approach, practically identical diff. Good catch on the root cause.

Where #110 diverges:

Thanks for the PR — the analysis in your description was spot on.

@tembleking tembleking closed this May 6, 2026
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.

TypeError: Cannot read properties of undefined (reading 'name') in SummaryReportPresenter`

2 participants