mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
update disallow new capabilities
This commit is contained in:
parent
4e848b48a2
commit
121b81a83b
4 changed files with 14 additions and 13 deletions
|
@ -111,8 +111,9 @@ func Test_validate_disallow_host_filesystem_fail(t *testing.T) {
|
||||||
func Test_validate_disallow_host_filesystem_pass(t *testing.T) {
|
func Test_validate_disallow_host_filesystem_pass(t *testing.T) {
|
||||||
testScenario(t, "test/scenarios/samples/best_practices/scenario_validate_disallow_host_filesystem_pass.yaml")
|
testScenario(t, "test/scenarios/samples/best_practices/scenario_validate_disallow_host_filesystem_pass.yaml")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_validate_disallow_new_capabilities(t *testing.T) {
|
func Test_validate_disallow_new_capabilities(t *testing.T) {
|
||||||
testScenario(t, "/test/scenarios/samples/best_practices/scenario_validate_disallow_new_capabilities.yaml")
|
testScenario(t, "/test/scenarios/samples/best_practices/disallow_new_capabilities.yaml")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_validate_disallow_docker_sock_mount(t *testing.T) {
|
func Test_validate_disallow_docker_sock_mount(t *testing.T) {
|
||||||
|
|
|
@ -14,9 +14,9 @@ default capabilities.
|
||||||
apiVersion: kyverno.io/v1alpha1
|
apiVersion: kyverno.io/v1alpha1
|
||||||
kind: ClusterPolicy
|
kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: validate-new-capabilities
|
name: disallow-new-capabilities
|
||||||
annotations:
|
annotations:
|
||||||
policies.kyverno.io/category: Security Context
|
policies.kyverno.io/category: Security
|
||||||
policies.kyverno.io/description: Linux allows defining fine-grained permissions using
|
policies.kyverno.io/description: Linux allows defining fine-grained permissions using
|
||||||
capabilities. With Kubernetes, it is possible to add capabilities that escalate the
|
capabilities. With Kubernetes, it is possible to add capabilities that escalate the
|
||||||
level of kernel access and allow other potentially dangerous behaviors. This policy
|
level of kernel access and allow other potentially dangerous behaviors. This policy
|
||||||
|
@ -24,13 +24,13 @@ metadata:
|
||||||
default capabilities.
|
default capabilities.
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- name: deny-new-capabilities
|
- name: validate-add-capabilities
|
||||||
match:
|
match:
|
||||||
resources:
|
resources:
|
||||||
kinds:
|
kinds:
|
||||||
- Pod
|
- Pod
|
||||||
validate:
|
validate:
|
||||||
message: "Capabilities cannot be added"
|
message: "New capabilities cannot be added"
|
||||||
anyPattern:
|
anyPattern:
|
||||||
- spec:
|
- spec:
|
||||||
=(securityContext):
|
=(securityContext):
|
||||||
|
@ -42,4 +42,5 @@ spec:
|
||||||
=(securityContext):
|
=(securityContext):
|
||||||
=(capabilities):
|
=(capabilities):
|
||||||
X(add): null
|
X(add): null
|
||||||
|
|
||||||
````
|
````
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
apiVersion: kyverno.io/v1alpha1
|
apiVersion: kyverno.io/v1alpha1
|
||||||
kind: ClusterPolicy
|
kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: validate-new-capabilities
|
name: disallow-new-capabilities
|
||||||
annotations:
|
annotations:
|
||||||
policies.kyverno.io/category: Security Context
|
policies.kyverno.io/category: Security
|
||||||
policies.kyverno.io/description: Linux allows defining fine-grained permissions using
|
policies.kyverno.io/description: Linux allows defining fine-grained permissions using
|
||||||
capabilities. With Kubernetes, it is possible to add capabilities that escalate the
|
capabilities. With Kubernetes, it is possible to add capabilities that escalate the
|
||||||
level of kernel access and allow other potentially dangerous behaviors. This policy
|
level of kernel access and allow other potentially dangerous behaviors. This policy
|
||||||
|
@ -11,13 +11,13 @@ metadata:
|
||||||
default capabilities.
|
default capabilities.
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- name: deny-new-capabilities
|
- name: validate-add-capabilities
|
||||||
match:
|
match:
|
||||||
resources:
|
resources:
|
||||||
kinds:
|
kinds:
|
||||||
- Pod
|
- Pod
|
||||||
validate:
|
validate:
|
||||||
message: "Capabilities cannot be added"
|
message: "New capabilities cannot be added"
|
||||||
anyPattern:
|
anyPattern:
|
||||||
- spec:
|
- spec:
|
||||||
=(securityContext):
|
=(securityContext):
|
||||||
|
@ -28,4 +28,4 @@ spec:
|
||||||
- name: "*"
|
- name: "*"
|
||||||
=(securityContext):
|
=(securityContext):
|
||||||
=(capabilities):
|
=(capabilities):
|
||||||
X(add): null
|
X(add): null
|
||||||
|
|
|
@ -5,14 +5,13 @@ input:
|
||||||
expected:
|
expected:
|
||||||
validation:
|
validation:
|
||||||
policyresponse:
|
policyresponse:
|
||||||
policy: validate-new-capabilities
|
policy: disallow-new-capabilities
|
||||||
resource:
|
resource:
|
||||||
kind: Pod
|
kind: Pod
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
namespace: ''
|
namespace: ''
|
||||||
name: "add-new-capabilities"
|
name: "add-new-capabilities"
|
||||||
rules:
|
rules:
|
||||||
- name: deny-new-capabilities
|
- name: validate-add-capabilities
|
||||||
type: Validation
|
type: Validation
|
||||||
message: "Validation error: Capabilities cannot be added\nValidation rule deny-new-capabilities anyPattern[0] failed at path /spec/.\nValidation rule deny-new-capabilities anyPattern[1] failed at path /spec/containers/0/securityContext/capabilities/add/."
|
|
||||||
success: false
|
success: false
|
Loading…
Add table
Reference in a new issue