stackrox/kube-linter

[BUG] --format 'plain' gives no warnings but sarif/json does

Closed this issue · 2 comments

System info:

  • OS: Windows (git bash) & Linux (stackrox alpine docker image)

Describe the bug
Whenever I select 'plain' as --format, it will say it hasn't found errors. Checking it with json or

To Reproduce
Using this configmap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-kube-linter-configmap
data:
  configmap.yaml: |
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: no-name
    data:
      test: big-test

gives

$ kube-linter lint --format plain configmap.yaml
KubeLinter 0.2.4

No lint errors found!

while the other commands do give output (unsure if it's the same warnings that it emits, could check that if you'd like)

sarif

$ kube-linter lint --format sarif configmap.yaml
{"version":"2.1.0","$schema":"ht... #etc, cutoff for brevity

json

$ kube-linter lint --format json configmap.yaml
{"Checks":[{"name":"dangling-service","description":"Indicates when... #etc, cutoff for brevity

Expected behavior
For plain to have the same errors/warnings, just formatted differently.

Hi @frerikandriessen, thanks for filing this issue. This is functioning as designed. The --plain format is designed for human interactive use, so it only prints check failures, whereas the json and sarif formats are designed for scripts, and so they include more metadata. If you examine the outputs, you will see that there are no check failures in the json and sarif output -- what you're seeing is just metadata about what checks are run and similar things. The confusion may stem from the part that the --plain format explicitly tells you that no lint errors were found whereas the other formats don't, but this is as intended given that the other formats are primarily designed for consumption by programs.

Hope that makes sense. I will close this issue, but feel free to comment here if you have any further questions!

You're absolutely right, my bad. Thanks for the explanation!