Skip to content

Commit

Permalink
fix(k8s): skip empty image pull secrets (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusfm authored Jun 25, 2024
1 parent 5b540eb commit 717b743
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package k8s
import (
"context"
"fmt"
"log/slog"
"strings"

"github.com/aquasecurity/trivy-kubernetes/pkg/bom"
"github.com/aquasecurity/trivy-kubernetes/pkg/k8s/docker"
Expand All @@ -23,8 +25,6 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/utils/strings/slices"
"log/slog"
"strings"
)

var (
Expand Down Expand Up @@ -712,6 +712,9 @@ func (r *cluster) ListByLocalObjectReferences(ctx context.Context, refs []corev1
secrets := make([]*corev1.Secret, 0)

for _, secretRef := range refs {
if secretRef.Name == "" {
continue
}
secret, err := r.clientset.CoreV1().Secrets(ns).Get(ctx, secretRef.Name, metav1.GetOptions{})
if err != nil {
if k8sapierror.IsNotFound(err) || k8sapierror.IsForbidden(err) {
Expand Down

0 comments on commit 717b743

Please sign in to comment.