Skip to content

Commit

Permalink
osv: fix ToJSON encoding of Severity object
Browse files Browse the repository at this point in the history
"type" and "score" fields were mixed up.  Put them straight.

Fixes: #135
  • Loading branch information
frasertweedale authored and TristanCacqueray committed Dec 13, 2023
1 parent d66c8e4 commit cb9cd04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions code/hsec-tools/src/Security/OSV.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ instance FromJSON Severity where
$ typeMismatch "severity" (Object o)

instance ToJSON Severity where
toJSON (Severity cvss) = object ["type" .= CVSS.cvssVectorString cvss, "score" .= score]
toJSON (Severity cvss) = object ["score" .= CVSS.cvssVectorString cvss, "type" .= typ]
where
score :: Text
score = case CVSS.cvssVersion cvss of
typ :: Text
typ = case CVSS.cvssVersion cvss of
CVSS.CVSS31 -> "CVSS_V3"
CVSS.CVSS30 -> "CVSS_V3"
CVSS.CVSS20 -> "CVSS_V2"
Expand Down

0 comments on commit cb9cd04

Please sign in to comment.