Skip to content

Commit d01609a

Browse files
MarcelBochtlermnonnenmacher
authored andcommitted
FossIdScanResults: Replace problematic FossID licenses with valid expressions
Some license expressions from FossID cannot be parsed to SPDX expressions. These licenses result in an exception if `toSpdx()` used on them. Replace these problematic expressions with valid SPDX expressions. Signed-off-by: Marcel Bochtler <[email protected]>
1 parent ba2851f commit d01609a

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

scanner/src/main/kotlin/scanners/fossid/FossIdScanResults.kt

+31-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,34 @@ import org.ossreviewtoolkit.clients.fossid.model.summary.Summarizable
2626
import org.ossreviewtoolkit.model.CopyrightFinding
2727
import org.ossreviewtoolkit.model.LicenseFinding
2828
import org.ossreviewtoolkit.model.TextLocation
29+
import org.ossreviewtoolkit.utils.spdx.toSpdx
30+
31+
/**
32+
* Collection of problematic FossID license expressions. Compiled from FossID's list of licenses. May be updated if
33+
* FossID adds new licenses.
34+
*/
35+
private val fossIdLicenseMappings = mapOf(
36+
"BSD (Three Clause License)" to "BSD-3-clause".toSpdx(),
37+
"BSD-Acknowledgment-(Carrot2)" to "LicenseRef-scancode-bsd-ack-carrot2".toSpdx(),
38+
"Freeware-Public-(FPL)" to "LicenseRef-scancode-fpl".toSpdx(),
39+
"MediaInfo(Lib)" to "LicenseRef-scancode-mediainfo-lib".toSpdx(),
40+
"Oracle-Master-Agreement-(OMA)" to "LicenseRef-scancode-oracle-master-agreement".toSpdx(),
41+
"Things-I-Made-(TIM)-Public" to "LicenseRef-scancode-things-i-made-public-license".toSpdx(),
42+
"X11-Style-(Adobe)" to "LicenseRef-scancode-x11-adobe".toSpdx(),
43+
"X11-Style-(Adobe-DEC)" to "LicenseRef-scancode-x11-adobe-dec".toSpdx(),
44+
"X11-Style-(Bitstream-Charter)" to "LicenseRef-scancode-x11-bitstream".toSpdx(),
45+
"X11-Style-(DEC-1)" to "LicenseRef-scancode-x11-dec1".toSpdx(),
46+
"X11-Style-(DEC-2)" to "LicenseRef-scancode-x11-dec2".toSpdx(),
47+
"X11-Style-(DSC-Technologies)" to "LicenseRef-scancode-x11-dsc".toSpdx(),
48+
"X11-Style-(David-R.-Hanson)" to "LicenseRef-scancode-x11-hanson".toSpdx(),
49+
"X11-Style-(Lucent)" to "LicenseRef-scancode-x11-lucent".toSpdx(),
50+
"X11-Style-(OAR)" to "LicenseRef-scancode-x11-oar".toSpdx(),
51+
"X11-Style-(Open-Group)" to "MIT-open-group".toSpdx(),
52+
"X11-Style-(Quarterdeck)" to "LicenseRef-scancode-x11-quarterdeck".toSpdx(),
53+
"X11-Style-(Realmode)" to "LicenseRef-scancode-x11-realmode".toSpdx(),
54+
"X11-Style-(Silicon-Graphics)" to "LicenseRef-scancode-x11-sg".toSpdx(),
55+
"X11-Style-(Tektronix)" to "LicenseRef-scancode-x11-tektronix".toSpdx()
56+
)
2957

3058
/**
3159
* A data class to hold FossID raw results.
@@ -58,7 +86,9 @@ internal fun <T : Summarizable> List<T>.mapSummary(ignoredFiles: Map<String, Ign
5886
val location = TextLocation(summary.path, TextLocation.UNKNOWN_LINE, TextLocation.UNKNOWN_LINE)
5987

6088
summary.licences.forEach {
61-
val finding = LicenseFinding(it.identifier, location)
89+
val license = fossIdLicenseMappings[it.identifier] ?: it.identifier.toSpdx()
90+
91+
val finding = LicenseFinding(license, location)
6292
licenseFindings += finding
6393
}
6494

0 commit comments

Comments
 (0)