diff --git a/code/hsec-tools/hsec-tools.cabal b/code/hsec-tools/hsec-tools.cabal index 79db3d12..27fe9c33 100644 --- a/code/hsec-tools/hsec-tools.cabal +++ b/code/hsec-tools/hsec-tools.cabal @@ -50,7 +50,7 @@ library containers >= 0.6 && < 0.7, commonmark ^>= 0.2.2, aeson >= 2.0.1.0 && < 3, - toml-parser ^>=1.2.1.0, + toml-parser ^>=1.3.0.0, pandoc-types >= 1.22 && < 2, pathwalk >= 0.3, parsec >= 3 && < 4, diff --git a/code/hsec-tools/src/Security/Advisories/Parse.hs b/code/hsec-tools/src/Security/Advisories/Parse.hs index a4d34392..6b762def 100644 --- a/code/hsec-tools/src/Security/Advisories/Parse.hs +++ b/code/hsec-tools/src/Security/Advisories/Parse.hs @@ -35,6 +35,7 @@ import qualified Commonmark.Parser as Commonmark import Commonmark.Types (HasAttributes(..), IsBlock(..), IsInline(..), Rangeable(..), SourceRange(..)) import Commonmark.Pandoc (Cm(unCm)) import qualified Toml +import qualified Toml.Pretty as Toml import qualified Toml.FromValue as Toml import qualified Toml.FromValue.Matcher as Toml import qualified Toml.ToValue as Toml @@ -77,7 +78,7 @@ data ParseAdvisoryError = MarkdownError Commonmark.ParseError T.Text | MarkdownFormatError T.Text | TomlError String T.Text - | AdvisoryError [String] T.Text + | AdvisoryError [Toml.MatchMessage] T.Text deriving stock (Eq, Show, Generic) -- | The main parsing function. 'OutOfBandAttributes' are handled @@ -126,10 +127,10 @@ parseAdvisory policy attrs raw = do (Commonmark.commonmark "input" raw :: Either Commonmark.ParseError (Html ())) case parseAdvisoryTable attrs policy doc summary details html table of - Toml.Failure es -> Left (AdvisoryError es (T.pack (unlines es))) + Toml.Failure es -> Left (AdvisoryError es (T.pack (unlines (map Toml.prettyMatchMessage es)))) Toml.Success warnings adv | null warnings -> pure adv - | otherwise -> Left (AdvisoryError warnings (T.pack (unlines warnings))) -- treat warnings as errors + | otherwise -> Left (AdvisoryError warnings (T.pack (unlines (map Toml.prettyMatchMessage warnings)))) -- treat warnings as errors where firstPretty @@ -154,7 +155,7 @@ parseAdvisoryTable -> T.Text -- ^ details -> T.Text -- ^ rendered HTML -> Toml.Table - -> Toml.Result Advisory + -> Toml.Result Toml.MatchMessage Advisory parseAdvisoryTable oob policy doc summary details html tab = Toml.runMatcher $ do fm <- Toml.fromValue (Toml.Table tab)