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

Perform License Resolution On Name Field During SBOM Import #3555

Conversation

aravindparappil46
Copy link
Contributor

@aravindparappil46 aravindparappil46 commented Mar 16, 2024

Description

On import of SBOMs with SPDX compliant license ID in the name field and with no id field, license resolution should first occur against standard licenses.

If none found, only then should license resolution occur against custom licenses.

Addressed Issue

Fixes #3433

Additional Details

On SBOM import, if the license candidate/license option did not have an id field and only a name field, we were assuming the license to lookup would be a custom license (whereas in fact, the name field could contain a standard license ID and not a custom one)

In this change, during BOM upload, if license does not have an id, then we call qm.getLicense() with the name field first. If it returns no results, only then do we call qm.getCustomLicense()

Sample SBOM used for testing is attached to this PR:
tiny-bom.json

Please do let me know if I am doing anything blatantly wrong :)

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have added corresponding update logic
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

On import of SBOMs with SPDX compliant license in the name field and with no id field,
license resolution should first occur against standard licenses. If none found, only then
should license resolution occur against custom licenses

Signed-off-by: Aravind Parappil <aravindparappil@gmail.com>
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.05% (target: -1.00%) 70.00% (target: 70.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2182706) 21514 15924 74.02%
Head commit (b89f8c6) 21523 (+9) 15942 (+18) 74.07% (+0.05%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3555) 10 7 70.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@nscuro nscuro added this to the 4.11 milestone Mar 16, 2024
@nscuro nscuro added the defect Something isn't working label Mar 16, 2024
Copy link
Member

@nscuro nscuro left a comment

Choose a reason for hiding this comment

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

Great first PR @aravindparappil46, thank you!

@nscuro nscuro merged commit 4356d02 into DependencyTrack:master Mar 16, 2024
12 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
defect Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SBOM import does not perform License Resolution like it is done when updates are done via the API
2 participants