module Hadolint.Rule.DL3047 (rule) where import Hadolint.Rule import Hadolint.Shell (ParsedShell) import qualified Hadolint.Shell as Shell import Language.Docker.Syntax rule :: Rule ParsedShell rule :: Rule ParsedShell rule = RuleCode -> DLSeverity -> Text -> (Instruction ParsedShell -> Bool) -> Rule ParsedShell forall args. RuleCode -> DLSeverity -> Text -> (Instruction args -> Bool) -> Rule args simpleRule RuleCode code DLSeverity severity Text message Instruction ParsedShell -> Bool check where code :: RuleCode code = RuleCode "DL3047" severity :: DLSeverity severity = DLSeverity DLInfoC message :: Text message = Text "Avoid use of wget without progress bar. Use `wget --progress=dot:giga <url>`.\ \Or consider using `-q` or `-nv` (shorthands for `--quiet` or `--no-verbose`)." check :: Instruction ParsedShell -> Bool check (Run (RunArgs Arguments ParsedShell args RunFlags _)) = (ParsedShell -> Bool) -> Arguments ParsedShell -> Bool forall a b. (a -> b) -> Arguments a -> b foldArguments ((Command -> Bool) -> ParsedShell -> Bool Shell.noCommands Command -> Bool forgotProgress) Arguments ParsedShell args check Instruction ParsedShell _ = Bool True forgotProgress :: Command -> Bool forgotProgress Command cmd = Command -> Bool isWget Command cmd Bool -> Bool -> Bool && (Bool -> Bool not (Command -> Bool hasProgressOption Command cmd) Bool -> Bool -> Bool && Bool -> Bool not (Command -> Bool hasSpecialFlags Command cmd)) isWget :: Command -> Bool isWget (Shell.Command Text name [CmdPart] _ [CmdPart] _) = Text name Text -> Text -> Bool forall a. Eq a => a -> a -> Bool == Text "wget" hasProgressOption :: Command -> Bool hasProgressOption Command cmd = Text -> Command -> Bool Shell.hasFlag Text "progress" Command cmd hasSpecialFlags :: Command -> Bool hasSpecialFlags Command cmd = Command -> Bool hasQuietFlag Command cmd Bool -> Bool -> Bool || Command -> Bool hasOutputFlag Command cmd Bool -> Bool -> Bool || Command -> Bool hasAppendOutputFlag Command cmd Bool -> Bool -> Bool || Command -> Bool hasNoVerboseFlag Command cmd hasQuietFlag :: Command -> Bool hasQuietFlag Command cmd = [Text] -> Command -> Bool Shell.hasAnyFlag [Text "q", Text "quiet"] Command cmd hasOutputFlag :: Command -> Bool hasOutputFlag Command cmd = [Text] -> Command -> Bool Shell.hasAnyFlag [Text "o", Text "output-file"] Command cmd hasAppendOutputFlag :: Command -> Bool hasAppendOutputFlag Command cmd = [Text] -> Command -> Bool Shell.hasAnyFlag [Text "a", Text "append-output"] Command cmd hasNoVerboseFlag :: Command -> Bool hasNoVerboseFlag Command cmd = [Text] -> Command -> Bool Shell.hasAnyFlag [Text "no-verbose"] Command cmd Bool -> Bool -> Bool || Text -> [Text] -> Command -> Bool Shell.cmdHasArgs Text "wget" [Text "-nv"] Command cmd {-# INLINEABLE rule #-}