fix: reverse direction of SPDX SBOM dependency rels #7036
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed in #6867 some of the relationship types in the SPDX SBOM are using labels which don't match the direction of the relationship. This change fixes generated relationship entries so that the
relationshipType
aligns with the direction of the dependency relationship being described.For some types of relationships SPDX defines a pair of related types which can be used to describe dependency relationships from either parent-to-child or child-to-parent. For example:
Which can also be represented as
Note how the second example swaps the place of the parent/child and switches the relationship type from "DEPENDS_ON" to "DEPENDENCY_OF".
Unfortunately, not all of the SPDX-supported relationship types have a matched inverse. Specifically,
OPTIONAL_DEPENDENCY_OF
andDEV_DEPENDENCY_OF
have no matching type which would allow the relationship to be reversed (HAS_OPTIONAL_DEPENDENCY
andHAS_DEV_DEPENDENCY
would make sense, but aren't supported in the SPDX spec).In order to consistently represent ALL of the different relationships and ensure that the supplied type properly describes the direction of the relationship, we're going to swap the position of the parent/child nodes in the relationship (
spdxElementId
will always reference the child, whilerelatedSpdxElement
will always reference the parent) and exclusively use the child-to-parent relationship type labels:DEPENDENCY_OF
,DEV_DEPENDENCY_OF
,OPTIONAL_DEPENDENCY_OF
, andPREREQUISITE_FOR
.References
Fixes #6867