From d612283e7212f19e763cef224ddf6e8cb09d5582 Mon Sep 17 00:00:00 2001 From: chenk Date: Sun, 14 Jan 2024 13:01:45 +0200 Subject: [PATCH] fix: ignore no init containers Signed-off-by: chenk --- pkg/artifacts/artifacts.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/artifacts/artifacts.go b/pkg/artifacts/artifacts.go index 7340d23..48b2245 100644 --- a/pkg/artifacts/artifacts.go +++ b/pkg/artifacts/artifacts.go @@ -1,9 +1,6 @@ package artifacts import ( - "fmt" - "strings" - "github.com/aquasecurity/trivy-kubernetes/pkg/k8s" "github.com/aquasecurity/trivy-kubernetes/pkg/k8s/docker" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -20,8 +17,6 @@ type Artifact struct { RawResource map[string]interface{} } -const ResourceWithContainers = "Pod,Job,CronJob,ReplicaSet,ReplicationController,StatefulSet,DaemonSet,Deployment" - // FromResource is a factory method to create an Artifact from an unstructured.Unstructured func FromResource(resource unstructured.Unstructured, serverAuths map[string]docker.Auth) (*Artifact, error) { nestedKeys := getContainerNestedKeys(resource.GetKind()) @@ -45,9 +40,7 @@ func FromResource(resource unstructured.Unstructured, serverAuths map[string]doc } } } - if len(images) == 0 && strings.Contains(ResourceWithContainers, resource.GetKind()) { - return nil, fmt.Errorf("no images found in %s/%s", resource.GetNamespace(), resource.GetName()) - } + // we don't check found here, if the name is not found it will be an empty string name, _, err := unstructured.NestedString(resource.Object, "metadata", "name") if err != nil {