replicatedhq / dockerfilelint

An opinionated Dockerfile linter.
https://www.fromlatest.io
MIT License
979 stars 84 forks source link

Ability to supply "Severity" levels for rules #174

Open amthorn opened 3 years ago

amthorn commented 3 years ago

Running in CI pipelines typically uses the exit code to determine if a step has failed. In some cases, some rules from dockerfilelint may be permissable by some projects. Thus, dockerfilelint should expose in it's RC file the ability to specify a severity level (Similar to eslint perhaps) instead of just a boolean "on/off". This way, variations of rules can be configured for individual use cases.

Perhaps something like:

rules:
  uppercase_commands: "ERROR"
  expose_port_valid: "WARNING"
  label_format: "INFO"
  base_image_tag: on

If issues are found of severity level INFO/WARNING, then this should keep the exit code at 0. However, if at least one issue is found that has a severity level of error, the exit code should be > 0.

The default severity level, if not provided or using the old "on/off" syntax, should be ERROR to maintain backward compatibility.

I've solved this issue in my fork here: https://github.com/amthorn/dockerfilelint/tree/specify_severity

I'll submit a PR as soon as https://github.com/replicatedhq/dockerfilelint/pull/172 is reviewed/merged as there is a dependency on that PR. Here's the diff: https://github.com/amthorn/dockerfilelint/compare/add_custom_rulesets...amthorn:specify_severity