hadolint 1.13.0 → 1.14.0
raw patch · 3 files changed
+42/−44 lines, 3 filesdep ~language-docker
Dependency ranges changed: language-docker
Files
- hadolint.cabal +26/−25
- src/Hadolint/Lint.hs +5/−5
- src/Hadolint/Rules.hs +11/−14
hadolint.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.28.2.+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.31.0. -- -- see: https://github.com/sol/hpack ----- hash: a69d376d8be88ae5432a97710688afbe46ad227c9262d12796a4357211b33238+-- hash: a3ad665f70a51301b8daa833c740191a21e0230d890d804af8bdbb21c93e5a18 name: hadolint-version: 1.13.0+version: 1.14.0 synopsis: Dockerfile Linter JavaScript API description: A smarter Dockerfile linter that helps you build best practice Docker images. category: Development@@ -16,7 +18,6 @@ license: GPL-3 license-file: LICENSE build-type: Simple-cabal-version: >= 1.10 extra-source-files: README.md @@ -25,6 +26,20 @@ location: git@github.com:hadolint/hadolint.git library+ exposed-modules:+ Hadolint+ Hadolint.Config+ Hadolint.Formatter.Checkstyle+ Hadolint.Formatter.Codacy+ Hadolint.Formatter.Codeclimate+ Hadolint.Formatter.Format+ Hadolint.Formatter.Json+ Hadolint.Formatter.TTY+ Hadolint.Lint+ Hadolint.Rules+ Hadolint.Shell+ other-modules:+ Paths_hadolint hs-source-dirs: src ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -optP-Wno-nonportable-include-path@@ -36,31 +51,19 @@ , containers , directory >=1.3.0 , filepath- , language-docker >=6.0.4 && <7+ , language-docker >=7.0.0 && <8 , megaparsec >=6.4 , mtl , split >=0.2 , text , void , yaml- exposed-modules:- Hadolint- Hadolint.Config- Hadolint.Formatter.Checkstyle- Hadolint.Formatter.Codacy- Hadolint.Formatter.Codeclimate- Hadolint.Formatter.Format- Hadolint.Formatter.Json- Hadolint.Formatter.TTY- Hadolint.Lint- Hadolint.Rules- Hadolint.Shell- other-modules:- Paths_hadolint default-language: Haskell2010 executable hadolint main-is: Main.hs+ other-modules:+ Paths_hadolint hs-source-dirs: app ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -optP-Wno-nonportable-include-path@@ -69,19 +72,19 @@ , containers , gitrev >=1.3.1 , hadolint- , language-docker >=6.0.4 && <7+ , language-docker >=7.0.0 && <8 , megaparsec >=6.4 , optparse-applicative >=0.14.0 , text if !(os(osx)) ld-options: -static -pthread- other-modules:- Paths_hadolint default-language: Haskell2010 test-suite hadolint-unit-tests type: exitcode-stdio-1.0 main-is: Spec.hs+ other-modules:+ Paths_hadolint hs-source-dirs: test ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -optP-Wno-nonportable-include-path@@ -93,10 +96,8 @@ , bytestring >=0.10 , hadolint , hspec- , language-docker >=6.0.4 && <7+ , language-docker >=7.0.0 && <8 , megaparsec >=6.4 , split >=0.2 , text- other-modules:- Paths_hadolint default-language: Haskell2010
src/Hadolint/Lint.hs view
@@ -5,7 +5,7 @@ import qualified Data.List.NonEmpty as NonEmpty import Data.Text (Text) import qualified Language.Docker as Docker-import Language.Docker.Parser (DockerfileError)+import Language.Docker.Parser (DockerfileError, Error) import Language.Docker.Syntax (Dockerfile) import System.Exit (exitFailure, exitSuccess) @@ -61,7 +61,7 @@ -- then convert them to a Result and combine with -- the result of the previous dockerfile results lintDockerfile ignoreRules dockerFile = do- ast <- Docker.parseFile (parseFilename dockerFile)+ ast <- parseFilename dockerFile return (processedFile ast) where processedFile = fmap processRules@@ -72,9 +72,9 @@ ignoreFilter rules (Rules.RuleCheck (Rules.Metadata code _ _) _ _ _) = code `notElem` rules -- | Support UNIX convention of passing "-" instead of "/dev/stdin"- parseFilename :: String -> String- parseFilename "-" = "/dev/stdin"- parseFilename s = s+ parseFilename :: String -> IO (Either Error Dockerfile)+ parseFilename "-" = Docker.parseStdin+ parseFilename s = Docker.parseFile s -- | Returns the result of applying all the rules to the given dockerfile analyzeAll :: Rules.RulesConfig -> Dockerfile -> [Rules.RuleCheck]
src/Hadolint/Rules.hs view
@@ -234,20 +234,17 @@ aliasMustBe :: (Text.Text -> Bool) -> Instruction a -> Bool aliasMustBe predicate fromInstr = case fromInstr of- From (UntaggedImage _ (Just (ImageAlias alias))) -> predicate alias- From (TaggedImage _ _ (Just (ImageAlias alias))) -> predicate alias- From (DigestedImage _ _ (Just (ImageAlias alias))) -> predicate alias+ From (UntaggedImage _ _ (Just (ImageAlias alias))) -> predicate alias+ From (TaggedImage _ _ _ (Just (ImageAlias alias))) -> predicate alias _ -> True fromName :: BaseImage -> Text.Text-fromName (UntaggedImage Image {imageName} _) = imageName-fromName (TaggedImage Image {imageName} _ _) = imageName-fromName (DigestedImage Image {imageName} _ _) = imageName+fromName (UntaggedImage Image {imageName} _ _) = imageName+fromName (TaggedImage Image {imageName} _ _ _) = imageName fromAlias :: BaseImage -> Maybe ImageAlias-fromAlias (UntaggedImage _ alias) = alias-fromAlias (TaggedImage _ _ alias) = alias-fromAlias (DigestedImage _ _ alias) = alias+fromAlias (UntaggedImage _ _ alias) = alias+fromAlias (TaggedImage _ _ _ alias) = alias ------------- -- RULES --@@ -417,8 +414,8 @@ code = "DL3006" severity = WarningC message = "Always tag the version of an image explicitly"- check _ (From (UntaggedImage (Image _ "scratch") _)) = True- check line (From (UntaggedImage (Image _ i) _)) =+ check _ (From (UntaggedImage (Image _ "scratch") _ _)) = True+ check line (From (UntaggedImage (Image _ i) _ _)) = i `elem` previouslyDefinedAliases line dockerfile check _ _ = True @@ -430,7 +427,7 @@ message = "Using latest is prone to errors if the image will ever update. Pin the version explicitly \ \to a release tag"- check (From (TaggedImage _ tag _)) = tag /= "latest"+ check (From (TaggedImage _ tag _ _)) = tag /= "latest" check _ = True aptGetVersionPinned :: Rule@@ -787,8 +784,8 @@ code = "DL3026" severity = ErrorC message = "Use only an allowed registry in the FROM image"- check st _ (From (UntaggedImage img alias)) = withState (Set.insert alias st) (doCheck st img)- check st _ (From (TaggedImage img _ alias)) = withState (Set.insert alias st) (doCheck st img)+ check st _ (From (UntaggedImage img _ alias)) = withState (Set.insert alias st) (doCheck st img)+ check st _ (From (TaggedImage img _ _ alias)) = withState (Set.insert alias st) (doCheck st img) check st _ _ = (st, True) -- |Transforms an Image into a Maybe ImageAlias by using the Image name toImageAlias = Just . ImageAlias . imageName