Git Product home page Git Product logo

config-lint's Introduction

Latest Release Build & Deploy Go Report Card

๐Ÿ” config-lint ๐Ÿ”Ž

A command line tool to validate configuration files using rules specified in YAML. The configuration files can be one of several formats: Terraform, JSON, YAML, with support for Kubernetes. There are built-in rules provided for Terraform, and custom files can be used for other formats.

๐Ÿ““ Documentation

๐Ÿ‘ท Contributing

๐Ÿ› Issues & Bugs

Blog Posts

โœ๏ธ config-lint: Up and Running

โœ๏ธ Development Acceleration Through VS Code Remote Containers

Quick Start

Install the latest version of config-lint on macOS using Homebrew:

brew tap stelligent/tap
brew install config-lint

Or manually on Linux:

curl -L https://github.com/stelligent/config-lint/releases/latest/download/config-lint_Linux_x86_64.tar.gz | tar xz -C /usr/local/bin config-lint
chmod +rx /usr/local/bin/config-lint

Run the built-in ruleset against your Terraform files. For instance if you want to run config-lint against our example files:

config-lint -terraform example-files/config

You will see failure and warning violations in the output like this:

[
  {
    "AssertionMessage": "viewer_certificate[].cloudfront_default_certificate | [0] should be 'false', not ''",
    "Category": "resource",
    "CreatedAt": "2020-04-15T19:24:33Z",
    "Filename": "example-files/config/cloudfront.tf",
    "LineNumber": 10,
    "ResourceID": "s3_distribution",
    "ResourceType": "aws_cloudfront_distribution",
    "RuleID": "CLOUDFRONT_MINIMUM_SSL",
    "RuleMessage": "CloudFront Distribution must use TLS 1.2",
    "Status": "FAILURE"
  },
  ...

You can find more install options in our installation guide.

config-lint's People

Contributors

aabouzaid avatar brianjakovich avatar car6807 avatar chapipo avatar cplee avatar gitter-badger avatar jeffb4 avatar kidbrax avatar lhitchon avatar michae1ho11ey avatar milldr avatar namloc2001 avatar oshaughnessy avatar psg9999 avatar rmorris1218 avatar ryanpagel avatar twellspring avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

config-lint's Issues

Follow terraform module calls

I have a lot of terraform repositories where there is a root module that includes other modules with some inputs/attributes. Those inputs are variables for the other modules, which affect whether they pass or fail rules. But config-lint doesn't handle that situation correctly, instead looking at just one file at a time, and not being aware of the relationship between the files or what is in the variables one is passing to another.

I would like to be able to config-lint a single root module and have it include/import the referenced modules with the appropriate inputs/variables.

Update build image to go 1.12

go.mod defines go 1.12, but the circleci build image we're using is circleci/golang:1.11. We need to set the build image to circleci/golang:1.12 and test accordingly.

Rule Load Failure Exit Code

On rule failure, exit code is 0

Example:

$ config-lint -rules config_lint_rules/config_lint_default_rules.yml .
Failed to load rules: error unmarshaling JSON: json: cannot unmarshal array into Go struct field Expression.Value of type string
$ echo $?
0

Expected behavior:
exit code is 1

Add a way for a rule to exclude resources

Rules can be scoped to a specific ResourceType which can be "*" for all resources.
They can also be scoped to a list of ResourceTypes
It would be nice to have a way to specify "all resources except for this list"
This is more future-proof than explicitly listing all known resources in the ResourceTypes attribute.

Some typical use cases:
Tagging strategies for AWS resources - list resources types that do not support tagging
Metadata - list resource types that do not require certain metadata attributes

Feature Request: xunit xml output

In CI toolchains capable of parsing and making workflow decisions based on xunit xml artifacts, it would be useful for config-lint to emit such an XML file of its linting results (vice return codes and JSON output).

I found a couple of examples of golang emitting junit/xunit, but they seemed non-trivial

Allow multiple resources for each rule

Allow a rule to apply to multiple resources, defined as a list.

Example:

  - id: UTAN_VALID_REGEX
    resources: 
        - aws_dynamodb_table
        - aws_instance
    message: make sure that UTAN is a valid regex
    severity: WARNING
    assertions: 
      - key: tags[0].utan
        op: regex
        value: "^[0-9]{5}$"

Support terraform variable maps

Some of our repositories are trying to stay as DRY as possible in their code and heavily using built in Terraform features such as maps for defining tags.

variables.tf
variable "common_tags" { description = "Common resource tags." type = "map"

module.tf <-- Fails linting
tags = ${var.common_tags}

Where the variables are set and rendered on apply per environment:

main.tf
common_tags = "${map( "App", "App Name", "Product", "Product", "Team", "My Team", )}"

Having config-lint being able to render out the map would be fantastic as the alternative is to modify the rules to look for the required tags or $(var.common_tags) which feels like a band-aid.

Fix deprecated goreleaser build fields

running goreleaser shows a few deprecated notices:

โ€ข ARCHIVES
      โ€ข DEPRECATED: `archive` should not be used anymore, check https://goreleaser.com/deprecations#archive for more info.
โ€ข HOMEBREW TAP FORMULA
      โ€ข DEPRECATED: `brew` should not be used anymore, check https://goreleaser.com/deprecations#brew for more info.

Feature: Add Operation for CIDR Calculations

Add an is-subnet operator that can determine whether or not the value is a member of a given network.

This will be used to allow our Terraform SCA to check security group rules are within RFC1918 ranges.

Example:

...
  - id: SG1
    resource: aws_security_group
    message: Security group should not allow ingress from 0.0.0.0/0
    severity: FAILURE
    assertions:
      - key: "ingress[].cidr_blocks[] | [*]"
        op: is-subnet
        value: "10.0.0.0/8"
...

I am happy to implement this. Do you have any reqs for the design? Otherwise I can submit a PR for review. @lhitchon @jeffb4

Add max-host-count Operation

Add a max-host-count operations. This would be especially helpful in assessing CIDR blocks in configuration.

For example:

...
  - id: MAX_HOSTS_EXPOSED_PER_RULE
    message: All security group rules must expose less than 1016 hosts
    severity: FAILURE
    resource: aws_security_group_rule
    assertions:
      - every:
        key: "cidr_blocks"
        expressions:
          - key: "@"
            op: max-host-count
            value: 1016
...

Update VS Code Remote Dev Environment

The VS Code Remote Development environment needs more fine tuning and further customizations.

  • Custom vscode extensions (and appropriate settings)
  • git support
  • non-root user
  • load custom container image from stelligent Docker Hub

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.