From 53efb4ba5bdf4b6f9951801e05a906518a8e73af Mon Sep 17 00:00:00 2001 From: Nicolas Nobelis Date: Fri, 19 May 2023 08:26:50 +0200 Subject: [PATCH] fix(fossid-webapp): Make Snippet `url` property non-nullable This is a follow-up of the discussion at [1]: Since FossID does not document the data model of the API response, the `url` property of the `Snippet` has been defensively made nullable. Since then, FossID support confirmed that the property is never `null` in the API responses: While the database schema indeed has this property as nullable, the CLI tool used by the scanner guarantee it is never null. [1]: https://github.com/oss-review-toolkit/ort/pull/6791#discussion_r1191036017 Signed-off-by: Nicolas Nobelis --- .../fossid-webapp/src/main/kotlin/model/result/Snippet.kt | 2 +- scanner/src/main/kotlin/scanners/fossid/FossId.kt | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/clients/fossid-webapp/src/main/kotlin/model/result/Snippet.kt b/clients/fossid-webapp/src/main/kotlin/model/result/Snippet.kt index 50f51a4bf8c41..6446877059bb2 100644 --- a/clients/fossid-webapp/src/main/kotlin/model/result/Snippet.kt +++ b/clients/fossid-webapp/src/main/kotlin/model/result/Snippet.kt @@ -38,7 +38,7 @@ data class Snippet( val file: String, val fileLicense: String?, - val url: String?, + val url: String, val hits: String, val size: Int?, diff --git a/scanner/src/main/kotlin/scanners/fossid/FossId.kt b/scanner/src/main/kotlin/scanners/fossid/FossId.kt index 756b316b2feef..33cbe9f0a894d 100644 --- a/scanner/src/main/kotlin/scanners/fossid/FossId.kt +++ b/scanner/src/main/kotlin/scanners/fossid/FossId.kt @@ -822,10 +822,8 @@ class FossId internal constructor( // FossID does not return the hash of the remote artifact. Instead, it returns the MD5 hash of the // matched file in the remote artifact as part of the "match_file_id" property. - val snippetProvenance = it.url?.let { url -> - ArtifactProvenance(RemoteArtifact(url, Hash.NONE)) - } ?: UnknownProvenance - val purlType = it.url?.let { url -> urlToPackageType(url).toString() } + val snippetProvenance = ArtifactProvenance(RemoteArtifact(it.url, Hash.NONE)) + val purlType = urlToPackageType(it.url).toString() // TODO: FossID doesn't return the line numbers of the match, only the character range. One must use // another call "getMatchedLine" to retrieve the matched line numbers. Unfortunately, this is a