fix(query): Extend image_pull_policy_of_container_is_not_always k8s rule to cover additional resource kinds #4891
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The rule intends to address the problem that image tags are mutable and it is not guaranteed that the version of an image that is cached on a node equals the one with the same tag in a registry. This potential security issue can be prevented by any of the following conditions:
imagePullPolicy
to "Always" to ensure the kubelet downloads the image anew every time it launches the containerimagePullPolicy
but by providing an image in one the following ways:Except for the last sub-item, Kubernetes will apply
imagePullPolicy: Always
. When an image is provided together with a digest, caching by a node is legit and does not trigger the potential security risk this rule strives to detect. Also, this is analogous to what is done by the kubelet with policy "Always" (see here. In other words, since the digest associated with an image is immutable, it unambiguously refers to a specific image locally and/or in the registry.Problem
imagePullPolicy
is always defined. Otherwise, the rule aborts early as a statement evalutes to false. This is an issue as the default pull policy isIfNotPresent
and notAlways
Proposed Changes
imagePullPolicy != "Always"
in a DeploymentimagePullPolicy
not specified but a tagI submit this contribution under the Apache-2.0 license.