hackage-security 0.6.2.4 → 0.6.2.5
raw patch · 46 files changed
+122/−351 lines, 46 filesdep ~Cabaldep ~Cabal-syntaxdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: Cabal, Cabal-syntax, base, bytestring, containers, directory, filepath, ghc-prim, mtl, parsec, tar, template-haskell, time
API changes (from Hackage documentation)
- Hackage.Security.Client: class DownloadedFile (down :: * -> *)
+ Hackage.Security.Client: class DownloadedFile (down :: Type -> Type)
- Hackage.Security.Client: data IndexFile :: * -> *
+ Hackage.Security.Client: data IndexFile :: Type -> Type
- Hackage.Security.Client: data SomeRemoteError :: *
+ Hackage.Security.Client: data SomeRemoteError :: Type
- Hackage.Security.Client.Formats: data Format :: * -> *
+ Hackage.Security.Client.Formats: data Format :: Type -> Type
- Hackage.Security.Client.Formats: data Formats :: * -> * -> *
+ Hackage.Security.Client.Formats: data Formats :: Type -> Type -> Type
- Hackage.Security.Client.Formats: data HasFormat :: * -> * -> *
+ Hackage.Security.Client.Formats: data HasFormat :: Type -> Type -> Type
- Hackage.Security.Client.Repository: class DownloadedFile (down :: * -> *)
+ Hackage.Security.Client.Repository: class DownloadedFile (down :: Type -> Type)
- Hackage.Security.Client.Repository: data IndexFile :: * -> *
+ Hackage.Security.Client.Repository: data IndexFile :: Type -> Type
- Hackage.Security.Client.Repository: data IsCached :: * -> *
+ Hackage.Security.Client.Repository: data IsCached :: Type -> Type
- Hackage.Security.Client.Repository: data RemoteFile :: * -> * -> *
+ Hackage.Security.Client.Repository: data RemoteFile :: Type -> Type -> Type
- Hackage.Security.Client.Repository: data SomeRemoteError :: *
+ Hackage.Security.Client.Repository: data SomeRemoteError :: Type
- Hackage.Security.Client.Repository.Remote: data RemoteTemp :: * -> *
+ Hackage.Security.Client.Repository.Remote: data RemoteTemp :: Type -> Type
- Hackage.Security.Server: data IndexFile :: * -> *
+ Hackage.Security.Server: data IndexFile :: Type -> Type
- Hackage.Security.Trusted: data StaticPtr a
+ Hackage.Security.Trusted: data () => StaticPtr a
- Hackage.Security.Util.Path: data BufferMode
+ Hackage.Security.Util.Path: data () => BufferMode
- Hackage.Security.Util.Path: data Handle
+ Hackage.Security.Util.Path: data () => Handle
- Hackage.Security.Util.Path: data IOMode
+ Hackage.Security.Util.Path: data () => IOMode
- Hackage.Security.Util.Path: data SeekMode
+ Hackage.Security.Util.Path: data () => SeekMode
Files
- ChangeLog.md +13/−0
- hackage-security.cabal +31/−43
- src/Hackage/Security/Client.hs +3/−21
- src/Hackage/Security/Client/Formats.hs +5/−4
- src/Hackage/Security/Client/Repository.hs +6/−10
- src/Hackage/Security/Client/Repository/Cache.hs +1/−1
- src/Hackage/Security/Client/Repository/HttpLib.hs +1/−2
- src/Hackage/Security/Client/Repository/Local.hs +1/−1
- src/Hackage/Security/Client/Repository/Remote.hs +6/−11
- src/Hackage/Security/Client/Verify.hs +1/−1
- src/Hackage/Security/JSON.hs +1/−6
- src/Hackage/Security/Key.hs +1/−28
- src/Hackage/Security/Key/Env.hs +1/−1
- src/Hackage/Security/TUF/Common.hs +1/−1
- src/Hackage/Security/TUF/FileInfo.hs +1/−1
- src/Hackage/Security/TUF/FileMap.hs +1/−1
- src/Hackage/Security/TUF/Header.hs +1/−1
- src/Hackage/Security/TUF/Layout/Cache.hs +1/−1
- src/Hackage/Security/TUF/Layout/Index.hs +3/−2
- src/Hackage/Security/TUF/Layout/Repo.hs +1/−1
- src/Hackage/Security/TUF/Mirrors.hs +1/−1
- src/Hackage/Security/TUF/Paths.hs +1/−1
- src/Hackage/Security/TUF/Patterns.hs +6/−30
- src/Hackage/Security/TUF/Root.hs +1/−1
- src/Hackage/Security/TUF/Signed.hs +1/−1
- src/Hackage/Security/TUF/Snapshot.hs +1/−1
- src/Hackage/Security/TUF/Targets.hs +1/−1
- src/Hackage/Security/TUF/Timestamp.hs +1/−1
- src/Hackage/Security/Trusted.hs +2/−4
- src/Hackage/Security/Trusted/TCB.hs +1/−25
- src/Hackage/Security/Util/Base64.hs +1/−1
- src/Hackage/Security/Util/Checked.hs +5/−33
- src/Hackage/Security/Util/Exit.hs +1/−1
- src/Hackage/Security/Util/IO.hs +1/−1
- src/Hackage/Security/Util/JSON.hs +1/−17
- src/Hackage/Security/Util/Lens.hs +1/−1
- src/Hackage/Security/Util/Path.hs +2/−25
- src/Hackage/Security/Util/Pretty.hs +1/−1
- src/Hackage/Security/Util/Some.hs +1/−15
- src/Hackage/Security/Util/Stack.hs +1/−1
- src/Hackage/Security/Util/TypedEmbedded.hs +3/−2
- src/MyPrelude.hs +0/−31
- src/Text/JSON/Canonical.hs +2/−13
- tests/TestSuite.hs +4/−4
- tests/TestSuite/InMemRepo.hs +2/−1
- tests/TestSuite/JSON.hs +0/−1
ChangeLog.md view
@@ -1,5 +1,18 @@ See also http://pvp.haskell.org/faq +0.6.2.5+-------++* Allow `Cabal-3.12` and `Cabal-syntax-3.12`.+* Allow `zlib-0.7`.+* Drop flag `use-old-time` and support for `old-time`, require `time ≥ 1.5`+ ([PR #304](https://github.com/haskell/hackage-security/pull/304)).+* Drop support for GHC < 8.4+ ([PR #306](https://github.com/haskell/hackage-security/pull/306)).+* Code maintenance: address warning `star-is-type`, `unused-record-wildcards` etc.+ ([PR #306](https://github.com/haskell/hackage-security/pull/306)).+* Tested with GHC 8.4 - 9.8.+ 0.6.2.4 -------
hackage-security.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: hackage-security-version: 0.6.2.4+version: 0.6.2.5 synopsis: Hackage security library description: The hackage security library provides both server and@@ -31,8 +31,8 @@ build-type: Simple tested-with:- GHC == 9.8.1- GHC == 9.6.3+ GHC == 9.8.2+ GHC == 9.6.4 GHC == 9.4.8 GHC == 9.2.8 GHC == 9.0.2@@ -40,9 +40,6 @@ GHC == 8.8.4 GHC == 8.6.5 GHC == 8.4.4- GHC == 8.2.2- GHC == 8.0.2- GHC == 7.10.3 extra-source-files: ChangeLog.md@@ -110,41 +107,38 @@ Hackage.Security.Util.Lens Hackage.Security.Util.Stack Hackage.Security.Util.TypedEmbedded- MyPrelude- -- We support ghc 7.4 (bundled with Cabal 1.14) and up- build-depends: base >= 4.8 && < 4.20,- -- PatternSynonyms are only available since GHC 7.8 (base 4.7)- base16-bytestring >= 0.1.1 && < 1.1,- base64-bytestring >= 1.0 && < 1.3,- bytestring >= 0.9 && < 0.13,- containers >= 0.4 && < 0.8,- cryptohash-sha256 >= 0.11 && < 0.12,- directory >= 1.2 && < 1.4,- ed25519 >= 0.0 && < 0.1,- filepath >= 1.2 && < 1.5,- mtl >= 2.2 && < 2.4,- parsec >= 3.1 && < 3.2,- pretty >= 1.0 && < 1.2,++ build-depends: base >= 4.11 && < 4.20,+ base16-bytestring >= 0.1.1 && < 1.1,+ base64-bytestring >= 1.0 && < 1.3,+ bytestring >= 0.10.8.2 && < 0.13,+ containers >= 0.5.11 && < 0.8,+ cryptohash-sha256 >= 0.11 && < 0.12,+ directory >= 1.3.1.5 && < 1.4,+ ed25519 >= 0.0 && < 0.1,+ filepath >= 1.4.2 && < 1.5,+ mtl >= 2.2.2 && < 2.4,+ parsec >= 3.1.13 && < 3.2,+ pretty >= 1.0 && < 1.2, -- 0.4.2 introduces TarIndex, 0.4.4 introduces more -- functionality, 0.5.0 changes type of serialise- tar >= 0.5 && < 0.7,- template-haskell >= 2.7 && < 2.22,- time >= 1.2 && < 1.13,- transformers >= 0.3 && < 0.7,- zlib >= 0.5 && < 0.7,+ tar >= 0.5 && < 0.7,+ template-haskell >= 2.13 && < 2.22,+ time >= 1.8.0.2 && < 1.13,+ transformers >= 0.3 && < 0.7,+ zlib >= 0.5 && < 0.8, -- whatever versions are bundled with ghc:- ghc-prim+ ghc-prim >= 0.5.2 && < 0.12 if flag(lukko) build-depends: lukko >= 0.1 && < 0.2 else- build-depends: base >= 4.10+ build-depends: base >= 4.11 - if flag(Cabal-syntax) && impl(ghc >= 8.2)- build-depends: Cabal-syntax >= 3.7 && < 3.12+ if flag(Cabal-syntax)+ build-depends: Cabal-syntax >= 3.7 && < 3.14 else- build-depends: Cabal >= 1.14 && < 1.26- || >= 2.0 && < 2.6+ build-depends: Cabal >= 2.2.0.1 && < 2.6 || >= 3.0 && < 3.7, Cabal-syntax < 3.7 @@ -175,18 +169,13 @@ AllowAmbiguousTypes BangPatterns CPP+ DeriveLift OverlappingInstances PackageImports RoleAnnotations StaticPointers UndecidableInstances - -- use the new stage1/cross-compile-friendly DeriveLift extension for GHC 8.0+- if impl(ghc >= 8.0)- other-extensions: DeriveLift- else- other-extensions: TemplateHaskell- ghc-options: -Wall -- The URI type got split out off the network package after version 2.5, and@@ -250,12 +239,11 @@ time, zlib - if flag(Cabal-syntax) && impl(ghc >= 8.2)- build-depends: Cabal >= 3.7 && < 3.12,- Cabal-syntax >= 3.7 && < 3.12+ if flag(Cabal-syntax)+ build-depends: Cabal >= 3.7 && < 3.14,+ Cabal-syntax >= 3.7 && < 3.14 else- build-depends: Cabal >= 1.14 && < 1.26- || >= 2.0 && < 2.6+ build-depends: Cabal >= 2.2.0.1 && < 2.6 || >= 3.0 && < 3.7, Cabal-syntax < 3.7
src/Hackage/Security/Client.hs view
@@ -1,7 +1,5 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE StaticPointers #-}-#endif+ -- | Main entry point into the Hackage Security framework for clients module Hackage.Security.Client ( -- * Checking for updates@@ -41,7 +39,7 @@ , LocalFileCorrupted(..) ) where -import MyPrelude hiding (log)+import Prelude hiding (log) import Control.Arrow (first) import Control.Exception import Control.Monad@@ -333,11 +331,7 @@ -- | Get all cached info (if any) getCachedInfo ::-#if __GLASGOW_HASKELL__ < 800- (Applicative m, MonadIO m)-#else MonadIO m-#endif => Repository down -> m CachedInfo getCachedInfo rep = do (cachedRoot, cachedKeyEnv) <- readLocalRoot rep@@ -360,9 +354,6 @@ return (trustLocalFile signedRoot, rootKeys (signed signedRoot)) readLocalFile :: ( FromJSON ReadJSON_Keys_Layout (Signed a), MonadIO m-#if __GLASGOW_HASKELL__ < 800- , Applicative m-#endif ) => Repository down -> KeyEnv -> CachedFile -> m (Maybe (Trusted a)) readLocalFile rep cachedKeyEnv file = do@@ -383,7 +374,7 @@ -> Maybe UTCTime -> RemoteFile (f :- ()) Metadata -> Verify (Trusted a, down Metadata)-getRemoteFile rep@Repository{..} cachedInfo@CachedInfo{..} isRetry mNow file = do+getRemoteFile rep@Repository{} cachedInfo@CachedInfo{..} isRetry mNow file = do (targetPath, tempPath) <- getRemote' rep isRetry file verifyFileInfo' (remoteFileDefaultInfo file) targetPath tempPath signed <- throwErrorsChecked (VerificationErrorDeserialization targetPath) =<<@@ -952,21 +943,12 @@ } deriving (Typeable) -#if MIN_VERSION_base(4,8,0) deriving instance Show InvalidPackageException deriving instance Show LocalFileCorrupted deriving instance Show InvalidFileInIndex instance Exception InvalidPackageException where displayException = pretty instance Exception LocalFileCorrupted where displayException = pretty instance Exception InvalidFileInIndex where displayException = pretty-#else-instance Show InvalidPackageException where show = pretty-instance Show LocalFileCorrupted where show = pretty-instance Show InvalidFileInIndex where show = pretty-instance Exception InvalidPackageException-instance Exception LocalFileCorrupted-instance Exception InvalidFileInIndex-#endif instance Pretty InvalidPackageException where pretty (InvalidPackageException pkgId) = "Invalid package " ++ display pkgId
src/Hackage/Security/Client/Formats.hs view
@@ -17,7 +17,8 @@ , formatsLookup ) where -import MyPrelude+import Prelude+import Data.Kind (Type) import Hackage.Security.Util.Stack import Hackage.Security.Util.TypedEmbedded @@ -31,7 +32,7 @@ -- | Format is a singleton type (reflection type to term level) -- -- NOTE: In the future we might add further compression formats.-data Format :: * -> * where+data Format :: Type -> Type where FUn :: Format FormatUn FGz :: Format FormatGz @@ -55,7 +56,7 @@ -- -- NOTE: If we add additional cases here (for dealing with additional formats) -- all calls to @error "inaccessible"@ need to be reevaluated.-data Formats :: * -> * -> * where+data Formats :: Type -> Type -> Type where FsNone :: Formats () a FsUn :: a -> Formats (FormatUn :- ()) a FsGz :: a -> Formats (FormatGz :- ()) a@@ -74,7 +75,7 @@ -- | @HasFormat fs f@ is a proof that @f@ is a key in @fs@. -- -- See 'formatsMember' and 'formatsLookup' for typical usage.-data HasFormat :: * -> * -> * where+data HasFormat :: Type -> Type -> Type where HFZ :: Format f -> HasFormat (f :- fs) f HFS :: HasFormat fs f -> HasFormat (f' :- fs) f
src/Hackage/Security/Client/Repository.hs view
@@ -30,8 +30,9 @@ , mustCache ) where -import MyPrelude+import Prelude import Control.Exception+import Data.Kind (Type) import Data.Typeable (Typeable) import qualified Codec.Archive.Tar.Index as Tar import qualified Data.ByteString.Lazy as BS.L@@ -63,7 +64,7 @@ -- is metadata actual binary content. -- -- NOTE: Haddock lacks GADT support so constructors have only regular comments.-data RemoteFile :: * -> * -> * where+data RemoteFile :: Type -> Type -> Type where -- Timestamp metadata (@timestamp.json@) -- -- We never have (explicit) file length available for timestamps.@@ -361,7 +362,7 @@ Downloaded files -------------------------------------------------------------------------------} -class DownloadedFile (down :: * -> *) where+class DownloadedFile (down :: Type -> Type) where -- | Verify a download file downloadedVerify :: down a -> Trusted FileInfo -> IO Bool @@ -381,17 +382,12 @@ -- -- For instance, for repositories using HTTP this might correspond to a 404; -- for local repositories this might correspond to file-not-found, etc.-data SomeRemoteError :: * where+data SomeRemoteError :: Type where SomeRemoteError :: Exception e => e -> SomeRemoteError deriving (Typeable) -#if MIN_VERSION_base(4,8,0) deriving instance Show SomeRemoteError instance Exception SomeRemoteError where displayException = pretty-#else-instance Exception SomeRemoteError-instance Show SomeRemoteError where show = pretty-#endif instance Pretty SomeRemoteError where pretty (SomeRemoteError ex) = displayException ex@@ -424,7 +420,7 @@ -------------------------------------------------------------------------------} -- | Is a particular remote file cached?-data IsCached :: * -> * where+data IsCached :: Type -> Type where -- This remote file should be cached, and we ask for it by name CacheAs :: CachedFile -> IsCached Metadata
src/Hackage/Security/Client/Repository/Cache.hs view
@@ -15,7 +15,7 @@ , lockCacheWithLogger ) where -import MyPrelude+import Prelude import Control.Exception import Control.Monad import Control.Monad.IO.Class
src/Hackage/Security/Client/Repository/HttpLib.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} -- | Abstracting over HTTP libraries module Hackage.Security.Client.Repository.HttpLib ( HttpLib(..)@@ -11,7 +10,7 @@ , bodyReaderFromBS ) where -import MyPrelude+import Prelude import Data.IORef import Network.URI hiding (uriPath, path) import qualified Data.ByteString as BS
src/Hackage/Security/Client/Repository/Local.hs view
@@ -5,7 +5,7 @@ , withRepository ) where -import MyPrelude+import Prelude import Hackage.Security.Client.Formats import Hackage.Security.Client.Repository import Hackage.Security.Client.Repository.Cache
src/Hackage/Security/Client/Repository/Remote.hs view
@@ -27,11 +27,12 @@ , fileSizeWithinBounds ) where -import MyPrelude+import Prelude import Control.Concurrent import Control.Exception import Control.Monad (when, unless) import Control.Monad.IO.Class (MonadIO)+import Data.Kind (Type) import Data.List (nub, intercalate) import Data.Typeable import Network.URI hiding (uriPath, path)@@ -238,7 +239,7 @@ -- error we want to make sure caches get files upstream in case the validation -- error was because the cache updated files out of order. httpRequestHeaders :: RemoteConfig -> AttemptNr -> [HttpRequestHeader]-httpRequestHeaders RemoteConfig{..} attemptNr =+httpRequestHeaders RemoteConfig{} attemptNr = if attemptNr == 0 then defaultHeaders else HttpRequestMaxAge0 : defaultHeaders where@@ -256,7 +257,7 @@ -> Maybe [Mirror] -- ^ TUF mirrors -> IO a -- ^ Callback -> IO a-withMirror HttpLib{..}+withMirror HttpLib{} selectedMirror logger oobMirrors@@ -300,7 +301,7 @@ -------------------------------------------------------------------------------} -- | Download method (downloading or updating)-data DownloadMethod :: * -> * -> * where+data DownloadMethod :: Type -> Type -> Type where -- Download this file (we never attempt to update this type of file) NeverUpdated :: { neverUpdatedFormat :: HasFormat fs f@@ -498,13 +499,8 @@ expected (FileSizeExact n) = "exactly " ++ show n expected (FileSizeBound n) = "at most " ++ show n -#if MIN_VERSION_base(4,8,0) deriving instance Show FileTooLarge instance Exception FileTooLarge where displayException = pretty-#else-instance Exception FileTooLarge-instance Show FileTooLarge where show = pretty-#endif {------------------------------------------------------------------------------- Information about remote files@@ -600,7 +596,7 @@ Files downloaded from the remote repository -------------------------------------------------------------------------------} -data RemoteTemp :: * -> * where+data RemoteTemp :: Type -> Type where DownloadedWhole :: { wholeTemp :: Path Absolute } -> RemoteTemp a@@ -687,4 +683,3 @@ BS.L.take (fromIntegral deltaSeek) existing , temp ]-
src/Hackage/Security/Client/Verify.hs view
@@ -10,7 +10,7 @@ , liftIO ) where -import MyPrelude+import Prelude import Control.Exception import Control.Monad (join, void) import Control.Monad.IO.Class (MonadIO, liftIO)
src/Hackage/Security/JSON.hs view
@@ -38,7 +38,7 @@ , module Hackage.Security.Util.JSON ) where -import MyPrelude+import Prelude import Control.Arrow (first, second) import Control.Exception import Control.Monad (unless, liftM)@@ -84,13 +84,8 @@ | DeserializationErrorFileType String String deriving (Typeable) -#if MIN_VERSION_base(4,8,0) deriving instance Show DeserializationError instance Exception DeserializationError where displayException = pretty-#else-instance Show DeserializationError where show = pretty-instance Exception DeserializationError-#endif instance Pretty DeserializationError where pretty (DeserializationErrorMalformed str) =
src/Hackage/Security/Key.hs view
@@ -25,7 +25,7 @@ , verify ) where -import MyPrelude+import Prelude import Control.Monad import Data.Functor.Identity import Data.Typeable (Typeable)@@ -37,10 +37,6 @@ import qualified Data.ByteString.Base16 as Base16 import qualified Data.ByteString.Lazy as BS.L -#if !MIN_VERSION_base(4,7,0)-import qualified Data.Typeable as Typeable-#endif- import Hackage.Security.Util.JSON import Hackage.Security.Util.Some import Hackage.Security.Util.TypedEmbedded@@ -277,26 +273,3 @@ case tag of "ed25519" -> return . Some $ KeyTypeEd25519 _otherwise -> expected "valid key type" (Just tag)--{-------------------------------------------------------------------------------- Orphans-- Pre-7.8 (base 4.7) we cannot have Typeable instance for higher-kinded types.- Instead, here we provide some instance for specific instantiations.--------------------------------------------------------------------------------}--#if !MIN_VERSION_base(4,7,0)-tyConKey, tyConPublicKey, tyConPrivateKey :: Typeable.TyCon-tyConKey = Typeable.mkTyCon3 "hackage-security" "Hackage.Security.Key" "Key"-tyConPublicKey = Typeable.mkTyCon3 "hackage-security" "Hackage.Security.Key" "PublicKey"-tyConPrivateKey = Typeable.mkTyCon3 "hackage-security" "Hackage.Security.Key" "PrivateKey"--instance Typeable (Some Key) where- typeOf _ = Typeable.mkTyConApp tyConSome [Typeable.mkTyConApp tyConKey []]--instance Typeable (Some PublicKey) where- typeOf _ = Typeable.mkTyConApp tyConSome [Typeable.mkTyConApp tyConPublicKey []]--instance Typeable (Some PrivateKey) where- typeOf _ = Typeable.mkTyConApp tyConSome [Typeable.mkTyConApp tyConPrivateKey []]-#endif
src/Hackage/Security/Key/Env.hs view
@@ -12,7 +12,7 @@ , union ) where -import MyPrelude hiding (lookup, null)+import Prelude hiding (lookup, null) import Control.Monad import Data.Map (Map) import qualified Data.Map as Map
src/Hackage/Security/TUF/Common.hs view
@@ -6,7 +6,7 @@ , KeyThreshold(..) ) where -import MyPrelude+import Prelude import Hackage.Security.JSON {-------------------------------------------------------------------------------
src/Hackage/Security/TUF/FileInfo.hs view
@@ -13,7 +13,7 @@ , Int54 ) where -import MyPrelude hiding (lookup)+import Prelude hiding (lookup) import Data.Map (Map) import qualified Crypto.Hash.SHA256 as SHA256 import qualified Data.Map as Map
src/Hackage/Security/TUF/FileMap.hs view
@@ -18,7 +18,7 @@ , fileMapChanges ) where -import MyPrelude hiding (lookup)+import Prelude hiding (lookup) import Control.Arrow (second) import Data.Map (Map) import qualified Data.Map as Map
src/Hackage/Security/TUF/Header.hs view
@@ -12,7 +12,7 @@ , versionIncrement ) where -import MyPrelude+import Prelude import Data.Time import Data.Typeable (Typeable)
src/Hackage/Security/TUF/Layout/Cache.hs view
@@ -4,7 +4,7 @@ , cabalCacheLayout ) where -import MyPrelude+import Prelude import Hackage.Security.TUF.Paths import Hackage.Security.Util.Path
src/Hackage/Security/TUF/Layout/Index.hs view
@@ -9,7 +9,8 @@ , indexLayoutPkgPrefs ) where -import MyPrelude+import Prelude+import Data.Kind (Type) import Distribution.Package import Distribution.Text @@ -43,7 +44,7 @@ -- TODO: If we wanted to support legacy Hackage, we should also have a case for -- the global preferred-versions file. But supporting legacy Hackage will -- probably require more work anyway..-data IndexFile :: * -> * where+data IndexFile :: Type -> Type where -- Package-specific metadata (@targets.json@) IndexPkgMetadata :: PackageIdentifier -> IndexFile (Signed Targets)
src/Hackage/Security/TUF/Layout/Repo.hs view
@@ -5,7 +5,7 @@ , cabalLocalRepoLayout ) where -import MyPrelude+import Prelude import Distribution.Package import Distribution.Text
src/Hackage/Security/TUF/Mirrors.hs view
@@ -9,7 +9,7 @@ , describeMirror ) where -import MyPrelude+import Prelude import Control.Monad.Except import Network.URI
src/Hackage/Security/TUF/Paths.hs view
@@ -14,7 +14,7 @@ , anchorCachePath ) where -import MyPrelude+import Prelude import Hackage.Security.Util.Path import Hackage.Security.Util.Pretty
src/Hackage/Security/TUF/Patterns.hs view
@@ -2,13 +2,9 @@ -- -- NOTE: This module was developed to prepare for proper delegation (#39). -- It is currently unused.-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DeriveLift #-} {-# LANGUAGE StandaloneDeriving #-}-#else-{-# LANGUAGE TemplateHaskell #-}-#endif+ module Hackage.Security.TUF.Patterns ( -- * Patterns and replacements FileName@@ -26,7 +22,7 @@ , qqd ) where -import MyPrelude+import Prelude import Control.Monad (guard) import Language.Haskell.TH (Q, Exp) import System.FilePath.Posix@@ -130,8 +126,8 @@ go [] _ = Nothing go [f] (PatFileConst f') = do guard (f == f') return ()- go [f] (PatFileExt e') = do let (bn, _:e) = splitExtension f- guard $ e == e'+ go [f] (PatFileExt e') = do let (bn, dotExt) = splitExtension f+ guard $ dotExt == '.':e' return (bn :- ()) go [_] _ = Nothing go (d:p) (PatDirConst d' p') = do guard (d == d')@@ -274,29 +270,10 @@ Left err -> fail $ "Invalid delegation: " ++ err Right del -> TH.lift del -#if __GLASGOW_HASKELL__ >= 800 deriving instance TH.Lift (Pattern a) deriving instance TH.Lift (Replacement a) deriving instance TH.Lift Delegation-#else-instance TH.Lift (Pattern a) where- lift (PatFileConst fn) = [| PatFileConst fn |]- lift (PatFileExt e) = [| PatFileExt e |]- lift PatFileAny = [| PatFileAny |]- lift (PatDirConst d p) = [| PatDirConst d p |]- lift (PatDirAny p) = [| PatDirAny p |] -instance TH.Lift (Replacement a) where- lift (RepFileConst fn) = [| RepFileConst fn |]- lift (RepFileExt e ) = [| RepFileExt e |]- lift RepFileAny = [| RepFileAny |]- lift (RepDirConst d r) = [| RepDirConst d r |]- lift (RepDirAny r) = [| RepDirAny r |]--instance TH.Lift Delegation where- lift (Delegation pat repl) = [| Delegation pat repl |]-#endif- {------------------------------------------------------------------------------- JSON -------------------------------------------------------------------------------}@@ -346,9 +323,8 @@ ) _ex2 :: Maybe String-_ex2 = matchDelegation del "A/x/y/z.foo"- where- Right del = parseDelegation "A/*/*/*.foo" "B/*/C/*/*.bar"+_ex2 = either undefined (`matchDelegation` "A/x/y/z.foo")+ (parseDelegation "A/*/*/*.foo" "B/*/C/*/*.bar") _ex3 :: Either String Delegation _ex3 = parseDelegation "foo" "*/bar"
src/Hackage/Security/TUF/Root.hs view
@@ -6,7 +6,7 @@ , RoleSpec(..) ) where -import MyPrelude+import Prelude import Hackage.Security.JSON import Hackage.Security.Key import Hackage.Security.Key.Env (KeyEnv)
src/Hackage/Security/TUF/Signed.hs view
@@ -27,7 +27,7 @@ , toPreSignatures ) where -import MyPrelude+import Prelude import Control.Monad import Data.Functor.Identity import qualified Data.ByteString as BS
src/Hackage/Security/TUF/Snapshot.hs view
@@ -3,7 +3,7 @@ Snapshot(..) ) where -import MyPrelude+import Prelude import Control.Monad.Except import Control.Monad.Reader
src/Hackage/Security/TUF/Targets.hs view
@@ -8,7 +8,7 @@ , targetsLookup ) where -import MyPrelude+import Prelude import Hackage.Security.JSON import Hackage.Security.Key import Hackage.Security.Key.Env (KeyEnv)
src/Hackage/Security/TUF/Timestamp.hs view
@@ -3,7 +3,7 @@ Timestamp(..) ) where -import MyPrelude+import Prelude import Control.Monad.Except import Control.Monad.Reader
src/Hackage/Security/Trusted.hs view
@@ -1,7 +1,5 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 710 {-# LANGUAGE StaticPointers #-}-#endif+ module Hackage.Security.Trusted ( module Hackage.Security.Trusted.TCB -- * Derived functions@@ -12,7 +10,7 @@ , trustedFileInfoEqual ) where -import MyPrelude+import Prelude import Data.Function (on) import Data.Time import Hackage.Security.TUF
src/Hackage/Security/Trusted/TCB.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} module Hackage.Security.Trusted.TCB ( -- * Trusted values Trusted(DeclareTrusted)@@ -16,17 +15,11 @@ , signaturesVerified , verifyRole' , verifyFingerprints-#if __GLASGOW_HASKELL__ >= 710 -- * Re-exports , StaticPtr-#else- -- * Fake static pointers- , StaticPtr- , static-#endif ) where -import MyPrelude+import Prelude import Control.Exception import Control.Monad (when, unless) import Control.Monad.Except (Except, runExcept, throwError)@@ -38,18 +31,8 @@ import Hackage.Security.Util.Pretty import qualified Hackage.Security.Util.Lens as Lens -#if __GLASGOW_HASKELL__ >= 710 import GHC.StaticPtr-#else--- Fake static pointers for ghc < 7.10. This means Trusted offers no--- additional type safety, but that's okay: we can still verify the code--- with ghc 7.10 and get the additional checks.-newtype StaticPtr a = StaticPtr { deRefStaticPtr :: a } -static :: a -> StaticPtr a-static = StaticPtr-#endif- -- | Trusted values -- -- Trusted values originate in only two ways:@@ -209,17 +192,10 @@ type VerificationHistory = [Either RootUpdated VerificationError] -#if MIN_VERSION_base(4,8,0) deriving instance Show VerificationError deriving instance Show RootUpdated instance Exception VerificationError where displayException = pretty instance Exception RootUpdated where displayException = pretty-#else-instance Exception VerificationError-instance Show VerificationError where show = pretty-instance Show RootUpdated where show = pretty-instance Exception RootUpdated-#endif indentedLines :: [String] -> String indentedLines = unlines . map (" " ++)
src/Hackage/Security/Util/Base64.hs view
@@ -4,7 +4,7 @@ , toByteString ) where -import MyPrelude+import Prelude import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as C8 -- only called on B64-enc strings import qualified Data.ByteString.Base64 as B64
src/Hackage/Security/Util/Checked.hs view
@@ -1,15 +1,9 @@-{-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -fno-warn-unused-binds #-}-#if __GLASGOW_HASKELL__ >= 800-{-# OPTIONS_GHC -Wno-redundant-constraints #-}-#endif--#if __GLASGOW_HASKELL__ >= 708-{-# LANGUAGE RoleAnnotations #-}+{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE IncoherentInstances #-}-#endif+{-# LANGUAGE RoleAnnotations #-} -{-# LANGUAGE DeriveDataTypeable#-}+{-# OPTIONS_GHC -Wno-unused-binds #-}+{-# OPTIONS_GHC -Wno-redundant-constraints #-} -- | Checked exceptions module Hackage.Security.Util.Checked (@@ -25,16 +19,12 @@ , internalError ) where -import MyPrelude+import Prelude import Control.Exception (Exception, IOException) import qualified Control.Exception as Base import Data.Typeable (Typeable) -#if __GLASGOW_HASKELL__ >= 708 import GHC.Prim (coerce)-#else-import Unsafe.Coerce (unsafeCoerce)-#endif {------------------------------------------------------------------------------- Basic infrastructure@@ -43,9 +33,7 @@ -- | Checked exceptions class Throws e where -#if __GLASGOW_HASKELL__ >= 708 type role Throws representational-#endif unthrow :: forall a e proxy . proxy e -> (Throws e => a) -> a unthrow _ x = unWrap (coerceWrap (Wrap x :: Wrap e a))@@ -56,22 +44,10 @@ -- | Determine if an exception is asynchronous, based on its type. isAsync :: Exception e => e -> Bool-#if MIN_VERSION_base(4, 7, 0) isAsync e = case Base.fromException $ Base.toException e of Just Base.SomeAsyncException{} -> True Nothing -> False-#else--- Earlier versions of GHC had no SomeAsyncException. We have to--- instead make up a list of async exceptions.-isAsync e =- let se = Base.toException e- in case () of- ()- | Just (_ :: Base.AsyncException) <- Base.fromException se -> True- | show e == "<<timeout>>" -> True- | otherwise -> False-#endif -- | 'Base.catch', but immediately rethrows asynchronous exceptions -- (as determined by 'isAsync').@@ -131,11 +107,7 @@ newtype Wrap e a = Wrap { unWrap :: Throws e => a } coerceWrap :: Wrap e a -> Wrap (Catch e) a-#if __GLASGOW_HASKELL__ >= 708 coerceWrap = coerce-#else-coerceWrap = unsafeCoerce-#endif data Proxy a = Proxy
src/Hackage/Security/Util/Exit.hs view
@@ -1,6 +1,6 @@ module Hackage.Security.Util.Exit where -import MyPrelude+import Prelude import Control.Monad (liftM) import Control.Monad.Except (ExceptT, runExceptT, throwError)
src/Hackage/Security/Util/IO.hs view
@@ -9,7 +9,7 @@ , timedIO ) where -import MyPrelude+import Prelude import Control.Concurrent (threadDelay) import Control.Exception import Data.Time
src/Hackage/Security/Util/JSON.hs view
@@ -1,7 +1,3 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ < 710-{-# LANGUAGE OverlappingInstances #-}-#endif -- | module Hackage.Security.Util.JSON ( -- * Type classes@@ -23,7 +19,7 @@ , Int54 ) where -import MyPrelude+import Prelude import Control.Monad (liftM) import Data.Maybe (catMaybes) import Data.Map (Map)@@ -32,10 +28,6 @@ import Network.URI import qualified Data.Map as Map -#if !MIN_VERSION_time(1,5,0)-import System.Locale (defaultTimeLocale)-#endif- import Hackage.Security.Util.Path {-------------------------------------------------------------------------------@@ -120,16 +112,12 @@ fromJSON val = expected' "int" val instance-#if __GLASGOW_HASKELL__ >= 710 {-# OVERLAPPABLE #-}-#endif (Monad m, ToJSON m a) => ToJSON m [a] where toJSON = liftM JSArray . mapM toJSON instance-#if __GLASGOW_HASKELL__ >= 710 {-# OVERLAPPABLE #-}-#endif (ReportSchemaErrors m, FromJSON m a) => FromJSON m [a] where fromJSON (JSArray as) = mapM fromJSON as fromJSON val = expected' "array" val@@ -143,10 +131,6 @@ case parseTimeM False defaultTimeLocale "%FT%TZ" str of Just time -> return time Nothing -> expected "valid date-time string" (Just str)-#if !MIN_VERSION_time(1,5,0)- where- parseTimeM _trim = parseTime-#endif instance ( Monad m , ToObjectKey m k
src/Hackage/Security/Util/Lens.hs view
@@ -14,7 +14,7 @@ , set ) where -import MyPrelude+import Prelude import Control.Applicative import Data.Functor.Identity
src/Hackage/Security/Util/Path.hs view
@@ -7,7 +7,6 @@ -- -- Note that his module does not import any other modules from Hackage.Security; -- everywhere else we use Path instead of FilePath directly.-{-# LANGUAGE CPP #-} module Hackage.Security.Util.Path ( -- * Paths Path(..)@@ -83,16 +82,12 @@ , IO.hSeek ) where -import MyPrelude+import Prelude import Control.Monad import Data.List (isPrefixOf) import System.IO (IOMode(..), BufferMode(..), Handle, SeekMode(..)) import System.IO.Unsafe (unsafeInterleaveIO)-#if MIN_VERSION_directory(1,2,0) import Data.Time (UTCTime)-#else-import System.Time (ClockTime)-#endif import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BS.L import qualified System.FilePath as FP.Native@@ -239,21 +234,7 @@ toAbsoluteFilePath :: Path root -> IO FilePath instance FsRoot Relative where- toAbsoluteFilePath p = go (unPathNative p)- where- go :: FilePath -> IO FilePath-#if MIN_VERSION_directory(1,2,2)- go = Dir.makeAbsolute-#else- -- copied implementation from the directory package- go = (FP.Native.normalise <$>) . absolutize- absolutize path -- avoid the call to `getCurrentDirectory` if we can- | FP.Native.isRelative path- = (FP.Native.</> path)- . FP.Native.addTrailingPathSeparator <$>- Dir.getCurrentDirectory- | otherwise = return path-#endif+ toAbsoluteFilePath p = Dir.makeAbsolute (unPathNative p) instance FsRoot Absolute where toAbsoluteFilePath = return . unPathNative@@ -371,11 +352,7 @@ filePath <- toAbsoluteFilePath path Dir.doesDirectoryExist filePath -#if MIN_VERSION_directory(1,2,0) getModificationTime :: FsRoot root => Path root -> IO UTCTime-#else-getModificationTime :: FsRoot root => Path root -> IO ClockTime-#endif getModificationTime path = do filePath <- toAbsoluteFilePath path Dir.getModificationTime filePath
src/Hackage/Security/Util/Pretty.hs view
@@ -3,7 +3,7 @@ Pretty(..) ) where -import MyPrelude+import Prelude -- | Produce a human-readable string class Pretty a where
src/Hackage/Security/Util/Some.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} -- | Hiding existentials module Hackage.Security.Util.Some ( Some(..)@@ -13,30 +12,17 @@ , SomePretty(..) -- ** Type checking , typecheckSome-#if !MIN_VERSION_base(4,7,0)- -- ** Compatibility with base < 4.7- , tyConSome-#endif ) where -import MyPrelude-#if MIN_VERSION_base(4,7,0)+import Prelude import Data.Typeable (Typeable)-#else-import qualified Data.Typeable as Typeable-#endif import Hackage.Security.Util.TypedEmbedded import Hackage.Security.Util.Pretty data Some f = forall a. Some (f a) -#if MIN_VERSION_base(4,7,0) deriving instance Typeable Some-#else-tyConSome :: Typeable.TyCon-tyConSome = Typeable.mkTyCon3 "hackage-security" "Hackage.Security.Util.Some" "Some"-#endif {------------------------------------------------------------------------------- Equality on Some types
src/Hackage/Security/Util/Stack.hs view
@@ -3,7 +3,7 @@ (:-)(..) ) where -import MyPrelude+import Prelude data h :- t = h :- t deriving (Eq, Show)
src/Hackage/Security/Util/TypedEmbedded.hs view
@@ -7,7 +7,8 @@ , AsType(..) ) where -import MyPrelude+import Prelude+import Data.Kind (Type) -- | Type equality proofs --@@ -16,7 +17,7 @@ data a :=: b where Refl :: a :=: a -type family TypeOf (f :: * -> *) :: * -> *+type family TypeOf (f :: Type -> Type) :: Type -> Type -- | Equality check that gives us a type-level equality proof. class Unify f where
− src/MyPrelude.hs
@@ -1,31 +0,0 @@--- | Smooth over differences between various ghc versions by making older--- preludes look like 4.8.0-{-# LANGUAGE CPP #-}-module MyPrelude (- module P-#if !MIN_VERSION_base(4,8,0)- , Applicative(..)- , Monoid(..)- , (<$>)- , (<$)- , Traversable(traverse)- , displayException-#endif- ) where--#if MIN_VERSION_base(4,8,0)-import Prelude as P-#else-#if MIN_VERSION_base(4,6,0)-import Prelude as P-#else-import Prelude as P hiding (catch)-#endif-import Control.Applicative-import Control.Exception (Exception)-import Data.Monoid-import Data.Traversable (Traversable(traverse))--displayException :: Exception e => e -> String-displayException = show-#endif
src/Text/JSON/Canonical.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE CPP #-}--------------------------------------------------------------------- -- | -- Module : Text.JSON.Parsec -- Copyright : (c) Galois, Inc. 2007-2009, Duncan Coutts 2015@@ -30,21 +28,15 @@ , prettyCanonicalJSON ) where -import MyPrelude+import Prelude import Text.ParserCombinators.Parsec ( CharParser, (<|>), (<?>), many, between, sepBy , satisfy, char, string, digit, spaces , parse ) import Text.PrettyPrint hiding (char) import qualified Text.PrettyPrint as Doc-#if !(MIN_VERSION_base(4,7,0))-import Control.Applicative ((<$>), (<$), pure, (<*>), (<*), (*>))-#endif import Control.Arrow (first)-import Data.Bits (Bits)-#if MIN_VERSION_base(4,7,0)-import Data.Bits (FiniteBits)-#endif+import Data.Bits (Bits, FiniteBits) import Data.Char (isDigit, digitToInt) import Data.Data (Data) import Data.Function (on)@@ -83,9 +75,7 @@ , Ord , Real , Ix-#if MIN_VERSION_base(4,7,0) , FiniteBits-#endif , Bits , Storable , PrintfArg@@ -353,4 +343,3 @@ go [] = [] go [y] = [p <+> y, r] go (y:ys) = (p <+> y) : go ys-
tests/TestSuite.hs view
@@ -238,7 +238,7 @@ length (directoryEntries dir1) @?= 0 now <- getCurrentTime- inMemRepoSetIndex inMemRepo now [testEntry1]+ inMemRepoSetIndex inMemRepo now testEntries1 assertEqual "B" HasUpdates =<< checkForUpdates repo =<< checkExpiry dir2 <- getDirectory repo@@ -264,9 +264,9 @@ _ -> fail "unexpected index entry content" _ -> fail "unexpected index path" - testEntry1 = Tar.fileEntry path testEntrycontent- where- Right path = Tar.toTarPath False "foo/preferred-versions"+ testEntries1 :: [Tar.GenEntry Tar.TarPath linkTarget]+ testEntries1 = either (const []) (pure . (`Tar.fileEntry` testEntrycontent))+ (Tar.toTarPath False "foo/preferred-versions") testEntrycontent = BS.pack "foo >= 1" testEntryIndexFile = IndexPkgPrefs (mkPackageName "foo")
tests/TestSuite/InMemRepo.hs view
@@ -8,6 +8,7 @@ -- stdlib import Control.Exception+import Data.Kind (Type) import Data.Time import qualified Codec.Archive.Tar as Tar import qualified Codec.Compression.GZip as GZip@@ -33,7 +34,7 @@ "Files" from the in-memory repository -------------------------------------------------------------------------------} -data InMemFile :: * -> * where+data InMemFile :: Type -> Type where InMemMetadata :: ToJSON WriteJSON a => RepoLayout -> a -> InMemFile Metadata InMemBinary :: BS.L.ByteString -> InMemFile Binary
tests/TestSuite/JSON.hs view
@@ -11,7 +11,6 @@ import Data.Int import Data.List (sortBy, nubBy) import Data.Function (on)-import Control.Applicative import qualified Data.ByteString.Lazy.Char8 as BS import Test.QuickCheck