-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
bug(k8s): Image scanned from "metadata:annotations:kubectl.kubernetes.io/last-applied-configuration" instead of "spec" #7573
Comments
I'd like to grab this one |
@michaeljsaenz thanks! it'd be really nice! |
please assign 👍🏽 |
hi @michaeljsaenz! |
hi @afdesk !
Thank you! |
@michaeljsaenz |
maybe it'll help you #4784 |
We see similar behaviour but for findings such as 'securityContext.readOnlyRootFilesystem' should be set to true (AVD-KSV-0014) I've fixed a number of these findings but they still show on the Trivy report because the old configuration details are in the |
hi @michaeljsaenz |
@phr3nzii thanks for the report! will try to fix it before next release |
Description
since #4786 (aquasecurity/trivy-kubernetes#189) Trivy scan last applied configuration instead of actual Resource state.
Reason
For scans Trivy prefers info from an annotation. so if a customer mixes imperative and declarative styles, the result is a bit confusing.
https://github.com/aquasecurity/trivy-kubernetes/blob/b070991579cacd7634052dee2e250350d6e493e8/pkg/trivyk8s/trivyk8s.go#L208-L214
Note: the issue will be happened only if a resource is created from
kubectl apply
.Solution
We can try to receive a version info more flexible way
Reproduction Steps
/nginx-deployment
```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx web: my-app spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.1 ports: - containerPort: 80 ```$ kubectl set image deployment.apps/nginx-deployment nginx=nginx:1.15.0
nginx-deployment details
apiVersion: apps/v1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "3" kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"nginx","web":"my-app"},"name":"nginx-deployment","namespace":"7551"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"nginx"}},"template":{"metadata":{"labels":{"app":"nginx"}},"spec":{"containers":[{"image":"nginx:1.14.1","name":"nginx","ports":[{"containerPort":80}]}]}}}} labels: app: nginx web: my-app pec: replicas: 1 template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: nginx:1.15.0 name: nginx ports: - containerPort: 80 ... ```nginx:1.14.1
instead of `nginx:1.15.0", that actually runs in a cluster.Discussed in #7551
The text was updated successfully, but these errors were encountered: