-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
purl for apk packages missing when installed db file is not in root #1572
Comments
I think I figured this out. The problem isn't the depth, or having the package at root. The issue is what it actually has in that package. The cataloger looks for some linux release identifier before it starts parsing packages (any packages), whether they are in root or below. It does it here calling If at least one of these is not available in the root of the directory (or tar, or image, etc.) being scanned, then it cannot find it, and gives up on trying to give a purl for any package whose type requires it. So apk packages lose it, but golang packages do not (I didn't check any others). This leads to a question and two suggestions:
I am not wholly sure that any of these fully addresses it, as you can have a situation where I am running on some other OS, my own odd custom distribution or high-level packaging system, but I am taking the packages from the official alpine package repository, by running
So I do want the distro part of the purl to be alpine, even though my base OS does not have that in the discoverable files, e.g. Some alternatives:
I think I like the last one the best, as it avoids global settings that might break other things. This would be so much easier if |
It occurs to me that using I believe that the apk logic for installation is to go through each repository in order, until it finds a matching package. I'm pretty sure we do not want syft to go do all of that. Looking for some direction to help fix this. |
What happened:
lib/apk/db/installed
is in the root of the filesystem being scanned, then syft includes everything, including the purl.lib/apk/db/installed
is below the root of the filesystem being scanned, then syft includes everything, except the purlIn both cases it reads the
installed
file and parses it, yet for some reason, if not in the root, it misses the purl.Interestingly, if the package is also in the root, i.e. in addition to the above, it is in
lib/apk/db/installed
, then it adds thepurl
for all of them.What you expected to happen:
Add the apk purl for all packages, wherever it finds them.
Steps to reproduce the issue:
/tmp/oci
:$ docker buildx build -t spdx-test --output type=local,dest=/tmp/oci .
syft packages -o spdx-json /tmp/oci
- WORKSmkdir -p /tmp/single/one && tar -C /tmp/oci -cvf - . | (cd /tmp/single/one; tar -xvf - )
syft packages -o spdx-json /tmp/single
- FAILSsyft packages -o spdx-json /tmp/deep
- FAILSmkdir -p /tmp/staggered && mkdir -p /tmp/staggered/one && mkdir -p /tmp/staggered/two && tar -C /tmp/oci -cvf - . | (cd /tmp/staggered/one; tar -xvf - ) && tar -C /tmp/oci -cvf - . | (cd /tmp/staggered/two; tar -xvf - ) && tar -C /tmp/oci -cvf - . | (cd /tmp/staggered; tar -xvf - )
syft packages -o spdx-json /tmp/stagged
Output from the first (limited to curl package for readability):
From the single but one layer deep:
From two parallel but deep:
From staggered, i.e. two deep and one in root:
Anything else we need to know
It was @dautovri who first figured this out and explained it. Credit where it is due.
Environment:
syft version
: latest commitcat /etc/os-release
or similar): ran on macOS and LinuxThe text was updated successfully, but these errors were encountered: