diff --git a/plugins/scanners/fossid/src/main/kotlin/FossIdConfig.kt b/plugins/scanners/fossid/src/main/kotlin/FossIdConfig.kt index 4f63433ed8b94..4d130efdc430c 100644 --- a/plugins/scanners/fossid/src/main/kotlin/FossIdConfig.kt +++ b/plugins/scanners/fossid/src/main/kotlin/FossIdConfig.kt @@ -83,6 +83,9 @@ data class FossIdConfig( /** The name of the FossID project. If `null`, the name will be determined from the repository URL. */ val projectName: String?, + /** The pattern for scan names when scans are created on the FossID instance. If null, a default pattern is used. */ + val namingScanPattern: String?, + /** Flag whether the scanner should wait for the completion of FossID scans. */ val waitForResult: Boolean, @@ -116,10 +119,7 @@ data class FossIdConfig( val sensitivity: Int, /** A comma-separated list of URL mappings. */ - val urlMappings: String?, - - /** Stores the map with FossID-specific configuration options. */ - private val options: Map + val urlMappings: String? ) { companion object { /** Name of the configuration property for the server URL. */ @@ -197,6 +197,7 @@ data class FossIdConfig( ?: throw IllegalArgumentException("No FossID API Key configuration found.") val projectName = options[PROP_PROJECT_NAME] + val namingScanPattern = options[PROP_NAMING_SCAN_PATTERN] val waitForResult = options[PROP_WAIT_FOR_RESULT]?.toBooleanStrict() ?: true @@ -231,6 +232,7 @@ data class FossIdConfig( user = user, apiKey = apiKey, projectName = projectName, + namingScanPattern = namingScanPattern, waitForResult = waitForResult, keepFailedScans = keepFailedScans, deltaScans = deltaScans, @@ -239,10 +241,9 @@ data class FossIdConfig( detectCopyrightStatements = detectCopyrightStatements, timeout = timeout, fetchSnippetMatchedLines = fetchSnippetMatchedLines, - options = options, snippetsLimit = snippetsLimit, sensitivity = sensitivity, - urlMappings = urlMappings, + urlMappings = urlMappings ) } } @@ -250,13 +251,7 @@ data class FossIdConfig( /** * Create a [FossIdNamingProvider] helper object based on the configuration stored in this object. */ - fun createNamingProvider(): FossIdNamingProvider { - val namingScanPattern = options[PROP_NAMING_SCAN_PATTERN]?.also { - logger.info { "Naming pattern for scans is $it." } - } - - return FossIdNamingProvider(namingScanPattern, projectName) - } + fun createNamingProvider() = FossIdNamingProvider(namingScanPattern, projectName) /** * Create a [FossIdUrlProvider] helper object based on the configuration stored in this object. diff --git a/plugins/scanners/fossid/src/test/kotlin/FossIdConfigTest.kt b/plugins/scanners/fossid/src/test/kotlin/FossIdConfigTest.kt index a23a4ab8f07bd..9f91ceff2349e 100644 --- a/plugins/scanners/fossid/src/test/kotlin/FossIdConfigTest.kt +++ b/plugins/scanners/fossid/src/test/kotlin/FossIdConfigTest.kt @@ -44,6 +44,7 @@ class FossIdConfigTest : WordSpec({ val options = mapOf( "serverUrl" to SERVER_URL, "projectName" to PROJECT, + "namingScanPattern" to "#repositoryName_#deltaTag", "waitForResult" to "false", "keepFailedScans" to "true", "deltaScans" to "true", @@ -68,6 +69,7 @@ class FossIdConfigTest : WordSpec({ user = USER, apiKey = API_KEY, projectName = PROJECT, + namingScanPattern = "#repositoryName_#deltaTag", waitForResult = false, keepFailedScans = true, deltaScans = true, @@ -76,7 +78,6 @@ class FossIdConfigTest : WordSpec({ detectCopyrightStatements = true, timeout = 300, fetchSnippetMatchedLines = true, - options = options, snippetsLimit = 1000, sensitivity = 10, urlMappings = "https://example.org(?.*) -> ssh://example.org\${repoPath}" @@ -98,6 +99,7 @@ class FossIdConfigTest : WordSpec({ user = USER, apiKey = API_KEY, projectName = null, + namingScanPattern = null, waitForResult = true, keepFailedScans = false, deltaScans = false, @@ -106,7 +108,6 @@ class FossIdConfigTest : WordSpec({ detectCopyrightStatements = false, timeout = 60, fetchSnippetMatchedLines = false, - options = options, snippetsLimit = 500, sensitivity = 10, urlMappings = null diff --git a/plugins/scanners/fossid/src/test/kotlin/TestUtils.kt b/plugins/scanners/fossid/src/test/kotlin/TestUtils.kt index 5346c26699991..3e05c81fbdcd9 100644 --- a/plugins/scanners/fossid/src/test/kotlin/TestUtils.kt +++ b/plugins/scanners/fossid/src/test/kotlin/TestUtils.kt @@ -130,6 +130,7 @@ internal fun createConfig( user = USER, apiKey = API_KEY, projectName = projectName, + namingScanPattern = null, waitForResult = waitForResult, keepFailedScans = false, deltaScans = deltaScans, @@ -138,7 +139,6 @@ internal fun createConfig( detectCopyrightStatements = false, timeout = 60, fetchSnippetMatchedLines = fetchSnippetMatchedLines, - options = emptyMap(), snippetsLimit = snippetsLimit, sensitivity = 10, urlMappings = null