-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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] Relationships in SPDX sbom pointing in wrong direction #6867
Comments
This adjusts the relationships to match the explanations at https://spdx.github.io/spdx-spec/v2.3/relationships-between-SPDX-elements/ Fixes npm#6867 Signed-off-by: Anton Bauhofer <anton.bauhofer@tngtech.com>
I don't think this is wrong, this was brought up during the implementation PR and the current direction matches guidance from the SPDX community, namely that
|
The current implementation was based on guidance that we received from the SPDX maintainers. The way it was explained to me is that the relationship names should be considered non-directional. Most tooling which consumes SBOMs will treat the The fact that some of the relationship labels have inverse variants ( |
This issue is not resolved and my comment in #6801 was probably missunderstood. Can you please reopen the ticket? The currently produced SPDX files do not represent the correct dependency tree. |
Hey @wraithgar, that statement is wrong. There are two parts to that determine "directionality",
Therefore the relationships
and
are equivalent, since the label was inverted and the But the following relationships are not equivalent:
and
So, the choice of label ( |
I agree that the direction of the arrows should not be inverted. Nevertheless the relationshipTypes need to be fixed |
This adjusts the relationships to match the explanations at https://spdx.github.io/spdx-spec/v2.3/relationships-between-SPDX-elements/ Fixes npm#6867 Signed-off-by: Anton Bauhofer <anton.bauhofer@tngtech.com>
This adjusts the relationships to match the explanations at https://spdx.github.io/spdx-spec/v2.3/relationships-between-SPDX-elements/ Fixes npm#6867 Signed-off-by: Anton Bauhofer <anton.bauhofer@tngtech.com>
This adjusts the relationships to match the explanations at https://spdx.github.io/spdx-spec/v2.3/relationships-between-SPDX-elements/ Fixes npm#6867 Signed-off-by: Anton Bauhofer <anton.bauhofer@tngtech.com>
This adjusts the relationships to match the explanations at https://spdx.github.io/spdx-spec/v2.3/relationships-between-SPDX-elements/ Fixes npm#6867 Signed-off-by: Anton Bauhofer <anton.bauhofer@tngtech.com>
This adjusts the relationships to match the explanations at https://spdx.github.io/spdx-spec/v2.3/relationships-between-SPDX-elements/ Fixes npm#6867 Signed-off-by: Anton Bauhofer <anton.bauhofer@tngtech.com>
This adjusts the relationships to match the explanations at https://spdx.github.io/spdx-spec/v2.3/relationships-between-SPDX-elements/ Fixes npm#6867 Signed-off-by: Anton Bauhofer <anton.bauhofer@tngtech.com>
We created a new PR to address the issue and keep the order of ( |
Let me explain the thought process and the guidance I received that yielded the current implementation . . . Setting aside the issue of the For example, take the following: "relationships": [
{
"spdxElementId": "SPDXRef-DOCUMENT",
"relatedSpdxElement": "SPDXRef-Package-hello-world-1.0.0",
"relationshipType": "DESCRIBES"
},
{
"spdxElementId": "SPDXRef-Package-hello-world-1.0.0",
"relatedSpdxElement": "SPDXRef-Package-ms-2.1.3",
"relationshipType": "HAS_PREREQUISITE"
},
{
"spdxElementId": "SPDXRef-Package-hello-world-1.0.0",
"relatedSpdxElement": "SPDXRef-Package-ci-info-3.9.0",
"relationshipType": "DEPENDS_ON"
}
] It's pretty clear that this represents the following tree of dependencies:
Now you could argue that the following is an equivalent representation (note how some of the relationships are reversed similar to #6871): "relationships": [
{
"spdxElementId": "SPDXRef-DOCUMENT",
"relatedSpdxElement": "SPDXRef-Package-hello-world-1.0.0",
"relationshipType": "DESCRIBES"
},
{
"spdxElementId": "SPDXRef-Package-ms-2.1.3",
"relatedSpdxElement": "SPDXRef-Package-hello-world-1.0.0",
"relationshipType": "PREQUISITE_FOR"
},
{
"spdxElementId": "SPDXRef-Package-ci-info-3.9.0",
"relatedSpdxElement": "SPDXRef-Package-hello-world-1.0.0",
"relationshipType": "DEPENDENCY_OF"
}
] While both forms are valid according to the SPDX schema (and semantically equivalent to any person who might read them), in practice, I've found that much of the tooling written to consume SPDX documents can't make any sense of the second version because it breaks the expectations for how a directed-graph should be represented -- the source/parent --> destination/child relationship is not consistently represented. Take for example, the
While the second example results in the following:
With that constraint of representing all of the parent/child relationships consistently, the next question is what labels (or For prod and peer dependencies, the answer is fairly straightforward given that there exists relationship types that read naturally with the direction of the relationship: Unfortunately, the story isn't as clear for development and optional dependencies -- the corresponding relationship types have only a single variant and don't seem to imply the correct relationship "directionality": When discussing this with Adolfo Veytia as part of the RFC process, the guidance I got was that, despite their name, the relationship kinds are non-directional. He suggested that, even if it didn't read naturally, it was preferable to have a backwards label over having disconnected nodes in the graph. With that in mind, I implemented the graph consistently and used the somewhat clunky relationship types for the development and optional dependencies.
I agree that some of those labels don't read nicely, but it seems preferable to the alternative:
|
Thanks for this detailed commend and you have a good point here. You are right that the correct representation is more complex to parse, as one can not just follow edges of an graph ignoring the types. I created kubernetes-sigs/bom#354 to track that bug in the bom tool. |
I do not think that it is an issue of readability. I think the statement that is encoded is wrong. Lets look at the definition of
So, if I substitute it with the example from above I get the statement "hello-world@1.0.0 is an optional dependency of lodash@4.17.21.", which is not what should be expressed. Note that the Example actually talks about a similar npm example. |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When creating an SPDX sbom, some of the contained relationships are incorrect.
For example, for the npm/cli repository, the following relationship is determined:
{
"spdxElementId": "SPDXRef-Package-npm-10.1.0",
"relatedSpdxElement": "SPDXRef-Package-npmcli.eslint-config-4.0.2",
"relationshipType": "DEV_DEPENDENCY_OF"
}
Expected Behavior
According to the SPDX specification, the relationship should point in the other direction:
{
"spdxElementId": "SPDXRef-Package-npmcli.eslint-config-4.0.2",
"relatedSpdxElement": "SPDXRef-Package-npm-10.1.0",
"relationshipType": "DEV_DEPENDENCY_OF"
}
Steps To Reproduce
node . sbom --sbom-format spdx
"relationshipType": "DEV_DEPENDENCY_OF"
Environment
The text was updated successfully, but these errors were encountered: