These were not handling control characters and are redundant.
Sponsored-by: Jack Hill on Patreon
ks = keySource ld
doadd = sanitycheck ks $ do
(mkey, _mcache) <- liftAnnex $ do
- showStart "add" (keyFilename ks) (SeekInput [])
+ showStartMessage (StartMessage "add" (ActionItemOther (Just (QuotedPath (keyFilename ks)))) (SeekInput []))
ingest nullMeterUpdate (Just $ LockedDown lockdownconfig ks) Nothing
maybe (failedingest change) (done change $ fromRawFilePath $ keyFilename ks) mkey
addannexed' _ _ = return Nothing
start = do
guardTest
logf <- fromRepo gitAnnexFuzzTestLogFile
- showStart "fuzztest" (toRawFilePath logf) (SeekInput [])
+ showStartMessage (StartMessage "fuzztest" (ActionItemOther (Just (UnquotedString logf))) (SeekInput []))
logh <- liftIO $ openFile logf WriteMode
void $ forever $ fuzz logh
stop
getFeed :: AddUnlockedMatcher -> ImportFeedOptions -> Cache -> URLString -> CommandSeek
getFeed addunlockedmatcher opts cache url = do
- showStartOther "importfeed" (Just url) (SeekInput [])
+ showStartMessage (StartMessage "importfeed" (ActionItemOther (Just (UnquotedString url))) (SeekInput []))
withTmpFile "feed" $ \tmpf h -> do
liftIO $ hClose h
ifM (downloadFeed url tmpf)
getCache opttemplate = ifM (Annex.getRead Annex.force)
( ret S.empty S.empty
, do
- showStart "importfeed" "gathering known urls" (SeekInput [])
+ showStartMessage (StartMessage "importfeed" (ActionItemOther (Just "gathering known urls")) (SeekInput []))
(us, is) <- knownItems
showEndOk
ret (S.fromList us) (S.fromList is)
)
starturl u = unless started $
- showStartOther "addurl" (Just u) (SeekInput [])
+ showStartMessage (StartMessage "addurl" (ActionItemOther (Just (UnquotedString u))) (SeekInput []))
defaultTemplate :: String
defaultTemplate = "${feedtitle}/${itemtitle}${extension}"
noInfo :: String -> SeekInput -> String -> Annex ()
noInfo s si msg = do
- showStart "info" (encodeBS s) si
+ showStartMessage (StartMessage "info" (ActionItemOther (Just (UnquotedString s))) si)
showNote msg
showEndFail
Annex.incError
{- reads the config of a remote, with progress display -}
scan :: Git.Repo -> Annex Git.Repo
scan r = do
- showStartOther "map" (Just $ Git.repoDescribe r) (SeekInput [])
+ showStartMessage (StartMessage "map" (ActionItemOther (Just $ UnquotedString $ Git.repoDescribe r)) (SeekInput []))
v <- tryScan r
case v of
Just r' -> do
{-# LANGUAGE OverloadedStrings #-}
module Messages (
- showStart,
- showStartOther,
showStartMessage,
showEndMessage,
StartMessage(..),
import qualified Messages.JSON as JSON
import qualified Annex
-showStart :: String -> RawFilePath -> SeekInput -> Annex ()
-showStart command file si = outputMessage json $
- encodeBS command <> " " <> file <> " "
- where
- json = JSON.start command (Just file) Nothing si
-
-showStartActionItem :: String -> ActionItem -> SeekInput -> Annex ()
-showStartActionItem command ai si = do
- qp <- coreQuotePath <$> Annex.getGitConfig
- outputMessage json $
- encodeBS command <> " " <> actionItemDesc qp ai <> " "
- where
- json = JSON.start command (actionItemFile ai) (actionItemKey ai) si
-
-showStartOther :: String -> Maybe String -> SeekInput -> Annex ()
-showStartOther command mdesc si = outputMessage json $ encodeBS $
- command ++ (maybe "" (" " ++) mdesc) ++ " "
- where
- json = JSON.start command Nothing Nothing si
-
-showStartNothing :: String -> SeekInput -> Annex ()
-showStartNothing command si = outputMessage json $ encodeBS $
- command ++ " "
- where
- json = JSON.start command Nothing Nothing si
-
showStartMessage :: StartMessage -> Annex ()
showStartMessage (StartMessage command ai si) = case ai of
ActionItemAssociatedFile _ _ -> showStartActionItem command ai si
NormalOutput -> Annex.setOutput QuietOutput
_ -> noop
+showStartActionItem :: String -> ActionItem -> SeekInput -> Annex ()
+showStartActionItem command ai si = do
+ qp <- coreQuotePath <$> Annex.getGitConfig
+ outputMessage json $
+ encodeBS command <> " " <> actionItemDesc qp ai <> " "
+ where
+ json = JSON.start command (actionItemFile ai) (actionItemKey ai) si
+
+showStartNothing :: String -> SeekInput -> Annex ()
+showStartNothing command si = outputMessage json $ encodeBS $
+ command ++ " "
+ where
+ json = JSON.start command Nothing Nothing si
+
-- Only show end result if the StartMessage is one that gets displayed.
showEndMessage :: StartMessage -> Bool -> Annex ()
showEndMessage (StartMessage _ _ _) = showEndResult
control characters from all of these, since they are not filenames, and
any control characters in them are surely malicious.
-Also: git-annex importfeed displays urls from the feed, and should filter
-out control characters. If such an url even can be parsed?
-
Also: git-annex initremote with autoenable may be able to cause a remote
with a malicious name to be set up?
Also: Any place that an exception is thrown with an attacker-controlled value.
-`giveup` has been made to filter out control characters, but that leave
+`giveup` has been made to filter out control characters, but that leaves
other exceptions, including ones thrown by libraries. Catch all exceptions
at top-level (of program and/or worker threads) and filter out control
characters?