Merge pull request #217 from dwertent/master

Fixed include namespaces
This commit is contained in:
David Wertenteil
2021-11-07 13:56:56 +02:00
committed by GitHub
2 changed files with 11 additions and 21 deletions
+1 -16
View File
@@ -5,7 +5,6 @@ import (
"strings"
"github.com/armosec/k8s-interface/k8sinterface"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)
@@ -55,22 +54,8 @@ func getNamespacesSelector(resource *schema.GroupVersionResource, ns, operator s
}
namespacesSlice := strings.Split(ns, ",")
for _, n := range namespacesSlice {
fieldSelectors += fmt.Sprintf("%s!=%s,", fieldSelector, n)
fieldSelectors += fmt.Sprintf("%s%s%s,", fieldSelector, operator, n)
}
return fieldSelectors
}
func setFieldSelector(listOptions *metav1.ListOptions, resource *schema.GroupVersionResource, excludedNamespaces string) {
fieldSelector := "metadata."
if resource.Resource == "namespaces" {
fieldSelector += "name"
} else if k8sinterface.IsNamespaceScope(resource.Group, resource.Resource) {
fieldSelector += "namespace"
} else {
return
}
excludedNamespacesSlice := strings.Split(excludedNamespaces, ",")
for _, excludedNamespace := range excludedNamespacesSlice {
listOptions.FieldSelector += fmt.Sprintf("%s!=%s,", fieldSelector, excludedNamespace)
}
}
+10 -5
View File
@@ -33,10 +33,15 @@ if __name__ == "__main__":
run(kubescape_exec=smoke_utils.get_exec_from_args(sys.argv))
'''
Tests to add:
1. Scan E2E
2. Download and add --use-from
Supported tests:
1. Commands
2. Version number
3. E2E yaml scanning
3. Test formats + output
4. Test -t
TODO:
1. Test formats + output
2. Test --fail-threshold
3. Test known supported FW
4. Test FW list
5. Test Controls list
'''