-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(k8s): improve k8s scanning to handle namespace-restricted controllers #8620
Comments
additional info. it comes from here: also we should skip node checks here: trivy/pkg/k8s/scanner/scanner.go Lines 228 to 231 in ad58cf4
trivy/pkg/k8s/scanner/scanner.go Lines 377 to 381 in ad58cf4
|
I also tested scanning for $ trivy k8s --report summary
...
Infra Assessment
┌─────────────┬──────────────────────────────────────────────┬──────────────────────┬────────────────────┬───────────────────┐
│ Namespace │ Resource │ Vulnerabilities │ Misconfigurations │ Secrets │
│ │ ├───┬────┬────┬────┬───┼───┬───┬───┬────┬───┼───┬───┬───┬───┬───┤
│ │ │ C │ H │ M │ L │ U │ C │ H │ M │ L │ U │ C │ H │ M │ L │ U │
├─────────────┼──────────────────────────────────────────────┼───┼────┼────┼────┼───┼───┼───┼───┼────┼───┼───┼───┼───┼───┼───┤
│ kube-system │ Pod/kube-apiserver-minikube │ 1 │ 2 │ 13 │ │ │ │ 2 │ 7 │ 19 │ │ │ │ │ │ │
│ kube-system │ Pod/kube-controller-manager-minikube │ 1 │ 2 │ 13 │ │ │ │ 2 │ 6 │ 12 │ │ │ │ │ │ │
│ kube-system │ Pod/kube-scheduler-minikube │ 1 │ 2 │ 12 │ │ │ │ 2 │ 6 │ 10 │ │ │ │ │ │ │
│ kube-system │ ConfigMap/extension-apiserver-authentication │ │ │ │ │ │ │ │ 1 │ │ │ │ │ │ │ │
│ kube-system │ DaemonSet/kube-proxy │ 1 │ 2 │ 18 │ 16 │ │ │ 3 │ 8 │ 12 │ │ │ │ │ │ │
│ kube-system │ Deployment/coredns │ 2 │ 8 │ 24 │ 1 │ 2 │ │ │ 8 │ 6 │ │ │ │ │ │ │
│ kube-system │ Pod/storage-provisioner │ 5 │ 52 │ 38 │ 1 │ │ │ 3 │ 7 │ 12 │ │ │ │ │ │ │
│ kube-system │ Service/kube-dns │ │ │ │ │ │ │ │ 1 │ 2 │ │ │ │ │ │ │
│ kube-system │ Pod/etcd-minikube │ 4 │ 9 │ 29 │ 4 │ │ │ 2 │ 6 │ 9 │ │ │ │ │ │ │
│ │ Node/minikube │ │ │ │ │ │ │ 3 │ │ 2 │ │ │ │ │ │ │
└─────────────┴──────────────────────────────────────────────┴───┴────┴────┴────┴───┴───┴───┴───┴────┴───┴───┴───┴───┴───┴───┘
Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN $ trivy k8s --report summary --include-namespaces kube-system
...
Infra Assessment
┌─────────────┬──────────────────────────────────────────────┬──────────────────────┬────────────────────┬───────────────────┐
│ Namespace │ Resource │ Vulnerabilities │ Misconfigurations │ Secrets │
│ │ ├───┬────┬────┬────┬───┼───┬───┬───┬────┬───┼───┬───┬───┬───┬───┤
│ │ │ C │ H │ M │ L │ U │ C │ H │ M │ L │ U │ C │ H │ M │ L │ U │
├─────────────┼──────────────────────────────────────────────┼───┼────┼────┼────┼───┼───┼───┼───┼────┼───┼───┼───┼───┼───┼───┤
│ kube-system │ ConfigMap/extension-apiserver-authentication │ │ │ │ │ │ │ │ 1 │ │ │ │ │ │ │ │
│ kube-system │ Deployment/coredns │ 2 │ 8 │ 24 │ 1 │ 2 │ │ │ 8 │ 6 │ │ │ │ │ │ │
│ kube-system │ Pod/kube-apiserver-minikube │ 1 │ 2 │ 13 │ │ │ │ 2 │ 7 │ 19 │ │ │ │ │ │ │
│ kube-system │ Pod/kube-scheduler-minikube │ 1 │ 2 │ 12 │ │ │ │ 2 │ 6 │ 10 │ │ │ │ │ │ │
│ kube-system │ Service/kube-dns │ │ │ │ │ │ │ │ 1 │ 2 │ │ │ │ │ │ │
│ kube-system │ DaemonSet/kube-proxy │ 1 │ 2 │ 18 │ 16 │ │ │ 3 │ 8 │ 12 │ │ │ │ │ │ │
│ kube-system │ Pod/etcd-minikube │ 4 │ 9 │ 29 │ 4 │ │ │ 2 │ 6 │ 9 │ │ │ │ │ │ │
│ kube-system │ Pod/kube-controller-manager-minikube │ 1 │ 2 │ 13 │ │ │ │ 2 │ 6 │ 12 │ │ │ │ │ │ │
│ kube-system │ Pod/storage-provisioner │ 5 │ 52 │ 38 │ 1 │ │ │ 3 │ 7 │ 12 │ │ │ │ │ │ │
└─────────────┴──────────────────────────────────────────────┴───┴────┴────┴────┴───┴───┴───┴───┴────┴───┴───┴───┴───┴───┴───┘
Severities: C=CRITICAL H=HIGH M=MEDIUM L=LOW U=UNKNOWN |
isn't this a bug? |
I think that no, |
Description
By design Trivy k8s scans only targeted control plane components (Infra Assessment), which made sense for cluster-level scanning (without namespaces).
However, Trivy now supports scanning controllers that may be restricted to specific namespaces.
We should enhance the handling of such cases to ensure accurate and comprehensive scanning.
See below for details:
Without the
--include-namespaces
flagWith the
--include-namespaces
flagObserve that
ControlPlaneComponents/k8s.io/ingress-nginx
does not show up when filtering by namespace even though it is in the same namespace as the filter.Originally posted by @simar7 in #8614 (comment)
The text was updated successfully, but these errors were encountered: