mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
removed ruleWithKSOpaDependency function along with tests
Signed-off-by: cbrom <kb.cbrom@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@ package cautils
|
||||
import (
|
||||
"golang.org/x/mod/semver"
|
||||
|
||||
"github.com/armosec/utils-go/boolutils"
|
||||
"github.com/kubescape/opa-utils/reporthandling"
|
||||
"github.com/kubescape/opa-utils/reporthandling/apis"
|
||||
)
|
||||
@@ -33,7 +32,7 @@ func (policies *Policies) Set(frameworks []reporthandling.Framework, version str
|
||||
}
|
||||
}
|
||||
|
||||
if !ruleWithKSOpaDependency(frameworks[i].Controls[j].Rules[r].Attributes) && isRuleKubescapeVersionCompatible(frameworks[i].Controls[j].Rules[r].Attributes, version) && isControlFitToScanScope(frameworks[i].Controls[j], scanningScope) {
|
||||
if isRuleKubescapeVersionCompatible(frameworks[i].Controls[j].Rules[r].Attributes, version) && isControlFitToScanScope(frameworks[i].Controls[j], scanningScope) {
|
||||
compatibleRules = append(compatibleRules, frameworks[i].Controls[j].Rules[r])
|
||||
}
|
||||
}
|
||||
@@ -55,18 +54,6 @@ func (policies *Policies) Set(frameworks []reporthandling.Framework, version str
|
||||
}
|
||||
}
|
||||
|
||||
func ruleWithKSOpaDependency(attributes map[string]interface{}) bool {
|
||||
if attributes == nil {
|
||||
return false
|
||||
}
|
||||
if val, ok := attributes["armoOpa"]; ok { // TODO - make global
|
||||
if s, ok := val.(string); ok {
|
||||
return boolutils.StringToBool(s)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Checks that kubescape version is in range of use for this rule
|
||||
// In local build (BuildNumber = ""):
|
||||
// returns true only if rule doesn't have the "until" attribute
|
||||
|
||||
@@ -9,37 +9,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRuleWithKSOpaDependency(t *testing.T) {
|
||||
t.Run("return false when attributes is nil", func(t *testing.T) {
|
||||
result := ruleWithKSOpaDependency(nil)
|
||||
assert.False(t, result)
|
||||
})
|
||||
|
||||
t.Run("returns false when attributes does not contain armoOpa key", func(t *testing.T) {
|
||||
attributes := map[string]interface{}{
|
||||
"key": "value",
|
||||
}
|
||||
result := ruleWithKSOpaDependency(attributes)
|
||||
assert.False(t, result)
|
||||
})
|
||||
|
||||
t.Run("returns false when attributes contain armoOpa key with non bool value", func(t *testing.T) {
|
||||
attributes := map[string]interface{}{
|
||||
"armoOpa": true,
|
||||
}
|
||||
result := ruleWithKSOpaDependency(attributes)
|
||||
assert.False(t, result)
|
||||
})
|
||||
|
||||
t.Run("returns true when attributes contain armoOpa key with value true", func(t *testing.T) {
|
||||
attributes := map[string]interface{}{
|
||||
"armoOpa": "true",
|
||||
}
|
||||
result := ruleWithKSOpaDependency(attributes)
|
||||
assert.True(t, result)
|
||||
})
|
||||
}
|
||||
|
||||
func TestIsScanningScopeMatchToControlScope(t *testing.T) {
|
||||
tests := []struct {
|
||||
scanScope reporthandling.ScanningScopeType
|
||||
|
||||
Reference in New Issue
Block a user