diff --git a/Dockerfile b/Dockerfile index c47ba82e013..9c71792b48c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ FROM ghcr.io/terraform-linters/tflint:v0.50.3 as tflint FROM ghcr.io/yannh/kubeconform:v0.6.4 as kubeconfrm FROM golang:1.22.2-alpine as golang FROM golangci/golangci-lint:v1.57.2 as golangci-lint +FROM goreleaser/goreleaser:v1.25.1 as goreleaser FROM hadolint/hadolint:v2.12.0-alpine as dockerfile-lint FROM hashicorp/terraform:1.7.5 as terraform FROM koalaman/shellcheck:v0.10.0 as shellcheck @@ -276,6 +277,11 @@ COPY --from=golang /usr/local/go/pkg/ /usr/lib/go/pkg/ COPY --from=golang /usr/local/go/src/ /usr/lib/go/src/ COPY --from=golangci-lint /usr/bin/golangci-lint /usr/bin/ +###################### +# Install GoReleaser # +###################### +COPY --from=goreleaser /usr/bin/goreleaser /usr/bin/ + ##################### # Install Terraform # ##################### diff --git a/README.md b/README.md index 0996946215f..a1b9c8a287f 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Super-linter supports the following tools: | **Gherkin** | [gherkin-lint](https://github.com/vsiakka/gherkin-lint) | | **GitHub Actions** | [actionlint](https://github.com/rhysd/actionlint) | | **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) | +| **GoReleser** | [GoReleser](https://github.com/goreleaser/goreleaser) | | **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) | | **HTML** | [HTMLHint](https://github.com/htmlhint/HTMLHint) | | **Java** | [checkstyle](https://checkstyle.org) / [google-java-format](https://github.com/google/google-java-format) | @@ -274,6 +275,7 @@ You can configure super-linter using the following environment variables: | **VALIDATE_GITLEAKS** | `true` | Flag to enable or disable the linting process of the secrets. | | **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the individual Golang files. Set this to `false` if you want to lint Go modules. See the `VALIDATE_GO_MODULES` variable. | | **VALIDATE_GO_MODULES** | `true` | Flag to enable or disable the linting process of Go modules. Super-linter considers a directory to be a Go module if it contains a file named `go.mod`. | +| **VALIDATE_GO_RELEASER** | `true` | Flag to enable or disable the linting process of the GoReleaser config file. | | **VALIDATE_GOOGLE_JAVA_FORMAT** | `true` | Flag to enable or disable the linting process of the Java language. (Utilizing: google-java-format) | | **VALIDATE_GROOVY** | `true` | Flag to enable or disable the linting process of the language. | | **VALIDATE_HTML** | `true` | Flag to enable or disable the linting process of the HTML language. | diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index c54122a8e27..9363f1d3f18 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -481,6 +481,8 @@ BuildFileArrays() { elif [ "${FILE_TYPE}" == "xml" ] || [ "${FILE_TYPE}" == "xsd" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-XML" + elif [[ "${FILE}" =~ .?goreleaser.+ya?ml ]]; then + echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-GO_RELEASER" elif [ "${FILE_TYPE}" == "yml" ] || [ "${FILE_TYPE}" == "yaml" ]; then echo "${FILE}" >>"${FILE_ARRAYS_DIRECTORY_PATH}/file-array-YAML" if DetectActions "${FILE}"; then diff --git a/lib/functions/linterCommands.sh b/lib/functions/linterCommands.sh index 1fffd17db90..ea91503c8ca 100755 --- a/lib/functions/linterCommands.sh +++ b/lib/functions/linterCommands.sh @@ -51,6 +51,7 @@ LINTER_COMMANDS_ARRAY_GHERKIN=(gherkin-lint -c "${GHERKIN_LINTER_RULES}") LINTER_COMMANDS_ARRAY_GO=(golangci-lint run -c "${GO_LINTER_RULES}" --fast) # Consume the input as we do with ANSIBLE LINTER_COMMANDS_ARRAY_GO_MODULES=(golangci-lint run --allow-parallel-runners -c "${GO_LINTER_RULES}" "&& echo \"Linted: {}\"") +LINTER_COMMANDS_ARRAY_GO_RELEASER=(goreleaser check) LINTER_COMMANDS_ARRAY_GOOGLE_JAVA_FORMAT=(java -jar /usr/bin/google-java-format --dry-run --set-exit-if-changed) LINTER_COMMANDS_ARRAY_GROOVY=(npm-groovy-lint -c "${GROOVY_LINTER_RULES}" --failon warning --no-insight) LINTER_COMMANDS_ARRAY_HTML=(htmlhint --config "${HTML_LINTER_RULES}") diff --git a/lib/linter.sh b/lib/linter.sh index a90ff0478c4..f670c7aaa6e 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -292,7 +292,7 @@ fi LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CHECKOV' 'CLANG_FORMAT' 'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CPP' 'CSHARP' 'CSS' 'DART' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GITHUB_ACTIONS' - 'GITLEAKS' 'GHERKIN' 'GO' 'GO_MODULES' 'GOOGLE_JAVA_FORMAT' 'GROOVY' 'HTML' 'JAVA' + 'GITLEAKS' 'GHERKIN' 'GO' 'GO_MODULES' 'GO_RELEASER' 'GOOGLE_JAVA_FORMAT' 'GROOVY' 'HTML' 'JAVA' 'JAVASCRIPT_ES' "${JAVASCRIPT_STYLE_NAME}" 'JSCPD' 'JSON' 'JSONC' 'JSX' 'KUBERNETES_KUBECONFORM' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN' 'NATURAL_LANGUAGE' 'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' diff --git a/scripts/linterVersions.sh b/scripts/linterVersions.sh index 0fd85a84209..2f0e4239ec5 100755 --- a/scripts/linterVersions.sh +++ b/scripts/linterVersions.sh @@ -25,6 +25,7 @@ LINTER_NAMES_ARRAY['GITLEAKS']="gitleaks" LINTER_NAMES_ARRAY['GHERKIN']="gherkin-lint" LINTER_NAMES_ARRAY['GO']="golangci-lint" LINTER_NAMES_ARRAY['GO_MODULES']="${LINTER_NAMES_ARRAY['GO']}" +LINTER_NAMES_ARRAY['GO_RELEASER']="goreleaser" LINTER_NAMES_ARRAY['GOOGLE_JAVA_FORMAT']="google-java-format" LINTER_NAMES_ARRAY['GROOVY']="npm-groovy-lint" LINTER_NAMES_ARRAY['HTML']="htmlhint" diff --git a/test/inspec/super-linter/controls/super_linter.rb b/test/inspec/super-linter/controls/super_linter.rb index 8f04731a17b..8be2475ebe4 100644 --- a/test/inspec/super-linter/controls/super_linter.rb +++ b/test/inspec/super-linter/controls/super_linter.rb @@ -157,6 +157,7 @@ { linter_name: "gherkin-lint", expected_exit_status: 1}, # expect a return code = 1 because this linter doesn't support a "get linter version" command { linter_name: "gitleaks", version_option: "version"}, { linter_name: "golangci-lint"}, + { linter_name: "goreleaser"}, { linter_name: "google-java-format", version_command: "java -jar /usr/bin/google-java-format --version"}, { linter_name: "hadolint"}, { linter_name: "htmlhint"}, diff --git a/test/linters/go_releaser/.goreleaser_bad_1.yaml b/test/linters/go_releaser/.goreleaser_bad_1.yaml new file mode 100644 index 00000000000..b05fc33d51b --- /dev/null +++ b/test/linters/go_releaser/.goreleaser_bad_1.yaml @@ -0,0 +1,2 @@ +brews: + - folder: test diff --git a/test/linters/go_releaser/.goreleaser_good_1.yaml b/test/linters/go_releaser/.goreleaser_good_1.yaml new file mode 100644 index 00000000000..704c77d1f8e --- /dev/null +++ b/test/linters/go_releaser/.goreleaser_good_1.yaml @@ -0,0 +1,2 @@ +brews: + - directory: test