diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs index d11efda3e2..8929a722af 100644 --- a/Assistant/Threads/Committer.hs +++ b/Assistant/Threads/Committer.hs @@ -333,7 +333,7 @@ handleAdds lockdowndir havelsof largefilematcher delayadd cs = returnWhen (null 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 diff --git a/Command/FuzzTest.hs b/Command/FuzzTest.hs index 4fadffce30..642f07b51d 100644 --- a/Command/FuzzTest.hs +++ b/Command/FuzzTest.hs @@ -37,7 +37,7 @@ start :: CommandStart 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 diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs index 2b6803024f..07c289d7ce 100644 --- a/Command/ImportFeed.hs +++ b/Command/ImportFeed.hs @@ -81,7 +81,7 @@ seek o = do 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) @@ -148,7 +148,7 @@ getCache :: Maybe String -> Annex Cache 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) @@ -373,7 +373,7 @@ performDownload' started addunlockedmatcher opts cache todownload = case locatio ) starturl u = unless started $ - showStartOther "addurl" (Just u) (SeekInput []) + showStartMessage (StartMessage "addurl" (ActionItemOther (Just (UnquotedString u))) (SeekInput [])) defaultTemplate :: String defaultTemplate = "${feedtitle}/${itemtitle}${extension}" diff --git a/Command/Info.hs b/Command/Info.hs index 422d2f88d2..b6d12841f1 100644 --- a/Command/Info.hs +++ b/Command/Info.hs @@ -182,7 +182,7 @@ itemInfo o (si, p) = ifM (isdir (toRawFilePath p)) 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 diff --git a/Command/Map.hs b/Command/Map.hs index bdebbc4b1f..2674fac501 100644 --- a/Command/Map.hs +++ b/Command/Map.hs @@ -196,7 +196,7 @@ same a b {- 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 diff --git a/Messages.hs b/Messages.hs index 45b7de6209..5b6ed426f9 100644 --- a/Messages.hs +++ b/Messages.hs @@ -8,8 +8,6 @@ {-# LANGUAGE OverloadedStrings #-} module Messages ( - showStart, - showStartOther, showStartMessage, showEndMessage, StartMessage(..), @@ -70,32 +68,6 @@ import Annex.Concurrent.Utility 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 @@ -117,6 +89,20 @@ showStartMessage (CustomOutput _) = 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 diff --git a/doc/todo/terminal_escapes_in_filenames.mdwn b/doc/todo/terminal_escapes_in_filenames.mdwn index e59bd7fde8..2a46cb1891 100644 --- a/doc/todo/terminal_escapes_in_filenames.mdwn +++ b/doc/todo/terminal_escapes_in_filenames.mdwn @@ -54,14 +54,11 @@ description of a repository. It seems that git-annex could just filter out 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?