Skip to content
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

bug: sbom scan can't detect two versions of the same package #4058

Open
kzaitsu opened this issue Apr 19, 2024 · 10 comments
Open

bug: sbom scan can't detect two versions of the same package #4058

kzaitsu opened this issue Apr 19, 2024 · 10 comments
Labels
bug Something isn't working
Milestone

Comments

@kzaitsu
Copy link

kzaitsu commented Apr 19, 2024

First, I scanned a particular json file using the command below. This json file contains two versions of openssl (1.0.2u, 1.1.1f).
"cve-bin-tool --sbom spdx --sbom-file <directory/file.json> -f csv -o cve-bin-tool_sbomscan-squashfs-root-0_2"
The resulting csv file did not include openssl version 1.1.1f, only 1.0.2u.
Next, delete version 1.0.2u of openssl in the json file you used earlier and run the same command again, and this time version 1.1.1f, which was not displayed earlier, is now displayed in the csv file. (1.0.2u was not displayed)
I don't know why the above phenomenon occurs, so could you please explain to me?

@kzaitsu kzaitsu added the bug Something isn't working label Apr 19, 2024
@kzaitsu kzaitsu changed the title fix: [bug description] fix: I can't understand the regularity of scan output results for json files. Apr 19, 2024
@terriko
Copy link
Contributor

terriko commented Apr 19, 2024

Sounds like a bug to me; it should display both.

@mastersans
Copy link
Contributor

I'll look into this one.

@kzaitsu
Copy link
Author

kzaitsu commented Apr 22, 2024

We would like to add some points that were not fully explained.
The json file containing the two versions of openssl was obtained with the following command.
"cve-bin-tool --offline -l debug --sbom-format json --sbom-output <directory/file.json> --detailed --report "
I used the previously reported command on the json file created by this command and confirmed that the output is strange.

@mastersans
Copy link
Contributor

@kzaitsu @terriko I investigated on it and turns out this is a bug in lib4sbom library we use for our sbom operation, I investigate there too the exact thing that is causing this behaviour is this:
https://github.com/anthonyharrison/lib4sbom/blob/0dae9bbba17bba8149706ec7daafb3c0e4322623/lib4sbom/spdx/spdx_parser.py#L433
here the if statement is checking weather package already exists in the packages dictionary if not then only its added, since the openssl is already present in the packages it wasn't adding second one, its not a problem with some particular version whichever version in first in the file is added and the onces after that are not added thats why its not appearing in the output. here is the data that i got from a neat little print statement placed in the lib4sbom of the packages dictionary:

{
    "openssl": {
        "name": "openssl",
        "type": "LIBRARY",
        "version": "1.1.1f",
        "id": "openssl_1.1.1f",
        "supplier_type": "Organization",
        "supplier": "OpenSSL",
        "originator_type": "Organization",
        "originator": "OpenSSL",
        "homepage": "http://www.openssl.org/",
        "licenseconcluded": "LicenseRef-OpenSSL",
        "licensedeclared": "LicenseRef-OpenSSL",
        "downloadlocation": "http://www.openssl.org/source/",
        "description": "OpenSSL library version 1.1.1f",
    }
}

I'll file a issue there regarding this , btw i also checked same scernario with the cyclonedx format but its not a problem with that. but i think i am going to ping @anthonyharrison since he is the author of lib4sbom regarding this and ask can i work on it.

@anthonyharrison
Copy link
Contributor

anthonyharrison commented Apr 22, 2024

@mastersans @terriko it is a bug but appears to be limited to SPDX SBOMs in JSON format only.

@mastersans
Copy link
Contributor

mastersans commented Apr 22, 2024

@mastersans @terriko it is a bug but appears to be limited to SPDX SBOMs in JSON format only.

Yes, but it may have been present in the yaml too since json and yaml both uses same _parse_spdx_data() function but should be fixed now too.

@terriko terriko changed the title fix: I can't understand the regularity of scan output results for json files. bug: sbom scan can't detect two versions of the same package Apr 22, 2024
@mastersans
Copy link
Contributor

@terriko @kzaitsu this issue has been addressed in PR : #34 and can be closed as complete.

@terriko terriko added this to the 3.3.1 milestone Apr 23, 2024
@terriko
Copy link
Contributor

terriko commented Apr 23, 2024

We should probably wait to close this until @anthonyharrison gets a new release out and we bump our minimum version of lib4sbom up, just so we don't forget to do that. But thank you, I'm glad there's a fix!

@kzaitsu
Copy link
Author

kzaitsu commented May 1, 2024

@terriko @mastersans @anthonyharrison
Sorry, I am late in replying.
Thank you for answering my questions.
If I have any more questions, I will ask them again.
Thank you in advance.

@alext-w
Copy link

alext-w commented May 26, 2024

I see the same problem when using CycloneDX output format as well, so it's either not limited to SPDX only as investigated previously, or that may be a format parser bug, I guess.

Particularly, I'm scanning a Linux ELF file, which is compiled with one GCC version, but has other linked pieces, compiled by an older one. cve-bin-tool seems to detect only one, but not the other.

Specifically, here's what strings returns:

$ strings src/obj-intel64/CECTraceTool.so |grep GNU
GCC: (GNU) 11.2.0
GCC: (GNU) 13.2.1 20240316 (Red Hat 13.2.1-7)

...and 11.2.0 is the only one shown by cve-bin-tool, both in the CVE list (that version happens to have a disputed CVE), and the SBOM.

This issue's name formally covers this case too (two versions, only one detected), but let me know if you want me to submit a separate one for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants