module Hadolint.Rule.DL3032 (rule) where import Hadolint.Rule import qualified Hadolint.Shell as Shell import Language.Docker.Syntax rule :: Rule Shell.ParsedShell rule :: Rule ParsedShell rule = Rule ParsedShell dl3032 forall a. Semigroup a => a -> a -> a <> forall args. Rule args -> Rule args onbuild Rule ParsedShell dl3032 {-# INLINEABLE rule #-} dl3032 :: Rule Shell.ParsedShell dl3032 :: Rule ParsedShell dl3032 = 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 "DL3032" severity :: DLSeverity severity = DLSeverity DLWarningC message :: Text message = Text "`yum clean all` missing after yum command." check :: Instruction ParsedShell -> Bool check (Run (RunArgs Arguments ParsedShell args RunFlags _)) = forall a b. (a -> b) -> Arguments a -> b foldArguments ((Command -> Bool) -> ParsedShell -> Bool Shell.noCommands Command -> Bool yumInstall) Arguments ParsedShell args Bool -> Bool -> Bool || ( forall a b. (a -> b) -> Arguments a -> b foldArguments ((Command -> Bool) -> ParsedShell -> Bool Shell.anyCommands Command -> Bool yumInstall) Arguments ParsedShell args Bool -> Bool -> Bool && forall a b. (a -> b) -> Arguments a -> b foldArguments ((Command -> Bool) -> ParsedShell -> Bool Shell.anyCommands Command -> Bool yumClean) Arguments ParsedShell args ) check Instruction ParsedShell _ = Bool True yumInstall :: Command -> Bool yumInstall = Text -> [Text] -> Command -> Bool Shell.cmdHasArgs Text "yum" [Text "install"] yumClean :: Command -> Bool yumClean Command args = Text -> [Text] -> Command -> Bool Shell.cmdHasArgs Text "yum" [Text "clean", Text "all"] Command args Bool -> Bool -> Bool || Text -> [Text] -> Command -> Bool Shell.cmdHasArgs Text "rm" [Text "-rf", Text "/var/cache/yum/*"] Command args {-# INLINEABLE dl3032 #-}