anchore / syft

CLI tool and library for generating a Software Bill of Materials from container images and filesystems
Apache License 2.0
6.2k stars 571 forks source link

Scanning a source tree with duplicate conanfile.txt dependencies generates multiple components #3403

Open jkugler opened 6 days ago

jkugler commented 6 days ago

What happened: Syft found two identical dependencies in two different conanfile.txt files found in the source tree. This generated two Components in the CycloneDX SBOM that are identical in every way except for their bom-ref and syft:location:0:path.

What you expected to happen: I would expect it would create one component and then generate multiple entries in the properties like so:

      "properties": [
        {
          "name": "syft:location:0:path",
          "value": "/path/to/first/conanfile.txt"
        },
        {
          "name": "syft:location:1:path",
          "value": "/path/to/second/conanfile.txt"
        }
      ]

Steps to reproduce the issue: Create two conanfile.txt files and put them in two different locations in your source tree, and add these contents:

[requires]
libtiff/4.1.0

Then run syft scan dir:source_dir/ --output cyclonedx-json=example.json

Anything else we need to know?: This is similar to https://github.com/anchore/syft/issues/1162 but has to do with source trees and not scanning docker containers

Environment:

FYI: This issue was filed on behalf of Adobe.

jkugler commented 6 days ago

This may also be related to https://github.com/anchore/syft/issues/3131