mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
* support scanning scope Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update go mod Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update white list Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update go mod Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * scope empty return control should tested Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update rego scope for system test Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update test + mock Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * add comment Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update rego library Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update k8s-interface Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update opa utils - lots of file changes in this commit since armoapi-go bump up in opa-utils Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * move to temp k8s-interface - till PR in k8s-interface repo will approved Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update k8s-interface with released tag Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update go mod in httphandler Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * PR review corrections Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * change test name Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * scanning scope support for framework Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * test/mock adjustments after merge Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * add more informative log to the user Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * update go.mod and go.sum of the http handler Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * remove framework just scanning scope not matched to framework config scope Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * add system tests to workflow Signed-off-by: rcohencyberarmor <rcohen@armosec.io> * add system test to github workflow Signed-off-by: rcohencyberarmor <rcohen@armosec.io> --------- Signed-off-by: rcohencyberarmor <rcohen@armosec.io> Signed-off-by: David Wertenteil <dwertent@armosec.io> Co-authored-by: rcohencyberarmor <rcohen@armosec.io> Co-authored-by: David Wertenteil <dwertent@armosec.io>
105 lines
2.2 KiB
Go
105 lines
2.2 KiB
Go
package cautils
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/kubescape/opa-utils/reporthandling"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIsControlFitToScanScope(t *testing.T) {
|
|
tests := []struct {
|
|
scanInfo *ScanInfo
|
|
Control reporthandling.Control
|
|
expected_res bool
|
|
}{
|
|
{
|
|
scanInfo: &ScanInfo{
|
|
InputPatterns: []string{
|
|
"./testdata/any_file_for_test.json",
|
|
},
|
|
},
|
|
Control: reporthandling.Control{
|
|
ScanningScope: &reporthandling.ScanningScope{
|
|
Matches: []reporthandling.ScanningScopeType{
|
|
reporthandling.ScopeFile,
|
|
},
|
|
},
|
|
},
|
|
expected_res: true,
|
|
},
|
|
{
|
|
scanInfo: &ScanInfo{
|
|
InputPatterns: []string{
|
|
"./testdata/any_file_for_test.json",
|
|
},
|
|
},
|
|
Control: reporthandling.Control{
|
|
ScanningScope: &reporthandling.ScanningScope{
|
|
|
|
Matches: []reporthandling.ScanningScopeType{
|
|
reporthandling.ScopeCluster,
|
|
reporthandling.ScopeFile,
|
|
},
|
|
},
|
|
},
|
|
expected_res: true,
|
|
},
|
|
{
|
|
scanInfo: &ScanInfo{},
|
|
Control: reporthandling.Control{
|
|
ScanningScope: &reporthandling.ScanningScope{
|
|
|
|
Matches: []reporthandling.ScanningScopeType{
|
|
reporthandling.ScopeCluster,
|
|
},
|
|
},
|
|
},
|
|
expected_res: true,
|
|
},
|
|
{
|
|
scanInfo: &ScanInfo{
|
|
InputPatterns: []string{
|
|
"./testdata/any_file_for_test.json",
|
|
},
|
|
},
|
|
Control: reporthandling.Control{
|
|
ScanningScope: &reporthandling.ScanningScope{
|
|
|
|
Matches: []reporthandling.ScanningScopeType{
|
|
reporthandling.ScopeCloudGKE,
|
|
},
|
|
},
|
|
},
|
|
expected_res: false,
|
|
},
|
|
{
|
|
scanInfo: &ScanInfo{},
|
|
Control: reporthandling.Control{
|
|
ScanningScope: &reporthandling.ScanningScope{
|
|
|
|
Matches: []reporthandling.ScanningScopeType{
|
|
reporthandling.ScopeCloudEKS,
|
|
},
|
|
},
|
|
},
|
|
expected_res: false,
|
|
},
|
|
{
|
|
scanInfo: &ScanInfo{},
|
|
Control: reporthandling.Control{
|
|
ScanningScope: &reporthandling.ScanningScope{
|
|
Matches: []reporthandling.ScanningScopeType{
|
|
reporthandling.ScopeCloud,
|
|
},
|
|
},
|
|
},
|
|
expected_res: false,
|
|
}}
|
|
for i := range tests {
|
|
assert.Equal(t, isControlFitToScanScope(tests[i].Control, GetScanningScope(tests[i].scanInfo)), tests[i].expected_res, fmt.Sprintf("tests_true index %d", i))
|
|
}
|
|
}
|