-
Notifications
You must be signed in to change notification settings - Fork 361
fix(spdx): Set the licenseConcluded via ORT's effective license
#11131
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ import org.ossreviewtoolkit.model.Hash | |
| import org.ossreviewtoolkit.model.Identifier | ||
| import org.ossreviewtoolkit.model.KnownProvenance | ||
| import org.ossreviewtoolkit.model.LicenseFinding | ||
| import org.ossreviewtoolkit.model.LicenseSource | ||
| import org.ossreviewtoolkit.model.OrtResult | ||
| import org.ossreviewtoolkit.model.Package | ||
| import org.ossreviewtoolkit.model.Provenance | ||
|
|
@@ -159,6 +160,14 @@ internal fun Package.toSpdxPackage( | |
| .applyChoices(ortResult.getPackageLicenseChoices(id)) | ||
| .applyChoices(ortResult.getRepositoryLicenseChoices()) | ||
|
|
||
| val licenseDeclared = resolvedLicenseInfo.mainLicense()?.simplify() | ||
|
|
||
| // Do not use `CONCLUDED_OR_DECLARED_AND_DETECTED` here to support explicitly setting the `concludedLicense` to the | ||
| // `licenseDeclared` in order to acknowledge the latter and record it as the license concluded in SPDX. | ||
| val licenseView = LicenseView(setOf(LicenseSource.DECLARED, LicenseSource.DETECTED)) | ||
| val licenseConcluded = concludedLicense ?: resolvedLicenseInfo.effectiveLicense(licenseView) | ||
| .takeUnless { it == licenseDeclared } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Two questions about this:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I need to think about this a bit more. In essence, what I want to know if whether a license expression has been modified either by a package curation (via the concluded license) or by a package configuration (via a license finding conclusion).
Yes, it should, but I believe we have no good mechanism to do so. The only way I could think of to "acknowledge" that the declared license is correct as-is is to set the concluded license to the same expression. So, I probably should change the logic to always prefer a concluded license, and only fall back to the effective license (if it is different from the declared license). |
||
|
|
||
| return SpdxPackage( | ||
| spdxId = id.toSpdxId(type), | ||
| checksums = when (type) { | ||
|
|
@@ -182,11 +191,10 @@ internal fun Package.toSpdxPackage( | |
| SpdxPackageType.SOURCE_PACKAGE -> SpdxConstants.NOASSERTION | ||
| // Clear the concluded license as it might need to be different for the VCS location. | ||
| SpdxPackageType.VCS_PACKAGE -> SpdxConstants.NOASSERTION | ||
| SpdxPackageType.PROJECT -> concludedLicense.nullOrBlankToSpdxNoassertionOrNone() | ||
| else -> concludedLicense.nullOrBlankToSpdxNoassertionOrNone() | ||
| SpdxPackageType.PROJECT -> licenseConcluded.nullOrBlankToSpdxNoassertionOrNone() | ||
| else -> licenseConcluded.nullOrBlankToSpdxNoassertionOrNone() | ||
| }, | ||
| licenseDeclared = resolvedLicenseInfo.mainLicense() | ||
| ?.simplify() | ||
| licenseDeclared = licenseDeclared | ||
| ?.sorted() | ||
| ?.nullOrBlankToSpdxNoassertionOrNone() | ||
| ?: SpdxConstants.NONE, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a human only / exclusively has looked at a single detected license finding, and changed it with a curation, setting the SPDX's
licenseConcludedwould mean, that the human has looked at the overall (effective license expression) and concluded it to be ok. Which is not the case here. What do you think about this?Appart from that, the effective license not only can be altered by license finding curations, but also by
Should these be considered too (in particular the choices)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not necessarily the case, correct. We have no mechanism to signal that "a human has finished looking at all license findings and made curations as necessary", so I'm not sure there's a way to handle this.
I believe so, i.e. I do not see why not. For example, I don't think it's a problem that a single fixed software project could generate different SPDX files if different license choices were configured.