Skip to content

Commit

Permalink
fix(reporter): Only write major / minor SPDX license list version info
Browse files Browse the repository at this point in the history
Fixes #9606.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Dec 13, 2024
1 parent 8bc47a4 commit 3c62407
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private fun TestConfiguration.generateReport(

private fun SpdxDocument.getCustomReplacements() =
mapOf(
"<REPLACE_LICENSE_LIST_VERSION>" to SpdxLicense.LICENSE_LIST_VERSION.substringBefore("-"),
"<REPLACE_LICENSE_LIST_VERSION>" to SpdxLicense.LICENSE_LIST_VERSION.split('.').take(2).joinToString("."),
"<REPLACE_ORT_VERSION>" to Environment.ORT_VERSION,
"<REPLACE_CREATION_DATE_AND_TIME>" to creationInfo.created.toString(),
"<REPLACE_DOCUMENT_NAMESPACE>" to documentNamespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ internal object SpdxDocumentModelMapper {
comment = params.creationInfoComment,
created = Instant.now().truncatedTo(ChronoUnit.SECONDS),
creators = creators,
licenseListVersion = SpdxLicense.LICENSE_LIST_VERSION.substringBefore("-")
licenseListVersion = SpdxLicense.LICENSE_LIST_VERSION.split('.').take(2).joinToString(".")
),
documentNamespace = "spdx://${UUID.randomUUID()}",
documentDescribes = projectPackages.map { it.spdxId },
Expand Down
4 changes: 4 additions & 0 deletions utils/spdx/src/main/kotlin/model/SpdxCreationInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@ data class SpdxCreationInfo(
) {
init {
require(creators.isNotEmpty()) { "Creators must contain at least one entry, but was empty." }

require(licenseListVersion.isEmpty() || licenseListVersion.split('.').size == 2) {
"The license list version must contain exactly the major and minor parts."
}
}
}

0 comments on commit 3c62407

Please sign in to comment.