stackrox / kube-linter

KubeLinter is a static analysis tool that checks Kubernetes YAML files and Helm charts to ensure the applications represented in them adhere to best practices.
https://docs.kubelinter.io/
Apache License 2.0
2.82k stars 228 forks source link

Include line and column number ranges for errors #757

Closed mohkale closed 1 month ago

mohkale commented 3 months ago

Description of the problem/feature request

Hi there,

I'm trying to integrate this package into emacs through flymake. Most linters I've used normally output ranges where errors apply to make it easier for users to go-to and fix them. Kube-linter seems to only output messages and namespace information but not file specific location info so it's harder to correlate it with a place in the file to update for in editor highlighting.

Description of the existing behavior vs. expected behavior

Currently when run on the input file from before I see:

KubeLinter development

<standard input>: (object: <no namespace>/security-context-demo /v1, Kind=Pod) The container "sec-ctx-demo" is using an invalid container image, "busybox". Please use images that are not blocked by the `BlockList` criteria : [".*:(latest)$" "^[^:]*$" "(.*/[^:]+)$"] (check: latest-tag, remediation: Use a container image with a specific tag other than latest.)

<standard input>: (object: <no namespace>/security-context-demo /v1, Kind=Pod) container "sec-ctx-demo" does not have a read-only root file system (check: no-read-only-root-fs, remediation: Set readOnlyRootFilesystem to true in the container securityContext.)

<standard input>: (object: <no namespace>/security-context-demo /v1, Kind=Pod) container "sec-ctx-demo" has cpu limit 0 (check: unset-cpu-requirements, remediation: Set CPU requests and limits for your container based on its requirements. Refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits for details.)

<standard input>: (object: <no namespace>/security-context-demo /v1, Kind=Pod) container "sec-ctx-demo" has memory limit 0 (check: unset-memory-requirements, remediation: Set memory requests and limits for your container based on its requirements. Refer to https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#requests-and-limits for details.)

Error: found 4 lint errors

I'd suggest just appending line and column values after the standard-input prefix which is consistent with most other linters. For the JSON export a terminating range where the lint ends would also be useful.

Additional context

janisz commented 1 month ago

Duplicates