eliminate showStart showStartOther

These were not handling control characters and are redundant.

Sponsored-by: Jack Hill on Patreon
This commit is contained in:
Joey Hess 2023-04-10 16:07:54 -04:00
parent 3290a09a70
commit a0e6fa18eb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 22 additions and 39 deletions

View file

@ -333,7 +333,7 @@ handleAdds lockdowndir havelsof largefilematcher delayadd cs = returnWhen (null
ks = keySource ld ks = keySource ld
doadd = sanitycheck ks $ do doadd = sanitycheck ks $ do
(mkey, _mcache) <- liftAnnex $ 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 ingest nullMeterUpdate (Just $ LockedDown lockdownconfig ks) Nothing
maybe (failedingest change) (done change $ fromRawFilePath $ keyFilename ks) mkey maybe (failedingest change) (done change $ fromRawFilePath $ keyFilename ks) mkey
addannexed' _ _ = return Nothing addannexed' _ _ = return Nothing

View file

@ -37,7 +37,7 @@ start :: CommandStart
start = do start = do
guardTest guardTest
logf <- fromRepo gitAnnexFuzzTestLogFile logf <- fromRepo gitAnnexFuzzTestLogFile
showStart "fuzztest" (toRawFilePath logf) (SeekInput []) showStartMessage (StartMessage "fuzztest" (ActionItemOther (Just (UnquotedString logf))) (SeekInput []))
logh <- liftIO $ openFile logf WriteMode logh <- liftIO $ openFile logf WriteMode
void $ forever $ fuzz logh void $ forever $ fuzz logh
stop stop

View file

@ -81,7 +81,7 @@ seek o = do
getFeed :: AddUnlockedMatcher -> ImportFeedOptions -> Cache -> URLString -> CommandSeek getFeed :: AddUnlockedMatcher -> ImportFeedOptions -> Cache -> URLString -> CommandSeek
getFeed addunlockedmatcher opts cache url = do getFeed addunlockedmatcher opts cache url = do
showStartOther "importfeed" (Just url) (SeekInput []) showStartMessage (StartMessage "importfeed" (ActionItemOther (Just (UnquotedString url))) (SeekInput []))
withTmpFile "feed" $ \tmpf h -> do withTmpFile "feed" $ \tmpf h -> do
liftIO $ hClose h liftIO $ hClose h
ifM (downloadFeed url tmpf) ifM (downloadFeed url tmpf)
@ -148,7 +148,7 @@ getCache :: Maybe String -> Annex Cache
getCache opttemplate = ifM (Annex.getRead Annex.force) getCache opttemplate = ifM (Annex.getRead Annex.force)
( ret S.empty S.empty ( ret S.empty S.empty
, do , do
showStart "importfeed" "gathering known urls" (SeekInput []) showStartMessage (StartMessage "importfeed" (ActionItemOther (Just "gathering known urls")) (SeekInput []))
(us, is) <- knownItems (us, is) <- knownItems
showEndOk showEndOk
ret (S.fromList us) (S.fromList is) ret (S.fromList us) (S.fromList is)
@ -373,7 +373,7 @@ performDownload' started addunlockedmatcher opts cache todownload = case locatio
) )
starturl u = unless started $ starturl u = unless started $
showStartOther "addurl" (Just u) (SeekInput []) showStartMessage (StartMessage "addurl" (ActionItemOther (Just (UnquotedString u))) (SeekInput []))
defaultTemplate :: String defaultTemplate :: String
defaultTemplate = "${feedtitle}/${itemtitle}${extension}" defaultTemplate = "${feedtitle}/${itemtitle}${extension}"

View file

@ -182,7 +182,7 @@ itemInfo o (si, p) = ifM (isdir (toRawFilePath p))
noInfo :: String -> SeekInput -> String -> Annex () noInfo :: String -> SeekInput -> String -> Annex ()
noInfo s si msg = do noInfo s si msg = do
showStart "info" (encodeBS s) si showStartMessage (StartMessage "info" (ActionItemOther (Just (UnquotedString s))) si)
showNote msg showNote msg
showEndFail showEndFail
Annex.incError Annex.incError

View file

@ -196,7 +196,7 @@ same a b
{- reads the config of a remote, with progress display -} {- reads the config of a remote, with progress display -}
scan :: Git.Repo -> Annex Git.Repo scan :: Git.Repo -> Annex Git.Repo
scan r = do scan r = do
showStartOther "map" (Just $ Git.repoDescribe r) (SeekInput []) showStartMessage (StartMessage "map" (ActionItemOther (Just $ UnquotedString $ Git.repoDescribe r)) (SeekInput []))
v <- tryScan r v <- tryScan r
case v of case v of
Just r' -> do Just r' -> do

View file

@ -8,8 +8,6 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Messages ( module Messages (
showStart,
showStartOther,
showStartMessage, showStartMessage,
showEndMessage, showEndMessage,
StartMessage(..), StartMessage(..),
@ -70,32 +68,6 @@ import Annex.Concurrent.Utility
import qualified Messages.JSON as JSON import qualified Messages.JSON as JSON
import qualified Annex 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 -> Annex ()
showStartMessage (StartMessage command ai si) = case ai of showStartMessage (StartMessage command ai si) = case ai of
ActionItemAssociatedFile _ _ -> showStartActionItem command ai si ActionItemAssociatedFile _ _ -> showStartActionItem command ai si
@ -117,6 +89,20 @@ showStartMessage (CustomOutput _) =
NormalOutput -> Annex.setOutput QuietOutput NormalOutput -> Annex.setOutput QuietOutput
_ -> noop _ -> 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. -- Only show end result if the StartMessage is one that gets displayed.
showEndMessage :: StartMessage -> Bool -> Annex () showEndMessage :: StartMessage -> Bool -> Annex ()
showEndMessage (StartMessage _ _ _) = showEndResult showEndMessage (StartMessage _ _ _) = showEndResult

View file

@ -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 control characters from all of these, since they are not filenames, and
any control characters in them are surely malicious. 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 Also: git-annex initremote with autoenable may be able to cause a remote
with a malicious name to be set up? with a malicious name to be set up?
Also: Any place that an exception is thrown with an attacker-controlled value. 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 other exceptions, including ones thrown by libraries. Catch all exceptions
at top-level (of program and/or worker threads) and filter out control at top-level (of program and/or worker threads) and filter out control
characters? characters?