trustification / trustify

Apache License 2.0
10 stars 19 forks source link

`/api/v1/sbom/{id}/advisory` contains packages without id. #1043

Open carlosthe19916 opened 12 hours ago

carlosthe19916 commented 12 hours ago

Steps to reproduce:

[
    {
        "uuid": "urn:uuid:e635c662-fc76-4c07-87b3-908226d95fd1",
        "identifier": "https://www.redhat.com/#CVE-2023-2798",
        "issuer": {
            "id": "a80a05f2-7a3c-48a3-9a17-5252f9f1c17e",
            "name": "Red Hat Product Security",
            "cpe_key": null,
            "website": null
        },
        "published": "2023-05-25T00:00:00Z",
        "modified": "2023-08-10T12:02:50Z",
        "withdrawn": null,
        "title": "Stack overflow crash causes Denial of Service (DoS)",
        "labels": {
            "type": "csaf"
        },
        "status": [
            {
                "normative": true,
                "identifier": "CVE-2023-2798",
                "title": null,
                "description": null,
                "reserved": null,
                "published": null,
                "modified": null,
                "withdrawn": null,
                "discovered": null,
                "released": null,
                "cwes": [],
                "average_severity": "high",
                "status": "not_affected",
                "context": {
                    "cpe": "cpe:/a:redhat:quarkus:2:*:*:*"
                },
                "packages": [
                    {
                        "id": "",
                        "name": "htmlUnit",
                        "version": null,
                        "purl": [],
                        "cpe": []
                    }
                ]
            }
        ]
    },

I cut the response for better understanding

If you see the field status.packages then we have a package without id and only name.

The problem is that I am using this current data for the image below:

image

jcrossley3 commented 11 hours ago

I wondered about this TODO in the code. Is this issue the result of that TODO, @dejanb?

jcrossley3 commented 11 hours ago
  • get the quarkus-sbom advisories using /api/v1/sbom/urn%3Auuid%3A01935352-6dc7-7582-9241-b2577f404d3f/advisory

At the risk of telling you something you already know, those ID's are universally unique so will never match any other SBOM ingested in anyone else's environment.

If you wanted to be pedantic in your already-excellently-detailed steps to reproduce you could do something like:

ID=$(http get "http://localhost:8080/api/v1/sbom?q=quarkus" | jq -r '.items[0].id')
http get "http://localhost:8080/api/v1/sbom/$ID/advisory" | jq . | head -n 100

But it's not necessary.

And it's totally fine to refer to your own ID's in your issues, I just wanted to make sure you knew they were meaningless in any db other than your own. Apologies if you already did. :smile:

carlosthe19916 commented 11 hours ago

yeah, sorry. I was in a hurry and copied and pasted the URLs from my browser. So I used my unique ID from my DB.

And thanks for sharing the http command. That's a better way of reproducing and navigating JSONs. I'll keep it in mind so I can use it in future issues

dejanb commented 11 hours ago

I wondered about this TODO in the code. Is this issue the result of that TODO, @dejanb?

Yes. There's some work started to solve this with #994. The idea is to try to use in-mem graph for this search (an alternative is db query).