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

npm group and name should have / and not : when stitching the spdx name together #34

Open
flemminglau opened this issue Sep 22, 2023 · 2 comments

Comments

@flemminglau
Copy link

flemminglau commented Sep 22, 2023

We are seeing that an NPM package like
"@angular/router" in the cyclonedx file is represented as

"group": "@angular"
"name": "router"

When the converter constructs the SPDX "name" value it does

                if (Objects.nonNull(group) && !group.isBlank()) {
                        name = group + ":" + name;

yielding an SPDX name of "name": "@angular:router"

For java this works fine as the delimiter between group and name in java is ":"
But for NPM it is a "/" which is implicit in the cyclonedx.

Would it make sense to check the purl to find the package manager or what would be a good strategy?

@goneall
Copy link
Member

goneall commented Sep 22, 2023

Would it make sense to check the purl to find the package manager or what would be a good strategy?

Makes sense. We should follow the conventions of the package manager.

@flemminglau - would you like to create a PR?

@flemminglau
Copy link
Author

flemminglau commented Sep 22, 2023

I have the code needed but I cannot figure out how to get the test working.
So I guess my change would be unwelcome.
Line 487 of CycloneSpdxConverter.java:

		String group = component.getGroup();
		if (Objects.nonNull(group) && !group.isBlank()) {
			String purl = component.getPurl();
			if (Objects.nonNull(purl) && purl.startsWith("pkg:npm")) {
				name = group + "/" + name;
			} else {
			    name = group + ":" + name;
			}
		}

My point is that the test validates that the ":" is always a ":".
But actually for npm it must be a "/" so the test fails.

So the test must be taught to distinguish between java and npm.

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

No branches or pull requests

2 participants