Skip to content

Commit

Permalink
fix: ignore no init containers
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <[email protected]>
  • Loading branch information
chen-keinan committed Jan 14, 2024
1 parent e21feb9 commit d612283
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions pkg/artifacts/artifacts.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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())
Expand All @@ -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 {
Expand Down

0 comments on commit d612283

Please sign in to comment.