fix(sbom): detect OS from `purl` if OS component not found
Description
There are cases when SBOM file doesn't contain OS component.
To avoid missing OS packages -we can try to get OS from purl.
More details - https://github.com/aquasecurity/trivy/discussions/7073#discussioncomment-9932362
Related issues
- Close #7100
Checklist
- [x] I've read the guidelines for contributing to this repository.
- [x] I've followed the conventions in the PR title.
- [x] I've added tests that prove my fix is effective or that my feature works.
- [ ] I've updated the documentation with the relevant information (if needed).
- [ ] I've added usage information (if the PR introduces new options)
- [ ] I've included a "before" and "after" example to the description (if the PR is a user interface change).
@DmitriyLewen thank you for creating this PR, I too am seeing a lot of warnings when scanning wolfi images.
Question unrelated to PR: For these warning you mention in discussions/7073, is Trivy unable to scan the packages in the image therefore being unable to report accurate vulnerability info for Wolfi images?
Hello @eshafaq1
is Trivy unable to scan the packages in the image therefore being unable to report accurate vulnerability info for Wolfi images?
Trivy detects the following packages from wolfi images:
apkpackages obtained fromlib/apk/db/installedfile (default way to detectapkpackages)- packages from SBOM files (this PR for these packages).
IIUC packages from p1 and p2 is same (duplicates). So you shouldn't have problem, because Trivy correctly detectы vulnerabilities for packages from p1.
Hopefully @knqyf263 can get some time to review :)
This PR is stale because it has been labeled with inactivity.
This PR is stale because it has been labeled with inactivity.
is there anything we can do to move this forward?
Hello @tuananh
Unfortunately, we are currently busy with more priority tasks.
Please be patient. As soon as we have time, we will return to this PR
Regarrds, Dmitriy
This PR is stale because it has been labeled with inactivity.
This PR is stale because it has been labeled with inactivity.
@DmitriyLewen Do you all have time to prioritize this?
Hello @dalejrodriguez We don't have time to this task at the moment.
Release plans can be found here - https://github.com/aquasecurity/trivy/milestones
It seems that I was mistaken. I had assumed that wolfi-base did not contain OS package information (like /etc/os-release) and that we would need to extract OS information from the SBOM. Based on that assumption, I suggested retrieving OS information from the PURL. However, I have since realized that wolfi-base does include /etc/os-release. In other words, as long as we can retrieve the package information, it's not necessary to get OS information from the SBOM. I have created a new PR.
https://github.com/aquasecurity/trivy/pull/9034
closed in favor #9034