diff --git a/reporthandling/datastructuresmethods.go b/reporthandling/datastructuresmethods.go index e30ca535..b3020725 100644 --- a/reporthandling/datastructuresmethods.go +++ b/reporthandling/datastructuresmethods.go @@ -12,7 +12,10 @@ import ( "golang.org/x/exp/slices" ) -const ActionRequiredAttribute string = "actionRequired" +const ( + ActionRequiredAttribute string = "actionRequired" + ControlAttributeKeyIsFixedByNetworkPolicy string = "isFixedByNetworkPolicy" +) // ============================================================================================== // ========================== PostureReport ===================================================== @@ -443,6 +446,19 @@ func (control *Control) GetControlTypeTags() []string { return []string{} } +// returns true if control has attribute "isFixedByNetworkPolicy" and its value is true +func (control *Control) IsFixedByNetworkPolicy() bool { + if control.Attributes == nil { + return false + } + if v, exist := control.Attributes[ControlAttributeKeyIsFixedByNetworkPolicy]; exist { + if isFixedByNetworkPolicy, ok := v.(bool); ok { + return isFixedByNetworkPolicy + } + } + return false +} + func (control *Control) SupportSmartRemediation() bool { typeTags := control.GetControlTypeTags() return slices.Contains(typeTags, v1alpha1.ControlTypeTagSmartRemediation)