Skip to content

Commit

Permalink
fix(cargo): Only read checksum metadata entries as hashes
Browse files Browse the repository at this point in the history
Ignore metadata entries that do not start with "checksum ". This at the
same time simplifies code as a fixup for 44523e4 since when `v`
definitely is of type `String`.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jan 12, 2024
1 parent 6ae49d8 commit 488027d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/package-managers/cargo/src/main/kotlin/Cargo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import org.ossreviewtoolkit.model.orEmpty
import org.ossreviewtoolkit.utils.common.CommandLineTool
import org.ossreviewtoolkit.utils.common.splitOnWhitespace
import org.ossreviewtoolkit.utils.common.unquote
import org.ossreviewtoolkit.utils.common.withoutPrefix
import org.ossreviewtoolkit.utils.ort.DeclaredLicenseProcessor
import org.ossreviewtoolkit.utils.ort.ProcessedDeclaredLicense
import org.ossreviewtoolkit.utils.spdx.SpdxConstants
Expand Down Expand Up @@ -121,7 +122,7 @@ class Cargo(

else -> {
contents.metadata.mapNotNull { (k, v) ->
(v as? String)?.let { k.unquote().removePrefix("checksum ") to v }
k.unquote().withoutPrefix("checksum ")?.let { it to v }
}
}
}.toMap()
Expand Down

0 comments on commit 488027d

Please sign in to comment.