diff options
author | Joey Hess <joeyh@joeyh.name> | 2018-06-21 13:34:11 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2018-06-21 13:37:01 -0400 |
commit | b657242f5d946efae4cc77e8aef95dd2a306cd6b (patch) | |
tree | 3ce1adc18e7d4954b163cde419efcdf592fe06dc /P2P | |
parent | c981683f77253b2fa4e3f85d5593e6b1944d7746 (diff) |
enforce retrievalSecurityPolicy
Leveraged the existing verification code by making it also check the
retrievalSecurityPolicy.
Also, prevented getViaTmp from running the download action at all when the
retrievalSecurityPolicy is going to prevent verifying and so storing it.
Added annex.security.allow-unverified-downloads. A per-remote version
would be nice to have too, but would need more plumbing, so KISS.
(Bill the Cat reference not too over the top I hope. The point is to
make this something the user reads the documentation for before using.)
A few calls to verifyKeyContent and getViaTmp, that don't
involve downloads from remotes, have RetrievalAllKeysSecure hard-coded.
It was also hard-coded for P2P.Annex and Command.RecvKey,
to match the values of the corresponding remotes.
A few things use retrieveKeyFile/retrieveKeyFileCheap without going
through getViaTmp.
* Command.Fsck when downloading content from a remote to verify it.
That content does not get into the annex, so this is ok.
* Command.AddUrl when using a remote to download an url; this is new
content being added, so this is ok.
This commit was sponsored by Fernando Jimenez on Patreon.
Diffstat (limited to 'P2P')
-rw-r--r-- | P2P/Annex.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/P2P/Annex.hs b/P2P/Annex.hs index 05fa9e9ac0..008de23a50 100644 --- a/P2P/Annex.hs +++ b/P2P/Annex.hs @@ -22,6 +22,7 @@ import P2P.Protocol import P2P.IO import Logs.Location import Types.NumCopies +import Types.Remote (RetrievalSecurityPolicy(..)) import Utility.Metered import Control.Monad.Free @@ -63,9 +64,12 @@ runLocal runst runner a = case a of Right Nothing -> runner (next False) Left e -> return (Left (show e)) StoreContent k af o l getb validitycheck next -> do + -- This is the same as the retrievalSecurityPolicy of + -- Remote.P2P and Remote.Git. + let rsp = RetrievalAllKeysSecure ok <- flip catchNonAsync (const $ return False) $ transfer download k af $ \p -> - getViaTmp DefaultVerify k $ \tmp -> do + getViaTmp rsp DefaultVerify k $ \tmp -> do storefile tmp o l getb validitycheck p runner (next ok) StoreContentTo dest o l getb validitycheck next -> do |