Skip to content

Commit

Permalink
fix(fossid-webapp): Make Snippet url property non-nullable
Browse files Browse the repository at this point in the history
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]: oss-review-toolkit#6791 (comment)

Signed-off-by: Nicolas Nobelis <nicolas.nobelis@bosch.io>
  • Loading branch information
nnobelis committed May 19, 2023
1 parent 48da67a commit 53efb4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?,

Expand Down
6 changes: 2 additions & 4 deletions scanner/src/main/kotlin/scanners/fossid/FossId.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53efb4b

Please sign in to comment.