Skip to content

Commit 09bf9ca

Browse files
lamppusschuberth
authored andcommitted
refactor(dos): Remove fetchConcluded option
The `fetchConcluded` option will be removed from the endpoint on DOS API, so remove the option from the DOS scanner configuration, and the `options` parameter from the `ScanResultsRequestBody` class. This option was an experimental feature in the early development, and was mainly used to see the effects of the license conclusions before the DOS API also supported being used as a package configurations provider. There will be changes coming to the access to license conclusions on DOS API as users will be allowed to create their own license conclusions, and these will be linked to the organization the user belongs in, and the license conclusions will then be returned based on which organization they are queried for, so the scan results endpoint will be changed to only return the actual scanner findings (so in practice will behave as if `fetchConcluded` was set to `false`) to reduce maintenance efforts. Signed-off-by: Johanna Lamppu <[email protected]>
1 parent 8b82c4c commit 09bf9ca

File tree

5 files changed

+14
-37
lines changed

5 files changed

+14
-37
lines changed

clients/dos/src/main/kotlin/DosClient.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,18 @@ class DosClient(private val service: DosService) {
122122

123123
/**
124124
* Get scan results for a list of [packages]. In case multiple packages are provided, it is assumed that they all
125-
* refer to the same provenance (like a monorepo). If [fetchConcluded] is true, return concluded licenses instead of
126-
* detected licenses. Return either existing results, a "pending" message if the package is currently being scanned,
127-
* a "no-results" message if a scan yielded no results, or null on error. If only some of the packages exist in DOS
128-
* database (identified by purl), new bookmarks for the remaining packages are made (hence the need to provide the
129-
* declared licenses for these packages in this request).
125+
* refer to the same provenance (like a monorepo). Return either existing results, a "pending" message if the
126+
* package is currently being scanned, a "no-results" message if a scan yielded no results, or null on error. If
127+
* only some of the packages exist in DOS database (identified by purl), new bookmarks for the remaining packages
128+
* are made (hence the need to provide the declared licenses for these packages in this request).
130129
*/
131-
suspend fun getScanResults(packages: List<PackageInfo>, fetchConcluded: Boolean): ScanResultsResponseBody? {
130+
suspend fun getScanResults(packages: List<PackageInfo>): ScanResultsResponseBody? {
132131
if (packages.isEmpty()) {
133132
logger.error { "The list of PURLs to get scan results for must not be empty." }
134133
return null
135134
}
136135

137-
val options = ScanResultsRequestBody.ReqOptions(fetchConcluded)
138-
val requestBody = ScanResultsRequestBody(packages, options)
136+
val requestBody = ScanResultsRequestBody(packages)
139137
val response = service.getScanResults(requestBody)
140138
val responseBody = response.body()
141139

@@ -146,10 +144,6 @@ class DosClient(private val service: DosService) {
146144
"pending" -> logger.info { "Scan pending for $purls." }
147145
"ready" -> {
148146
logger.info { "Scan results ready for $purls." }
149-
150-
if (fetchConcluded) {
151-
logger.info { "Returning concluded licenses instead of detected licenses." }
152-
}
153147
}
154148
}
155149

clients/dos/src/main/kotlin/DosModel.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,8 @@ data class ScanResultsRequestBody(
6565
* refer to the same provenance (like a monorepo). If only some of the packages exist in the DOS database, new purl
6666
* bookmarks will be added for the missing packages (hence the need for the declared license here).
6767
*/
68-
val packages: List<PackageInfo>,
69-
70-
/** Options fort requesting scan results. */
71-
val options: ReqOptions? = null
72-
) {
73-
@Serializable
74-
data class ReqOptions(
75-
/** An option to fetch the concluded licenses along with the scan results. Defaults to "false". */
76-
val fetchConcluded: Boolean? = false
77-
)
78-
}
68+
val packages: List<PackageInfo>
69+
)
7970

8071
@Serializable
8172
data class ScanResultsResponseBody(

plugins/scanners/dos/src/main/kotlin/DosScanner.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class DosScanner(
115115

116116
// Ask for scan results from DOS API
117117
val existingScanResults = runCatching {
118-
client.getScanResults(packages, config.fetchConcluded)
118+
client.getScanResults(packages)
119119
}.onFailure {
120120
issues += createAndLogIssue(it.collectMessages())
121121
}.onSuccess {
@@ -232,7 +232,7 @@ class DosScanner(
232232
when (jobState.state.status) {
233233
"completed" -> {
234234
logger.info { "Scan completed for job with ID '$jobId'." }
235-
return client.getScanResults(listOf(pkg), config.fetchConcluded)
235+
return client.getScanResults(listOf(pkg))
236236
}
237237

238238
"failed" -> {

plugins/scanners/dos/src/main/kotlin/DosScannerConfig.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ data class DosScannerConfig(
3939
@OrtPluginOption(defaultValue = "5")
4040
val pollInterval: Long,
4141

42-
/** Use license conclusions as detected licenses when they exist? **/
43-
@OrtPluginOption(defaultValue = "false")
44-
val fetchConcluded: Boolean,
45-
4642
/** The URL where the DOS / package curation front-end is running. **/
4743
@OrtPluginOption(defaultValue = "http://localhost:3000")
4844
val frontendUrl: String,

plugins/scanners/dos/src/test/kotlin/DosScannerTest.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class DosScannerTest : StringSpec({
6969
token = Secret(""),
7070
timeout = 60L,
7171
pollInterval = 5L,
72-
fetchConcluded = false,
7372
frontendUrl = "http://localhost:3000"
7473
)
7574
}
@@ -87,7 +86,7 @@ class DosScannerTest : StringSpec({
8786
)
8887
)
8988

90-
scanner.client.getScanResults(emptyList(), false) shouldBe null
89+
scanner.client.getScanResults(emptyList()) shouldBe null
9190
}
9291

9392
"getScanResults() should return 'no-results' when no results in db" {
@@ -106,8 +105,7 @@ class DosScannerTest : StringSpec({
106105
purl = "purl",
107106
declaredLicenseExpressionSPDX = null
108107
)
109-
),
110-
false
108+
)
111109
)?.state?.status
112110

113111
status shouldBe "no-results"
@@ -129,8 +127,7 @@ class DosScannerTest : StringSpec({
129127
purl = "purl",
130128
declaredLicenseExpressionSPDX = null
131129
)
132-
),
133-
false
130+
)
134131
)
135132

136133
response?.state?.status shouldBe "pending"
@@ -153,8 +150,7 @@ class DosScannerTest : StringSpec({
153150
purl = "purl",
154151
declaredLicenseExpressionSPDX = null
155152
)
156-
),
157-
false
153+
)
158154
)
159155

160156
val actualJson = JSON.encodeToString(response?.results)

0 commit comments

Comments
 (0)