fix(conda): Add prefix to owned files list for environments not in scan root - #5225
fix(conda): Add prefix to owned files list for environments not in scan root#5225marcoesters wants to merge 9 commits into
Conversation
Signed-off-by: Marco Esters <mesters@anaconda.com>
Signed-off-by: Marco Esters <mesters@anaconda.com>
Signed-off-by: Marco Esters <mesters@anaconda.com>
Schema Change DetectionNew Schemas
|
Signed-off-by: Marco Esters <mesters@anaconda.com>
866954d to
31bd46e
Compare
Exact-head verification (head
|
Signed-off-by: Marco Esters <mesters@anaconda.com>
Signed-off-by: Marco Esters <mesters@anaconda.com>
Signed-off-by: Marco Esters <mesters@anaconda.com>
Signed-off-by: Marco Esters <mesters@anaconda.com>
|
Thank you for the review! I think in the end I think I addressed point 3 and 4. |
Signed-off-by: Marco Esters <mesters@anaconda.com>
42acb78 to
7396760
Compare
Description
Problem description
The
condacataloger reads the list of owned files fromcondametadata files. These file paths are taken to determine ownership overlap. The files paths in the metadata are stored relative to the environment location (prefix), andsyftcurrently does not prepend the environment location. This leads to different SBOMs depending on whether the environment is in the root directory of the file system or image scan.To reproduce using
syft 1.51.0:conda create -p /tmp/opt/testenv pythonsyft scan /tmp/opt/ -o spdx-json@2.3, which will result in the following SBOM: sbom.opt.jsonsyft scan /tmp/opt/testenv, which will result in the following, much larger SBOM: sbom.testenv.jsonThe latter contains relationships between the conda package, which are missing in the scan of
/tmp/opt:{ "relationships": [ { "spdxElementId": "SPDXRef-Package-conda-python-0372d4f949da77f2", "relatedSpdxElement": "SPDXRef-Package-binary-python-cf5530976b920e28", "relationshipType": "OTHER", "comment": "ownership-by-file-overlap: indicates that the parent package claims ownership of a child package since the parent metadata indicates overlap with a location that a cataloger found the child package by" } ] }Proposed solution
Add the environment location (
Prefix) to theCondaMetaPackagestruct. The environment location is always two directories above the metadata JSON file. The prefix is then used in theOwnedFiles()method to construct the full path relative to the scan root directory.I chose this over fixing the paths in the
Filesslice directly because it is the most flexible approach. Adding the prefix to all path types incondametadata may not always be the correct approach, so keeping the prefix separate allows us to add it on a case by case basis. The downside is that this the prefix is not an actual part ofconda's metadata and requires a new schema version just for a helper property.Using the code in this PR to scan the test environment yields the following SBOM: sbom.new.json
Type of change
Checklist