Skip to content

Commit cb9cd04

Browse files
frasertweedaleTristanCacqueray
authored andcommitted
osv: fix ToJSON encoding of Severity object
"type" and "score" fields were mixed up. Put them straight. Fixes: #135
1 parent d66c8e4 commit cb9cd04

File tree

1 file changed

+3
-3
lines changed
  • code/hsec-tools/src/Security

1 file changed

+3
-3
lines changed

code/hsec-tools/src/Security/OSV.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ instance FromJSON Severity where
171171
$ typeMismatch "severity" (Object o)
172172

173173
instance ToJSON Severity where
174-
toJSON (Severity cvss) = object ["type" .= CVSS.cvssVectorString cvss, "score" .= score]
174+
toJSON (Severity cvss) = object ["score" .= CVSS.cvssVectorString cvss, "type" .= typ]
175175
where
176-
score :: Text
177-
score = case CVSS.cvssVersion cvss of
176+
typ :: Text
177+
typ = case CVSS.cvssVersion cvss of
178178
CVSS.CVSS31 -> "CVSS_V3"
179179
CVSS.CVSS30 -> "CVSS_V3"
180180
CVSS.CVSS20 -> "CVSS_V2"

0 commit comments

Comments
 (0)