lift isCryptographicallySecure to Annex
Needed for VURL backend. Sponsored-by: Nicholas Golder-Manning on Patreon
This commit is contained in:
parent
55bf01b788
commit
e7b7ea78af
8 changed files with 15 additions and 14 deletions
|
@ -276,7 +276,7 @@ runTransferrer sd r k afile retrydecider direction _witness =
|
||||||
preCheckSecureHashes :: Observable v => Key -> Maybe Backend -> Annex v -> Annex v
|
preCheckSecureHashes :: Observable v => Key -> Maybe Backend -> Annex v -> Annex v
|
||||||
preCheckSecureHashes k meventualbackend a = case meventualbackend of
|
preCheckSecureHashes k meventualbackend a = case meventualbackend of
|
||||||
Just eventualbackend -> go
|
Just eventualbackend -> go
|
||||||
(pure (Types.Backend.isCryptographicallySecure eventualbackend))
|
(Types.Backend.isCryptographicallySecure eventualbackend)
|
||||||
(Types.Backend.backendVariety eventualbackend)
|
(Types.Backend.backendVariety eventualbackend)
|
||||||
Nothing -> go
|
Nothing -> go
|
||||||
(isCryptographicallySecure k)
|
(isCryptographicallySecure k)
|
||||||
|
|
|
@ -124,8 +124,8 @@ isStableKey k = maybe False (`B.isStableKey` k)
|
||||||
<$> maybeLookupBackendVariety (fromKey keyVariety k)
|
<$> maybeLookupBackendVariety (fromKey keyVariety k)
|
||||||
|
|
||||||
isCryptographicallySecure :: Key -> Annex Bool
|
isCryptographicallySecure :: Key -> Annex Bool
|
||||||
isCryptographicallySecure k = maybe False isCryptographicallySecure'
|
isCryptographicallySecure k = maybe (pure False) isCryptographicallySecure'
|
||||||
<$> maybeLookupBackendVariety (fromKey keyVariety k)
|
=<< maybeLookupBackendVariety (fromKey keyVariety k)
|
||||||
|
|
||||||
isCryptographicallySecure' :: Backend -> Bool
|
isCryptographicallySecure' :: Backend -> Annex Bool
|
||||||
isCryptographicallySecure' = B.isCryptographicallySecure
|
isCryptographicallySecure' = B.isCryptographicallySecure
|
||||||
|
|
|
@ -72,7 +72,7 @@ makeBackend' ebname@(ExternalBackendName bname) hasext (Right p) = do
|
||||||
, canUpgradeKey = Nothing
|
, canUpgradeKey = Nothing
|
||||||
, fastMigrate = Nothing
|
, fastMigrate = Nothing
|
||||||
, isStableKey = const isstable
|
, isStableKey = const isstable
|
||||||
, isCryptographicallySecure = iscryptographicallysecure
|
, isCryptographicallySecure = pure iscryptographicallysecure
|
||||||
}
|
}
|
||||||
makeBackend' ebname hasext (Left _) = return $ unavailBackend ebname hasext
|
makeBackend' ebname hasext (Left _) = return $ unavailBackend ebname hasext
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ unavailBackend (ExternalBackendName bname) hasext =
|
||||||
, canUpgradeKey = Nothing
|
, canUpgradeKey = Nothing
|
||||||
, fastMigrate = Nothing
|
, fastMigrate = Nothing
|
||||||
, isStableKey = const False
|
, isStableKey = const False
|
||||||
, isCryptographicallySecure = False
|
, isCryptographicallySecure = pure False
|
||||||
}
|
}
|
||||||
|
|
||||||
genKeyExternal :: ExternalBackendName -> HasExt -> KeySource -> MeterUpdate -> Annex Key
|
genKeyExternal :: ExternalBackendName -> HasExt -> KeySource -> MeterUpdate -> Annex Key
|
||||||
|
|
|
@ -81,7 +81,7 @@ genBackend hash = Backend
|
||||||
, canUpgradeKey = Just needsUpgrade
|
, canUpgradeKey = Just needsUpgrade
|
||||||
, fastMigrate = Just trivialMigrate
|
, fastMigrate = Just trivialMigrate
|
||||||
, isStableKey = const True
|
, isStableKey = const True
|
||||||
, isCryptographicallySecure = cryptographicallySecure hash
|
, isCryptographicallySecure = pure $ cryptographicallySecure hash
|
||||||
}
|
}
|
||||||
|
|
||||||
genBackendE :: Hash -> Backend
|
genBackendE :: Hash -> Backend
|
||||||
|
|
|
@ -31,7 +31,7 @@ backendURL = Backend
|
||||||
-- The content of an url can change at any time, so URL keys are
|
-- The content of an url can change at any time, so URL keys are
|
||||||
-- not stable.
|
-- not stable.
|
||||||
, isStableKey = const False
|
, isStableKey = const False
|
||||||
, isCryptographicallySecure = False
|
, isCryptographicallySecure = pure False
|
||||||
}
|
}
|
||||||
|
|
||||||
backendVURL :: Backend
|
backendVURL :: Backend
|
||||||
|
@ -48,7 +48,7 @@ backendVURL = Backend
|
||||||
-- can be more than one hash and different versions of the content.
|
-- can be more than one hash and different versions of the content.
|
||||||
-- So the content is not stable.
|
-- So the content is not stable.
|
||||||
, isStableKey = const False
|
, isStableKey = const False
|
||||||
, isCryptographicallySecure = False
|
, isCryptographicallySecure = pure False
|
||||||
-- TODO it is when all recorded hashes are
|
-- TODO it is when all recorded hashes are
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ backend = Backend
|
||||||
, canUpgradeKey = Just needsUpgrade
|
, canUpgradeKey = Just needsUpgrade
|
||||||
, fastMigrate = Just removeProblemChars
|
, fastMigrate = Just removeProblemChars
|
||||||
, isStableKey = const True
|
, isStableKey = const True
|
||||||
, isCryptographicallySecure = False
|
, isCryptographicallySecure = pure False
|
||||||
}
|
}
|
||||||
|
|
||||||
{- The key includes the file size, modification time, and the
|
{- The key includes the file size, modification time, and the
|
||||||
|
|
|
@ -171,9 +171,10 @@ downloadKey urlincludeexclude key _af dest p vc =
|
||||||
-- Make sure to pick a backend that is cryptographically
|
-- Make sure to pick a backend that is cryptographically
|
||||||
-- secure.
|
-- secure.
|
||||||
db <- defaultBackend
|
db <- defaultBackend
|
||||||
let b = if isCryptographicallySecure' db
|
b <- ifM (isCryptographicallySecure' db)
|
||||||
then db
|
( pure db
|
||||||
else defaultHashBackend
|
, pure defaultHashBackend
|
||||||
|
)
|
||||||
showSideAction (UnquotedString descChecksum)
|
showSideAction (UnquotedString descChecksum)
|
||||||
(hashk, _) <- genKey ks nullMeterUpdate b
|
(hashk, _) <- genKey ks nullMeterUpdate b
|
||||||
unless (hashk `elem` eks) $
|
unless (hashk `elem` eks) $
|
||||||
|
|
|
@ -34,7 +34,7 @@ data BackendA a = Backend
|
||||||
-- same data.
|
-- same data.
|
||||||
, isStableKey :: Key -> Bool
|
, isStableKey :: Key -> Bool
|
||||||
-- Checks if a key is verified using a cryptographically secure hash.
|
-- Checks if a key is verified using a cryptographically secure hash.
|
||||||
, isCryptographicallySecure :: Bool
|
, isCryptographicallySecure :: a Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
instance Show (BackendA a) where
|
instance Show (BackendA a) where
|
||||||
|
|
Loading…
Add table
Reference in a new issue