fix: skip pkgVulnFailure entries with unresolved package refs (#108) - #109
Closed
SAY-5 wants to merge 1 commit into
Closed
fix: skip pkgVulnFailure entries with unresolved package refs (#108)#109SAY-5 wants to merge 1 commit into
SAY-5 wants to merge 1 commit into
Conversation
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>
Member
|
Closing in favor of #110, which already covers this fix and goes further. Your null guard in the adapter (removing the Where #110 diverges:
Thanks for the PR — the analysis in your description was spot on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #108.
addPackagesskips a package when itslayerRefdoesn't resolve to a known layer.addPoliciesthen resolves rule failures viascanResult.findPackageByID(failureData.packageRef)!— the!masked the case where the package had been skipped, sofailure.pkgended upundefined.SummaryReportPresenter.getRulePkgMessagelater crashed onfailure.pkg.name: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
undefinedfor bothpkgand the JSON vuln lookup, andcontinuepast the failure if either can't be resolved. Same defensive shape asaddPackagesitself.Added a regression test in
JsonScanResultV1ToScanResultAdapter.test.tsthat 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 onmasterand pass with this change.npm run lint,npm run build, andnpm testall green (113 passed).