mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-08-22 21:56:32 +00:00
* Implement namespace support for exceptions Signed-off-by: Markus Blaschke <mblaschke82@gmail.com> * remove debug Signed-off-by: Markus Blaschke <mblaschke82@gmail.com> * Add documentation Signed-off-by: Markus Blaschke <mblaschke82@gmail.com> Co-authored-by: baderbuddy <bader@fairwinds.com>
42 lines
900 B
Go
42 lines
900 B
Go
package config
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// IsActionable determines whether a check is actionable given the current configuration
|
|
func (conf Configuration) IsActionable(ruleID, namespace, controllerName string) bool {
|
|
if severity, ok := conf.Checks[ruleID]; !ok || !severity.IsActionable() {
|
|
return false
|
|
}
|
|
if conf.DisallowExemptions {
|
|
return true
|
|
}
|
|
|
|
for _, example := range conf.Exemptions {
|
|
if example.Namespace != "" && example.Namespace != namespace {
|
|
continue
|
|
}
|
|
|
|
for _, rule := range example.Rules {
|
|
if rule != ruleID {
|
|
continue
|
|
}
|
|
|
|
for _, controller := range example.ControllerNames {
|
|
if strings.HasPrefix(controllerName, controller) {
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
if len(example.Rules) == 0 {
|
|
for _, controller := range example.ControllerNames {
|
|
if strings.HasPrefix(controllerName, controller) {
|
|
return false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true
|
|
}
|