git style filename quoting for giveup
When the filenames are part of the git repository or other files that might have attacker-controlled names, quote them in error messages. This is fairly complete, although I didn't do the one in Utility.DirWatcher.INotify.hs because that doesn't have access to Git.Filename or Annex. But it's also quite possible I missed some. And also while scanning for these, I found giveup used with other things that could be attacker controlled to contain control characters (eg Keys). So, I'm thinking it would also be good for giveup to just filter out control characters. This commit is then not the only line of defence, but just good formatting when git-annex displays a filename in an error message. Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
parent
da83652c76
commit
063c00e4f7
8 changed files with 79 additions and 30 deletions
|
@ -5,6 +5,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Command.ReKey where
|
||||
|
||||
import Command
|
||||
|
@ -17,6 +19,7 @@ import Annex.ReplaceFile
|
|||
import Logs.Location
|
||||
import Annex.InodeSentinal
|
||||
import Annex.WorkTree
|
||||
import Git.Filename
|
||||
import Utility.InodeCache
|
||||
import qualified Utility.RawFilePath as R
|
||||
|
||||
|
@ -80,8 +83,10 @@ perform file oldkey newkey = do
|
|||
ifM (inAnnex oldkey)
|
||||
( unlessM (linkKey file oldkey newkey) $
|
||||
giveup "failed creating link from old to new key"
|
||||
, unlessM (Annex.getRead Annex.force) $
|
||||
giveup $ fromRawFilePath file ++ " is not available (use --force to override)"
|
||||
, unlessM (Annex.getRead Annex.force) $ do
|
||||
qp <- coreQuotePath <$> Annex.getGitConfig
|
||||
giveup $ decodeBS $ quote qp $ QuotedPath file
|
||||
<> " is not available (use --force to override)"
|
||||
)
|
||||
next $ cleanup file newkey
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue