packages feed

hadolint 1.20.0 → 1.21.0

raw patch · 5 files changed

+49/−11 lines, 5 filesdep +cryptonitePVP ok

version bump matches the API change (PVP)

Dependencies added: cryptonite

API changes (from Hackage documentation)

+ Hadolint.Formatter.Codeclimate: instance Data.Aeson.Types.ToJSON.ToJSON Hadolint.Formatter.Codeclimate.FingerprintIssue
+ Hadolint.Formatter.Codeclimate: printGitlabResult :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => Result s e -> IO ()
+ Hadolint.Lint: GitlabCodeclimateJson :: OutputFormat

Files

README.md view
@@ -155,12 +155,13 @@ ## Integrations  To get most of `hadolint` it is useful to integrate it as a check to your CI-or to your editor to lint your `Dockerfile` as you write it. See our-[Integration][] docs.+or to your editor, or as a pre-commit hook, to lint your `Dockerfile` as you+write it. See our [Integration][] docs.  - [Code Review Platform Integrations][] - [Continuous Integrations][] - [Editor Integrations][]+- [Version Control Integrations][]  ## Rules @@ -335,6 +336,7 @@ [code review platform integrations]: docs/INTEGRATION.md#code-review [continuous integrations]: docs/INTEGRATION.md#continuous-integration [editor integrations]: docs/INTEGRATION.md#editors+[version control integrations]: docs/INTEGRATION.md#version-control [create an issue]: https://github.com/hadolint/hadolint/issues/new [dockerfile reference]: http://docs.docker.com/engine/reference/builder/ [syntax.hs]: https://www.stackage.org/haddock/nightly-2018-01-07/language-docker-2.0.1/Language-Docker-Syntax.html
app/Main.hs view
@@ -51,6 +51,7 @@ toOutputFormat "json" = Just Hadolint.Json toOutputFormat "tty" = Just Hadolint.TTY toOutputFormat "codeclimate" = Just Hadolint.CodeclimateJson+toOutputFormat "gitlab_codeclimate" = Just Hadolint.GitlabCodeclimateJson toOutputFormat "checkstyle" = Just Hadolint.Checkstyle toOutputFormat "codacy" = Just Hadolint.Codacy toOutputFormat _ = Nothing@@ -59,6 +60,7 @@ showFormat Hadolint.Json = "json" showFormat Hadolint.TTY = "tty" showFormat Hadolint.CodeclimateJson = "codeclimate"+showFormat Hadolint.GitlabCodeclimateJson = "gitlab_codeclimate" showFormat Hadolint.Checkstyle = "checkstyle" showFormat Hadolint.Codacy = "codacy" @@ -87,10 +89,10 @@         ( long "format"             <> short 'f' -- options for the output format             <> help-              "The output format for the results [tty | json | checkstyle | codeclimate | codacy]"+              "The output format for the results [tty | json | checkstyle | codeclimate | gitlab_codeclimate | codacy]"             <> value Hadolint.TTY             <> showDefaultWith showFormat -- The default value-            <> completeWith ["tty", "json", "checkstyle", "codeclimate", "codacy"]+            <> completeWith ["tty", "json", "checkstyle", "codeclimate", "gitlab_codeclimate", "codacy"]         )      ignoreList =
hadolint.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 196183dccc95114462aa7b27a5c15b007a0aa09fdddf2c00d154df003854e6ad+-- hash: b934b8b20c533c2e9d0f96fc7feae25791c0c02248f0116af5b43262a186afb8  name:           hadolint-version:        1.20.0+version:        1.21.0 synopsis:       Dockerfile Linter JavaScript API description:    A smarter Dockerfile linter that helps you build best practice Docker images. category:       Development@@ -58,6 +58,7 @@     , base >=4.8 && <5     , bytestring     , containers+    , cryptonite     , directory >=1.3.0     , filepath     , language-docker >=9.1.2 && <10
src/Hadolint/Formatter/Codeclimate.hs view
@@ -4,10 +4,12 @@  module Hadolint.Formatter.Codeclimate   ( printResult,+    printGitlabResult,     formatResult,   ) where +import Crypto.Hash (Digest, SHA1 (..), hash) import Data.Aeson hiding (Result) import qualified Data.ByteString.Lazy as B import Data.Monoid ((<>))@@ -29,6 +31,11 @@     impact :: String   } +data FingerprintIssue = FingerprintIssue+  { issue :: Issue,+    fingerprint :: Digest SHA1+  }+ data Location   = LocLine       String@@ -61,6 +68,18 @@         "severity" .= impact       ] +instance ToJSON FingerprintIssue where+  toJSON FingerprintIssue {..} =+    object+      [ "type" .= ("issue" :: String),+        "fingerprint" .= show fingerprint,+        "check_name" .= checkName issue,+        "description" .= description issue,+        "categories" .= (["Bug Risk"] :: [String]),+        "location" .= location issue,+        "severity" .= impact issue+      ]+ errorToIssue :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => ParseErrorBundle s e -> Issue errorToIssue err =   Issue@@ -91,16 +110,28 @@     InfoC -> "info"     StyleC -> "minor" +generateFingerprint :: Issue -> Digest SHA1+generateFingerprint = hash . B.toStrict . encode++issueToFingerprintIssue :: Issue -> FingerprintIssue+issueToFingerprintIssue i =+  FingerprintIssue+    { issue = i,+      fingerprint = generateFingerprint i+    }+ formatResult :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => Result s e -> Seq Issue-formatResult (Result errors checks) = allIssues-  where-    allIssues = errorMessages <> checkMessages-    errorMessages = fmap errorToIssue errors-    checkMessages = fmap checkToIssue checks+formatResult (Result errors checks) = (errorToIssue <$> errors) <> (checkToIssue <$> checks) +formatGitlabResult :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => Result s e -> Seq FingerprintIssue+formatGitlabResult result = issueToFingerprintIssue <$> formatResult result+ printResult :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => Result s e -> IO () printResult result = mapM_ output (formatResult result)   where     output value = do       B.putStr (encode value)       B.putStr (B.singleton 0x00)++printGitlabResult :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => Result s e -> IO ()+printGitlabResult = B.putStr . encode . formatGitlabResult
src/Hadolint/Lint.hs view
@@ -33,6 +33,7 @@   = Json   | TTY   | CodeclimateJson+  | GitlabCodeclimateJson   | Checkstyle   | Codacy   deriving (Show, Eq)@@ -50,6 +51,7 @@         Json -> Json.printResult res         Checkstyle -> Checkstyle.printResult res         CodeclimateJson -> Codeclimate.printResult res >> exitSuccess+        GitlabCodeclimateJson -> Codeclimate.printGitlabResult res >> exitSuccess         Codacy -> Codacy.printResult res >> exitSuccess  -- | Performs the process of parsing the dockerfile and analyzing it with all the applicable