Skip to content

Commit

Permalink
Support both code and legacy code for config (#967)
Browse files Browse the repository at this point in the history
Severity overrides should support both new code and legacy code in
addition to the severity values
  • Loading branch information
Owen Rumney committed Jul 29, 2021
1 parent 20c7b6e commit 88bc2e0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"version": "0.2.0",
"configurations": [


{
"name": "Basic tfsec",
"type": "go",
Expand Down Expand Up @@ -40,6 +42,14 @@
"program": "${workspaceFolder}/cmd/tfsec/main.go",
"args": ["${workspaceFolder}/example/foreach-module/src"]
},
{
"name": "config override test",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/tfsec/main.go",
"args": ["${workspaceFolder}/example/with_config_overrides"]
},
{
"name": "workspace test",
"type": "go",
Expand Down
2 changes: 1 addition & 1 deletion cmd/tfsec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func updateResultSeverity(results []result.Result) []result.Result {
var overriddenResults []result.Result
for _, res := range results {
for code, sev := range overrides {
if res.RuleID == code {
if res.RuleID == code || res.LegacyRuleID == code {
res.WithSeverity(severity.Severity(sev))
}
}
Expand Down
4 changes: 4 additions & 0 deletions example/with_config_overrides/.tfsec/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
severity_overrides:
AWS077: CRITICAL
aws-s3-specify-public-access-block: CRITICAL
8 changes: 8 additions & 0 deletions example/with_config_overrides/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "aws_s3_bucket" "for_web" {
bucket = "${local.prefix}-${lookup(each.value, "name")}-web"
acl = "private"

tags = {
Name = "${local.prefix}-${lookup(each.value, "name")}-web"
}
}

0 comments on commit 88bc2e0

Please sign in to comment.