module Hadolint.Rule.DL3030 (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
dl3030 forall a. Semigroup a => a -> a -> a
<> forall args. Rule args -> Rule args
onbuild Rule ParsedShell
dl3030
{-# INLINEABLE rule #-}

dl3030 :: Rule Shell.ParsedShell
dl3030 :: Rule ParsedShell
dl3030 = 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
"DL3030"
    severity :: DLSeverity
severity = DLSeverity
DLWarningC
    message :: Text
message = Text
"Use the -y switch to avoid manual input `yum install -y <package`"

    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
forgotYumYesOption) Arguments ParsedShell
args
    check Instruction ParsedShell
_ = Bool
True

    forgotYumYesOption :: Command -> Bool
forgotYumYesOption Command
cmd = Command -> Bool
isYumInstall Command
cmd Bool -> Bool -> Bool
&& Bool -> Bool
not (Command -> Bool
hasYesOption Command
cmd)
    isYumInstall :: Command -> Bool
isYumInstall = Text -> [Text] -> Command -> Bool
Shell.cmdHasArgs Text
"yum" [Text
"install", Text
"groupinstall", Text
"localinstall"]
    hasYesOption :: Command -> Bool
hasYesOption = [Text] -> Command -> Bool
Shell.hasAnyFlag [Text
"y", Text
"assumeyes"]
{-# INLINEABLE dl3030 #-}