fix: set license and manufacturer for the main component #654 - #836
fix: set license and manufacturer for the main component #654#836dimitarp wants to merge 2 commits into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Signed-off-by: Dimitar Popov <dimitar.popov@seitenbau.com>
611c0a6 to
5865449
Compare
5865449 to
32f3ef4
Compare
skhokhlov
left a comment
There was a problem hiding this comment.
Thanks for this! It is a correct per the CycloneDX spec.
However, this is a breaking change to the generated SBOM, which we treat as public API. It needs a major version bump (4.x.x). So the merge might be delayed until we understand full scope go the next major release.
| task.getExternalReferences().get().forEach(component::addExternalReference); | ||
| } | ||
| if (task.getLicenseChoice().isPresent()) { | ||
| component.setLicenses(task.getLicenseChoice().get()); |
There was a problem hiding this comment.
Note that toComponent (line ~264) may already set this component's licenses from resolved project metadata, and this line overwrites them. That's the behavior we want - a configured licenseChoice is the single source of truth for the main component's license - so no change needed here. Please add a sentence to the README's licenseChoice docs stating that a configured value replaces any auto-detected license for the main component.
| component.setLicenses(task.getLicenseChoice().get()); | ||
| } | ||
| if (task.getOrganizationalEntity().isPresent() | ||
| && !new OrganizationalEntity() |
There was a problem hiding this comment.
This presence + not-empty check duplicates lines 118-120; only the version comparison differs. Optional cleanup - extract a small helper and reuse it in both branches:
private Optional<OrganizationalEntity> configuredManufacturer() {
if (!task.getOrganizationalEntity().isPresent()) {
return Optional.empty();
}
OrganizationalEntity oe = task.getOrganizationalEntity().get();
return new OrganizationalEntity().equals(oe) ? Optional.empty() : Optional.of(oe);
}Happy to merge without this.
| assert !licenseChoice.getLicenses().findAll({ | ||
| it.getAttachmentText().getText() == "This is a Licenses-Test" && | ||
| it.getUrl() == "https://www.test-Url.org/" | ||
| }).isEmpty() |
There was a problem hiding this comment.
Please also assert the data left the old (document-level) location, otherwise a regression that writes to both places would pass:
assert bom.getMetadata().getLicenses() == null
assert bom.getMetadata().getManufacturer() == null| assert !licenseChoice.getLicenses().findAll({ | ||
| it.getAttachmentText().getText() == "This is a Licenses-Test" && | ||
| it.getUrl() == "https://www.test-Url.org/" | ||
| }).isEmpty() |
There was a problem hiding this comment.
Same here. Add the negative assertions so the old paths are verified empty:
assert bom.getMetadata().getLicenses() == null
assert bom.getMetadata().getManufacturer() == null| assert jsonBom.getMetadata().getManufacturer().getName() == "name" | ||
| assert xmlBom.getMetadata().getManufacturer().getName() == "name" | ||
| assert jsonBom.getMetadata().getComponent().getManufacturer().getName() == "name" | ||
| assert xmlBom.getMetadata().getComponent().getManufacturer().getName() == "name" |
There was a problem hiding this comment.
This branch asserts metadata.manufacture == null but not the BOM-level metadata.manufacturer. Please add the following so a manufacturer accidentally written to both the component and the document level is caught:
assert jsonBom.getMetadata().getManufacturer() == null
assert xmlBom.getMetadata().getManufacturer() == null|
Thanks for the review! I'll look into it the next days. |
I understand your concern. However, maybe the README should describe the actual behavior for the Optionally, implementing new parameters |
Signed-off-by: Dimitar Popov <dimitar.popov@seitenbau.com>
32f3ef4 to
fc9e827
Compare
|
Personally I think it would be best to add new parameters for the component manufacturer. This way the manufacturer can be set both for the SBOM itself and the main component. Additionally some Guidelines (e.g. the German BSI TR-03183) actually require the manufacturer on both levels. |
Put license and manufacturer data under
$.metadata.component.licensesand$.metadata.component.manufacturerinstead of$.metadata.licensesand$.metadata.manufacturer. The latter refers to the license and manufacturer of the SBOM itself and not of the main component. The plugin README states thatlicenseChoiceis the "License information for the main component".fixes #654