Skip to content

Conversation

@dgl
Copy link

@dgl dgl commented Jul 18, 2025

This (partly, depending if the request for cpe in a comment is considered) addresses CycloneDX/cyclonedx-cli#424.

Signed-off-by: David Leadbeater <dgl@dgl.cx>
@dgl dgl requested a review from a team as a code owner July 18, 2025 06:49
Copy link
Contributor

@andreas-hilti andreas-hilti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme states:

SPDX supports multiple CPEs and PURLs for a package. But doesn't support specifying if any are a component identifier.

Can you comment on this (and in particular the current state)?

"licenseDeclared": "NOASSERTION",
"name": "Jena",
"primaryPackagePurpose": "APPLICATION",
"purl": "pkg:maven/org.apache.jena/apache-jena@3.12.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid here? (I don't see it in the SPDX schema.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, no, reverted.

}
component.Properties.AddSpdxElement(refPropName, refPropValue);

if (refPropName == PropertyTaxonomy.EXTERNAL_REFERENCE_PACKAGE_MANAGER_PURL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, SPDX (in principle) allows multiple external references of type PURL. How do we want to handle this case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect it should take the first, while not ideal and entirely correct, it makes it work.

SPDX 3.0 does add a proper packageUrl field so if later support is added for 3.0 the CDX and SPDX 3.0 conversion can be more correct.


if (refPropName == PropertyTaxonomy.EXTERNAL_REFERENCE_PACKAGE_MANAGER_PURL)
{
component.Purl = refPropValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want to do component.Properties.AddSpdxElement(refPropName, refPropValue); (i.e. add it to the properties) if we end up here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but we need to properly roundtrip if we do that. I've updated the PR to do so.

Signed-off-by: David Leadbeater <dgl@dgl.cx>
@dgl
Copy link
Author

dgl commented Jul 21, 2025

SPDX supports multiple CPEs and PURLs for a package. But doesn't support specifying if any are a component identifier.

Can you comment on this (and in particular the current state)?

In SPDX 2 it is true that external ref is the only way to represent a PURL, but it is common for there to only be one purl (although I don't have a massive sample of SPDX files to confirm that). In SPDX 3 there is support for using a purl as an identifier:
https://spdx.github.io/spdx-spec/v3.0.1/model/Software/Classes/Package/#properties (extra PURLs can now be specified in ExternalIdentifier). Given there is a future where this can be correctly encoded (ecosystem support for SPDX 3 is still mostly being worked on), it seems like a simple heuristic like taking the first package URL in external refs works for SPDX 2.

@mtsfoni
Copy link
Member

mtsfoni commented Jul 21, 2025

I’d mostly go with Andreas' judgment regarding this PR

Copy link
Contributor

@andreas-hilti andreas-hilti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with SPDX, but having a Purl is quite crucial to do the vulnerability analysis. Thus, I think this is ok as a compromise.

However, we should document this in the readme.

Maybe we should get some feedback from other users of the SPDX to CDX conversion.

@mtsfoni
Copy link
Member

mtsfoni commented Jul 27, 2025

However, we should document this in the readme.

@dgl could you document this in the readme as suggested @andreas-hilti ?

@mtsfoni
Copy link
Member

mtsfoni commented Aug 10, 2025

@dgl quick bump - one tiny thing left before we can merge 👍

@andreas-hilti
Copy link
Contributor

@dgl @mtsfoni This would be may proposal for the readme update:
dgl#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants