mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
* add cmd Signed-off-by: Daniel Grunberger <danielgrunberger@armosec.io> * support single workload scan Signed-off-by: Amir Malka <amirm@armosec.io> * fix conflict Signed-off-by: Amir Malka <amirm@armosec.io> * added unit tests Signed-off-by: Amir Malka <amirm@armosec.io> * added unit tests Signed-off-by: Amir Malka <amirm@armosec.io> * more refactoring Signed-off-by: Amir Malka <amirm@armosec.io> * add scanned workload reference to opasessionobj Signed-off-by: Amir Malka <amirm@armosec.io> * fix GetWorkloadParentKind Signed-off-by: Amir Malka <amirm@armosec.io> * remove namespace argument from pullSingleResource, using field selector instead Signed-off-by: Amir Malka <amirm@armosec.io> * removed designators (unused) field from PolicyIdentifier, and designators argument from GetResources function Signed-off-by: Amir Malka <amirm@armosec.io> * fix tests Signed-off-by: Amir Malka <amirm@armosec.io> * use ScanObject instead of workload identifier Signed-off-by: Amir Malka <amirm@armosec.io> * refactor logic after CR Signed-off-by: Amir Malka <amirm@armosec.io> --------- Signed-off-by: Daniel Grunberger <danielgrunberger@armosec.io> Signed-off-by: Amir Malka <amirm@armosec.io> Co-authored-by: Daniel Grunberger <danielgrunberger@armosec.io>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package cautils
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/kubescape/k8s-interface/cloudsupport"
|
|
cloudapis "github.com/kubescape/k8s-interface/cloudsupport/apis"
|
|
"github.com/kubescape/opa-utils/reporthandling/apis"
|
|
)
|
|
|
|
var (
|
|
ImageVulnResources = []string{"ImageVulnerabilities"}
|
|
HostSensorResources = []string{"KubeletConfiguration",
|
|
"KubeletCommandLine",
|
|
"OsReleaseFile",
|
|
"KernelVersion",
|
|
"LinuxSecurityHardeningStatus",
|
|
"OpenPortsList",
|
|
"LinuxKernelVariables",
|
|
"KubeletInfo",
|
|
"KubeProxyInfo",
|
|
"ControlPlaneInfo",
|
|
"CloudProviderInfo",
|
|
"CNIInfo",
|
|
}
|
|
CloudResources = []string{
|
|
cloudapis.CloudProviderDescribeKind,
|
|
cloudapis.CloudProviderDescribeRepositoriesKind,
|
|
cloudapis.CloudProviderListEntitiesForPoliciesKind,
|
|
cloudapis.CloudProviderPolicyVersionKind,
|
|
string(cloudsupport.TypeApiServerInfo),
|
|
}
|
|
)
|
|
|
|
func MapKSResource(ksResourceMap KSResources, resources []string) []string {
|
|
var hostResources []string
|
|
for k := range ksResourceMap {
|
|
for _, resource := range resources {
|
|
if strings.Contains(k, resource) {
|
|
hostResources = append(hostResources, k)
|
|
}
|
|
}
|
|
}
|
|
return hostResources
|
|
}
|
|
|
|
func MapHostResources(ksResourceMap KSResources) []string {
|
|
return MapKSResource(ksResourceMap, HostSensorResources)
|
|
}
|
|
|
|
func MapImageVulnResources(ksResourceMap KSResources) []string {
|
|
return MapKSResource(ksResourceMap, ImageVulnResources)
|
|
}
|
|
|
|
func MapCloudResources(ksResourceMap KSResources) []string {
|
|
return MapKSResource(ksResourceMap, CloudResources)
|
|
}
|
|
|
|
func SetInfoMapForResources(info string, resources []string, errorMap map[string]apis.StatusInfo) {
|
|
for _, resource := range resources {
|
|
errorMap[resource] = apis.StatusInfo{
|
|
InnerInfo: info,
|
|
InnerStatus: apis.StatusSkipped,
|
|
}
|
|
}
|
|
}
|