mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
1.93k stars 203 forks source link

trivy: Handle nil result misconfigurations #579

Closed tom-on-the-internet closed 4 months ago

tom-on-the-internet commented 4 months ago

result.Misconfigurations can be a nil value. I encountered this by explicitly ignoring two Terraform misconfiguration rules.

In the example below, there are two #trivy:ignore comments. Having two ignore comments results in result.Misconfigurations being nil.


#trivy:ignore:AVD-AWS-0089
resource "aws_s3_bucket" "this" {
  bucket = "some-bucket-name"
}

#trivy:ignore:AVD-AWS-0132
resource "aws_s3_bucket_server_side_encryption_configuration" "this" {
  bucket = aws_s3_bucket.this.id

  rule {
    apply_server_side_encryption_by_default {
      sse_algorithm = "AES256"
    }
  }
}

To solve this, I followed the pattern from two lines above where possible falsy value was pair with an "or {}".