Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions plugins/reporters/spdx/src/main/kotlin/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -159,6 +160,14 @@ internal fun Package.toSpdxPackage(
.applyChoices(ortResult.getPackageLicenseChoices(id))
.applyChoices(ortResult.getRepositoryLicenseChoices())

val licenseDeclared = resolvedLicenseInfo.mainLicense()?.simplify()
Copy link
Member

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 licenseConcluded would 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

  1. path excludes
  2. license choices

Should these be considered too (in particular the choices)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Which is not the case here. What do you think about this?

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.

Should these be considered too (in particular the choices)?

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.


// 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 }
Copy link
Member

Choose a reason for hiding this comment

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

Finally, the licenseConcluded should only be set if (human) clearance work was involved, so only set it if it differs from the licenseDeclared.

Two questions about this:

  • The fact that there are detected licenses does not mean that anyone looked at them, so is it still correct to set this field when no concluded license was set?
  • If the clearance result is the same as the declared license, should this not be made explicit?

Copy link
Member Author

Choose a reason for hiding this comment

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

The fact that there are detected licenses does not mean that anyone looked at them, so is it still correct to set this field when no concluded license was set?

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).

If the clearance result is the same as the declared license, should this not be made explicit?

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) {
Expand All @@ -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,
Expand Down
Loading