module Hadolint.Rule.DL3036 (rule) where import Hadolint.Rule import qualified Hadolint.Shell as Shell import qualified Hadolint.Utils as Utils import Language.Docker.Syntax rule :: Rule Shell.ParsedShell rule :: Rule ParsedShell rule = Rule ParsedShell dl3036 Rule ParsedShell -> Rule ParsedShell -> Rule ParsedShell forall a. Semigroup a => a -> a -> a <> Rule ParsedShell -> Rule ParsedShell forall args. Rule args -> Rule args onbuild Rule ParsedShell dl3036 {-# INLINEABLE rule #-} dl3036 :: Rule Shell.ParsedShell dl3036 :: Rule ParsedShell dl3036 = 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 "DL3036" severity :: DLSeverity severity = DLSeverity DLWarningC message :: Text message = Text "`zypper clean` missing after zypper use." check :: Instruction ParsedShell -> Bool check (Run (RunArgs Arguments ParsedShell args RunFlags flags)) | (ParsedShell -> Bool) -> Arguments ParsedShell -> Bool forall a b. (a -> b) -> Arguments a -> b foldArguments ((Command -> Bool) -> ParsedShell -> Bool Shell.noCommands Command -> Bool zypperInstall) Arguments ParsedShell args = Bool True | Text -> RunFlags -> Bool Utils.hasCacheOrTmpfsMountWith Text "/var/cache/zypp" RunFlags flags = Bool True | Bool -> Maybe Bool forall a. a -> Maybe a Just Bool True Maybe Bool -> Maybe Bool -> Bool forall a. Eq a => a -> a -> Bool == ( Int -> Int -> Bool forall a. Ord a => a -> a -> Bool (<) (Int -> Int -> Bool) -> Maybe Int -> Maybe (Int -> Bool) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (ParsedShell -> Maybe Int) -> Arguments ParsedShell -> Maybe Int forall a b. (a -> b) -> Arguments a -> b foldArguments ((Command -> Bool) -> ParsedShell -> Maybe Int Shell.findCommandIndex Command -> Bool zypperInstall) Arguments ParsedShell args Maybe (Int -> Bool) -> Maybe Int -> Maybe Bool forall a b. Maybe (a -> b) -> Maybe a -> Maybe b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> (ParsedShell -> Maybe Int) -> Arguments ParsedShell -> Maybe Int forall a b. (a -> b) -> Arguments a -> b foldArguments ((Command -> Bool) -> ParsedShell -> Maybe Int Shell.findCommandIndex Command -> Bool zypperClean) Arguments ParsedShell args) = Bool True | Bool otherwise = Bool False check Instruction ParsedShell _ = Bool True zypperInstall :: Command -> Bool zypperInstall = Text -> [Text] -> Command -> Bool Shell.cmdHasArgs Text "zypper" [Text "install", Text "in"] zypperClean :: Command -> Bool zypperClean = Text -> [Text] -> Command -> Bool Shell.cmdHasArgs Text "zypper" [Text "clean", Text "cc"] {-# INLINEABLE dl3036 #-}