Skip to content

Commit d395b12

Browse files
committed
fix(tools): support GHC < 9.2.1
1 parent 214335c commit d395b12

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

code/hsec-tools/hsec-tools.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ library
3535
, Security.Advisories.Generate.HTML
3636
, Security.OSV
3737
build-depends: base >=4.14 && < 4.19,
38-
directory ^>= 1.3.6.1,
38+
directory < 2,
3939
extra ^>=1.7.5,
4040
filepath >= 1.4 && < 1.5,
41-
lucid2 >= 0.0.20220526,
41+
lucid >= 2.9.0,
4242
process >= 1.6 && < 1.7,
4343
text >= 1.2 && < 3,
4444
time >= 1.9 && < 1.14,

code/hsec-tools/src/Security/Advisories/Generate/HTML.hs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE DerivingStrategies #-}
22
{-# LANGUAGE LambdaCase #-}
3-
{-# LANGUAGE OverloadedRecordDot #-}
43
{-# LANGUAGE OverloadedStrings #-}
54

65
module Security.Advisories.Generate.HTML
@@ -59,10 +58,10 @@ renderAdvisoriesIndex src dst = do
5958
let advisoriesDir = dst </> "advisory"
6059
createDirectoryIfMissing False advisoriesDir
6160
forM_ advisories $ \advisory ->
62-
renderToFile' (advisoriesDir </> advisoryHtmlFilename advisory.advisoryId) $
61+
renderToFile' (advisoriesDir </> advisoryHtmlFilename (Advisories.advisoryId advisory)) $
6362
inPage PageAdvisory $
6463
div_ [class_ "pure-u-1"] $
65-
toHtmlRaw advisory.advisoryHtml
64+
toHtmlRaw (Advisories.advisoryHtml advisory)
6665

6766
-- * Rendering types
6867

@@ -97,13 +96,13 @@ listByDates advisories =
9796
tbody_ $ do
9897
let sortedAdvisories =
9998
zip
100-
(sortOn (Down . (.advisoryId)) advisories)
99+
(sortOn (Down . advisoryId) advisories)
101100
(cycle [[], [class_ "pure-table-odd"]])
102101
forM_ sortedAdvisories $ \(advisory, trClasses) ->
103102
tr_ trClasses $ do
104-
td_ [class_ "advisory-id"] $ a_ [href_ $ advisoryLink advisory.advisoryId] $ toHtml (Advisories.printHsecId advisory.advisoryId)
105-
td_ [class_ "advisory-packages"] $ toHtml $ T.intercalate "," $ (.packageName) <$> advisory.advisoryAffected
106-
td_ [class_ "advisory-summary"] $ toHtml advisory.advisorySummary
103+
td_ [class_ "advisory-id"] $ a_ [href_ $ advisoryLink (advisoryId advisory)] $ toHtml (Advisories.printHsecId (advisoryId advisory))
104+
td_ [class_ "advisory-packages"] $ toHtml $ T.intercalate "," $ packageName <$> advisoryAffected advisory
105+
td_ [class_ "advisory-summary"] $ toHtml $ advisorySummary advisory
107106

108107
listByPackages :: [AdvisoryR] -> Html ()
109108
listByPackages advisories =
@@ -113,9 +112,9 @@ listByPackages advisories =
113112
byPackage =
114113
Map.fromList $
115114
groupSort
116-
[ (package.packageName, (advisory, package))
115+
[ (packageName package, (advisory, package))
117116
| advisory <- advisories,
118-
package <- advisory.advisoryAffected
117+
package <- advisoryAffected advisory
119118
]
120119

121120
forM_ (Map.toList byPackage) $ \(currentPackageName, perPackageAdvisory) -> do
@@ -132,14 +131,14 @@ listByPackages advisories =
132131
tbody_ $ do
133132
let sortedAdvisories =
134133
zip
135-
(sortOn (Down . (.advisoryId) . fst) perPackageAdvisory)
134+
(sortOn (Down . advisoryId . fst) perPackageAdvisory)
136135
(cycle [[], [class_ "pure-table-odd"]])
137136
forM_ sortedAdvisories $ \((advisory, package), trClasses) ->
138137
tr_ trClasses $ do
139-
td_ [class_ "advisory-id"] $ a_ [href_ $ advisoryLink advisory.advisoryId] $ toHtml (Advisories.printHsecId advisory.advisoryId)
140-
td_ [class_ "advisory-introduced"] $ toHtml package.introduced
141-
td_ [class_ "advisory-fixed"] $ maybe (return ()) toHtml package.fixed
142-
td_ [class_ "advisory-summary"] $ toHtml advisory.advisorySummary
138+
td_ [class_ "advisory-id"] $ a_ [href_ $ advisoryLink $ advisoryId advisory] $ toHtml (Advisories.printHsecId $ advisoryId advisory)
139+
td_ [class_ "advisory-introduced"] $ toHtml $ introduced package
140+
td_ [class_ "advisory-fixed"] $ maybe (return ()) toHtml $ fixed package
141+
td_ [class_ "advisory-summary"] $ toHtml $ advisorySummary advisory
143142

144143
-- * Utils
145144

@@ -199,16 +198,16 @@ advisoryLink advisoryId' = "/advisory/" <> T.pack (advisoryHtmlFilename advisory
199198
toAdvisoryR :: Advisories.Advisory -> AdvisoryR
200199
toAdvisoryR x =
201200
AdvisoryR
202-
{ advisoryId = x.advisoryId,
203-
advisorySummary = x.advisorySummary,
204-
advisoryAffected = concatMap toAffectedPackageR x.advisoryAffected
201+
{ advisoryId = Advisories.advisoryId x,
202+
advisorySummary = Advisories.advisorySummary x,
203+
advisoryAffected = concatMap toAffectedPackageR $ Advisories.advisoryAffected x
205204
}
206205
where
207206
toAffectedPackageR :: Advisories.Affected -> [AffectedPackageR]
208207
toAffectedPackageR p =
209-
flip map p.affectedVersions $ \versionRange ->
208+
flip map (Advisories.affectedVersions p) $ \versionRange ->
210209
AffectedPackageR
211-
{ packageName = p.affectedPackage,
212-
introduced = versionRange.affectedVersionRangeIntroduced,
213-
fixed = versionRange.affectedVersionRangeFixed
210+
{ packageName = Advisories.affectedPackage p,
211+
introduced = Advisories.affectedVersionRangeIntroduced versionRange,
212+
fixed = Advisories.affectedVersionRangeFixed versionRange
214213
}

0 commit comments

Comments
 (0)