Skip to content

Commit

Permalink
Added exception check for resources
Browse files Browse the repository at this point in the history
Added additional check for `addExceptionsToRuleSet` for rules that use `resources` without explicitly setting the `ResourceCategory` to `resources`. Conditional will check for whether the exception `ResourceType` in the rule `Resources`.
  • Loading branch information
CAR6807 committed Oct 4, 2018
1 parent df10fd8 commit 57618f1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ func addExceptionsToRuleSet(ruleSet assertion.RuleSet, exceptions []RuleExceptio
rules := []assertion.Rule{}
for _, rule := range ruleSet.Rules {
for _, e := range exceptions {
if rule.ID == e.RuleID &&
if len(rule.Resources) > 0 {
if assertion.SliceContains(rule.Resources, e.ResourceType) &&
rule.ID == e.RuleID &&
(rule.Category == e.ResourceCategory || e.ResourceCategory == "resources") {
rule.Except = append(rule.Except, e.ResourceID)
}
} else if rule.ID == e.RuleID &&
rule.Resource == e.ResourceType &&
(rule.Category == e.ResourceCategory || rule.Category == "") {
rule.Except = append(rule.Except, e.ResourceID)
Expand Down

0 comments on commit 57618f1

Please sign in to comment.