Skip to content
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion cli/src/main/kotlin/commands/EvaluatorCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ class EvaluatorCommand : CliktCommand(name = "evaluate", help = "Evaluate ORT re
val licenseInfoResolver = LicenseInfoResolver(
provider = DefaultLicenseInfoProvider(ortResultInput, packageConfigurationProvider),
copyrightGarbage = copyrightGarbage,
addAuthorsToCopyrights = config.addAuthorsToCopyrights,
Copy link
Member Author

Choose a reason for hiding this comment

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

It was decided during PR grooming by the TSC that an implementation of the general feature to conclude copyrights would at first not remove the feature to map authors to copyrights. This is to allow users for a transition period to migrate configuration from one feature to the other smoothly.

archiver = config.scanner.archive.createFileArchiver(),
licenseFilenamePatterns = LicenseFilenamePatterns.getInstance()
)
Expand Down
1 change: 0 additions & 1 deletion cli/src/main/kotlin/commands/ReporterCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ class ReporterCommand : CliktCommand(
val licenseInfoResolver = LicenseInfoResolver(
provider = DefaultLicenseInfoProvider(ortResult, packageConfigurationProvider),
copyrightGarbage = copyrightGarbage,
addAuthorsToCopyrights = config.addAuthorsToCopyrights,
archiver = config.scanner.archive.createFileArchiver(),
licenseFilenamePatterns = LicenseFilenamePatterns.getInstance()
)
Expand Down
4 changes: 1 addition & 3 deletions helper-cli/src/main/kotlin/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ internal fun OrtResult.fetchScannedSources(id: Identifier): File {
internal fun OrtResult.processAllCopyrightStatements(
omitExcluded: Boolean = true,
copyrightGarbage: Set<String> = emptySet(),
addAuthorsToCopyrights: Boolean = false,
packageConfigurationProvider: PackageConfigurationProvider = PackageConfigurationProvider.EMPTY
): List<ProcessedCopyrightStatement> {
val result = mutableListOf<ProcessedCopyrightStatement>()
Expand All @@ -133,8 +132,7 @@ internal fun OrtResult.processAllCopyrightStatements(

val licenseInfoResolver = createLicenseInfoResolver(
packageConfigurationProvider = packageConfigurationProvider,
copyrightGarbage = CopyrightGarbage(copyrightGarbage.toSortedSet()),
addAuthorsToCopyrights = addAuthorsToCopyrights
copyrightGarbage = CopyrightGarbage(copyrightGarbage.toSortedSet())
)

collectProjectsAndPackages().forEach { id ->
Expand Down
11 changes: 11 additions & 0 deletions model/src/main/kotlin/Package.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ data class Package(
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
val authors: SortedSet<String> = sortedSetOf(),

/**
* The set of concluded copyright statements for this package. It can be used to override the [detected copyright
* statements][CopyrightFinding.statement] (note that there is no such thing as *declared* copyright statements
* because package managers do not support declaring them explicitly).
*
* ORT itself does not set this field, it needs to be set by the user using a [PackageCuration].
*/
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
val concludedCopyrights: SortedSet<String> = sortedSetOf(),
Copy link
Member Author

Choose a reason for hiding this comment

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

It was decided during PR grooming by the TSC that the current implementation is not sufficient even as a minimal solution. At a minimum, this set should be a map that associates license names with their copyright holder in order to not associate concluded copyrights to all licenses found in a package.


/**
* The set of licenses declared for this package. This does not necessarily correspond to the licenses as detected
* by a scanner. Both need to be taken into account for any conclusions.
Expand Down Expand Up @@ -138,6 +148,7 @@ data class Package(
id = Identifier.EMPTY,
purl = "",
authors = sortedSetOf(),
concludedCopyrights = sortedSetOf(),
declaredLicenses = sortedSetOf(),
declaredLicensesProcessed = ProcessedDeclaredLicense.EMPTY,
concludedLicense = null,
Expand Down
8 changes: 8 additions & 0 deletions model/src/main/kotlin/PackageCurationData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ data class PackageCurationData(
*/
val authors: SortedSet<String>? = null,

/**
* The set of concluded copyright statements for the package. It can be used to override the [detected copyright
* statements][CopyrightFinding.statement].
*/
val concludedCopyrights: SortedSet<String>? = null,

/**
* The concluded license as an [SpdxExpression]. It can be used to override the [declared][Package.declaredLicenses]
* / [detected][LicenseFinding.license] licenses of a package.
Expand Down Expand Up @@ -131,6 +137,7 @@ data class PackageCurationData(
purl = purl ?: original.purl,
cpe = cpe ?: original.cpe,
authors = authors ?: original.authors,
concludedCopyrights = concludedCopyrights ?: original.concludedCopyrights,
declaredLicenses = original.declaredLicenses,
declaredLicensesProcessed = declaredLicensesProcessed,
concludedLicense = concludedLicense ?: original.concludedLicense,
Expand Down Expand Up @@ -170,6 +177,7 @@ data class PackageCurationData(
purl = purl ?: other.purl,
cpe = cpe ?: other.cpe,
authors = (authors.orEmpty() + other.authors.orEmpty()).toSortedSet(),
concludedCopyrights = (concludedCopyrights.orEmpty() + other.concludedCopyrights.orEmpty()).toSortedSet(),
concludedLicense = setOfNotNull(concludedLicense, other.concludedLicense).reduce(SpdxExpression::and),
description = description ?: other.description,
homepageUrl = homepageUrl ?: other.homepageUrl,
Expand Down
5 changes: 0 additions & 5 deletions model/src/main/kotlin/config/OrtConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ data class OrtConfiguration(
*/
val licenseFilePatterns: LicenseFilenamePatterns = LicenseFilenamePatterns.DEFAULT,

/**
* A flag to indicate whether authors should be considered as copyright holders.
*/
val addAuthorsToCopyrights: Boolean = false,

/**
* The threshold from which on issues count as severe.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,26 @@ class DefaultLicenseInfoProvider(
private fun createConcludedLicenseInfo(id: Identifier): ConcludedLicenseInfo =
ortResult.getPackage(id)?.let { (pkg, curations) ->
ConcludedLicenseInfo(
concludedCopyrights = pkg.concludedCopyrights,
concludedLicense = pkg.concludedLicense,
appliedCurations = curations.filter { it.curation.concludedLicense != null }
)
} ?: ConcludedLicenseInfo(concludedLicense = null, appliedCurations = emptyList())
} ?: ConcludedLicenseInfo(concludedCopyrights = null, concludedLicense = null, appliedCurations = emptyList())

private fun createDeclaredLicenseInfo(id: Identifier): DeclaredLicenseInfo =
ortResult.getProject(id)?.let { project ->
DeclaredLicenseInfo(
authors = project.authors,
licenses = project.declaredLicenses,
processed = project.declaredLicensesProcessed,
appliedCurations = emptyList()
)
} ?: ortResult.getPackage(id)?.let { (pkg, curations) ->
DeclaredLicenseInfo(
authors = pkg.authors,
licenses = pkg.declaredLicenses,
processed = pkg.declaredLicensesProcessed,
appliedCurations = curations.filter { it.curation.declaredLicenseMapping.isNotEmpty() }
)
} ?: DeclaredLicenseInfo(
authors = sortedSetOf(),
licenses = emptySet(),
processed = ProcessedDeclaredLicense(null),
appliedCurations = emptyList()
Expand Down
10 changes: 5 additions & 5 deletions model/src/main/kotlin/licenses/LicenseInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ data class LicenseInfo(
* Information about the concluded license of a package or project.
*/
data class ConcludedLicenseInfo(
/**
* The concluded copyright statements, or null if no copyrights were concluded.
*/
val concludedCopyrights: SortedSet<String>?,

/**
* The concluded license, or null if no license was concluded.
*/
Expand All @@ -77,11 +82,6 @@ data class ConcludedLicenseInfo(
* Information about the declared license of a package or project.
*/
data class DeclaredLicenseInfo(
/**
* The set of authors.
*/
val authors: SortedSet<String>,

/**
* The unmodified set of declared licenses.
*/
Expand Down
9 changes: 2 additions & 7 deletions model/src/main/kotlin/licenses/LicenseInfoResolver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import org.ossreviewtoolkit.utils.spdx.SpdxSingleLicenseExpression
class LicenseInfoResolver(
private val provider: LicenseInfoProvider,
private val copyrightGarbage: CopyrightGarbage,
val addAuthorsToCopyrights: Boolean,
val archiver: FileArchiver?,
val licenseFilenamePatterns: LicenseFilenamePatterns = LicenseFilenamePatterns.DEFAULT
) {
Expand Down Expand Up @@ -98,17 +97,13 @@ class LicenseInfoResolver(
it == license
}.keys

licenseInfo.declaredLicenseInfo.authors.takeIf { it.isNotEmpty() && addAuthorsToCopyrights }?.also {
licenseInfo.concludedLicenseInfo.concludedCopyrights?.takeIf { it.isNotEmpty() }?.also {
locations += ResolvedLicenseLocation(
provenance = UnknownProvenance,
location = UNDEFINED_TEXT_LOCATION,
appliedCuration = null,
matchingPathExcludes = emptyList(),
copyrights = it.mapTo(mutableSetOf()) { author ->
val statement = "Copyright (C) $author".takeUnless {
author.contains("Copyright", ignoreCase = true)
} ?: author

copyrights = it.mapTo(mutableSetOf()) { statement ->
ResolvedCopyrightFinding(
statement = statement,
location = UNDEFINED_TEXT_LOCATION,
Expand Down
2 changes: 0 additions & 2 deletions model/src/main/kotlin/utils/OrtResultExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ import org.ossreviewtoolkit.model.licenses.LicenseInfoResolver
fun OrtResult.createLicenseInfoResolver(
packageConfigurationProvider: PackageConfigurationProvider = PackageConfigurationProvider.EMPTY,
copyrightGarbage: CopyrightGarbage = CopyrightGarbage(),
addAuthorsToCopyrights: Boolean = false,
archiver: FileArchiver? = null
) = LicenseInfoResolver(
DefaultLicenseInfoProvider(this, packageConfigurationProvider),
copyrightGarbage,
addAuthorsToCopyrights,
archiver,
LicenseFilenamePatterns.getInstance()
)
Expand Down
6 changes: 6 additions & 0 deletions model/src/test/kotlin/PackageCurationDataTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PackageCurationDataTest : WordSpec({
purl = "original",
cpe = "original",
authors = sortedSetOf("original"),
concludedCopyrights = sortedSetOf("original"),
concludedLicense = "original".toSpdx(),
description = "original",
homepageUrl = "original",
Expand Down Expand Up @@ -57,6 +58,7 @@ class PackageCurationDataTest : WordSpec({
purl = "other",
cpe = "other",
authors = sortedSetOf("other"),
concludedCopyrights = sortedSetOf("other"),
concludedLicense = "other".toSpdx(),
description = "other",
homepageUrl = "other",
Expand Down Expand Up @@ -88,6 +90,7 @@ class PackageCurationDataTest : WordSpec({
val originalWithSomeUnsetData = original.copy(
comment = null,
authors = null,
concludedCopyrights = null,
concludedLicense = null,
binaryArtifact = null,
vcs = null,
Expand All @@ -98,6 +101,7 @@ class PackageCurationDataTest : WordSpec({
originalWithSomeUnsetData.merge(other) shouldBe originalWithSomeUnsetData.copy(
comment = other.comment,
authors = other.authors,
concludedCopyrights = other.concludedCopyrights,
concludedLicense = other.concludedLicense,
binaryArtifact = other.binaryArtifact,
vcs = other.vcs,
Expand All @@ -110,6 +114,7 @@ class PackageCurationDataTest : WordSpec({
original.merge(other) shouldBe original.copy(
comment = "original\nother",
authors = sortedSetOf("original", "other"),
concludedCopyrights = sortedSetOf("original", "other"),
concludedLicense = "original AND other".toSpdx(),
declaredLicenseMapping = mapOf(
"original" to "original".toSpdx(),
Expand All @@ -122,6 +127,7 @@ class PackageCurationDataTest : WordSpec({
val otherWithSomeOriginalData = other.copy(
comment = original.comment,
authors = original.authors,
concludedCopyrights = original.concludedCopyrights,
concludedLicense = original.concludedLicense,
declaredLicenseMapping = original.declaredLicenseMapping
)
Expand Down
7 changes: 5 additions & 2 deletions model/src/test/kotlin/PackageCurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class PackageCurationTest : WordSpec({
purl = "pkg:maven/org.hamcrest/[email protected]#subpath=src/main/java/org/hamcrest/core",
cpe = "cpe:2.3:a:apache:commons_io:2.8.0:rc2:*:*:*:*:*:*",
authors = sortedSetOf("author 1", "author 2"),
declaredLicenseMapping = mapOf("license a" to "Apache-2.0".toSpdx()),
concludedCopyrights = sortedSetOf("copyright 1", "copyright 2"),
concludedLicense = "license1 OR license2".toSpdx(),
description = "description",
homepageUrl = "http://home.page",
Expand All @@ -75,7 +75,8 @@ class PackageCurationTest : WordSpec({
path = "path"
),
isMetaDataOnly = true,
isModified = true
isModified = true,
declaredLicenseMapping = mapOf("license a" to "Apache-2.0".toSpdx())
)
)

Expand All @@ -86,6 +87,7 @@ class PackageCurationTest : WordSpec({
purl shouldBe curation.data.purl
cpe shouldBe curation.data.cpe
authors shouldBe curation.data.authors
concludedCopyrights shouldBe curation.data.concludedCopyrights
declaredLicenses shouldBe pkg.declaredLicenses
declaredLicensesProcessed.spdxExpression shouldBe "Apache-2.0".toSpdx()
declaredLicensesProcessed.unmapped should containExactlyInAnyOrder("license b")
Expand Down Expand Up @@ -147,6 +149,7 @@ class PackageCurationTest : WordSpec({
purl shouldBe pkg.purl
cpe shouldBe pkg.cpe
authors shouldBe pkg.authors
concludedCopyrights shouldBe pkg.concludedCopyrights
declaredLicenses shouldBe pkg.declaredLicenses
concludedLicense shouldBe pkg.concludedLicense
description shouldBe pkg.description
Expand Down

This file was deleted.

Loading