DependencyTrack / dependency-track

Dependency-Track is an intelligent Component Analysis platform that allows organizations to identify and reduce risk in the software supply chain.
https://dependencytrack.org/
Apache License 2.0
2.45k stars 532 forks source link

Set license name instead of ID when using custom license #3915

Closed 2000rosser closed 4 days ago

2000rosser commented 5 days ago

Description

A valid SPDX is required when using the ID field for licenses. If the license is a custom license, use the name field instead.

Addressed Issue

3897

Checklist

codacy-production[bot] commented 5 days ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
:white_check_mark: +0.02% (target: -1.00%) :x: 66.67% (target: 70.00%)
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (a4d5a7b328bd93a7dc32f56efb00d0f60b70b480) | 22074 | 16811 | 76.16% | | | Head commit (177d9b6af71e3952381a1f7b9b45526bd573478f) | 22076 (+2) | 16817 (+6) | 76.18% (**+0.02%**) | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#3915) | 3 | 2 | **66.67%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences


:rocket: Don’t miss a bit, follow what’s new on Codacy.

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

2000rosser commented 5 days ago

I actually don't think the unit test I added is necessary, will remove it.

nscuro commented 5 days ago

Thanks @2000rosser!

Do you think you could add a test for this scenario here? https://github.com/DependencyTrack/dependency-track/blob/master/src/test/java/org/dependencytrack/resources/v1/BomResourceTest.java

Have a look at the existing export tests, and either extend them or add a smaller test case that's scoped to only this problem.

We want to ensure that, given a component with custom license, the exported BOM looks like expected (assertThatJson...), and passes schema validation (assertThatNoException().isThrownBy(() -> CycloneDxValidator.getInstance().validate(jsonResponse.getBytes()));).

2000rosser commented 5 days ago

@nscuro Sure, I'll take a look and add a test for it