From 4262a32e743fea2fc873c3e1393b1730d5bfc9e9 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Wed, 6 Apr 2022 15:48:59 +0100 Subject: [PATCH] Fix the type of signatures in metadata Signatures are actually complex objects. We could use `Value` here since it's unlikely that any consumers care about this, but it's cheap enough to just define a structure for the signature objects. In practice this isn't an issue because it seems like this field is never populated in Hackage, but it can be populated if you build a custom Hackage it can happen. Fixes #573. --- hackage-db/src/Distribution/Hackage/DB/MetaData.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hackage-db/src/Distribution/Hackage/DB/MetaData.hs b/hackage-db/src/Distribution/Hackage/DB/MetaData.hs index 956406a04..880188458 100644 --- a/hackage-db/src/Distribution/Hackage/DB/MetaData.hs +++ b/hackage-db/src/Distribution/Hackage/DB/MetaData.hs @@ -35,7 +35,7 @@ parseMetaData :: ByteString -> MetaData parseMetaData = either (throw . InvalidMetaFile) id . eitherDecode data MetaData = MetaData { signed :: SignedMetaData - , signatures :: [String] + , signatures :: [Signature] } deriving (Show, Generic) @@ -56,3 +56,10 @@ data TargetData = TargetData { length :: Int deriving (Show, Generic) instance FromJSON TargetData + +data Signature = Signature { keyid :: String + , method :: String + , sig :: String } + deriving (Show, Generic) + +instance FromJSON Signature