mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
Merge branch '451_fix_disallow_host_net_port' into 452_make_sample_policy_rule_names_consistent
# Conflicts: # samples/best_practices/disallow_host_network_hostport.yaml # test/scenarios/samples/best_practices/disallow_host_network_port.yaml
This commit is contained in:
commit
7f54e8e2e3
4 changed files with 26 additions and 10 deletions
|
@ -61,7 +61,7 @@ func Test_validate_require_namespace_quota(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_validate_disallow_node_port(t *testing.T) {
|
func Test_validate_disallow_node_port(t *testing.T) {
|
||||||
testScenario(t, "test/scenarios/samples/best_practices/scenario_validate_disallow_node_port.yaml")
|
testScenario(t, "test/scenarios/samples/best_practices/disallow_node_port.yaml")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_validate_disallow_default_serviceaccount(t *testing.T) {
|
func Test_validate_disallow_default_serviceaccount(t *testing.T) {
|
||||||
|
|
|
@ -1,20 +1,33 @@
|
||||||
apiVersion: kyverno.io/v1alpha1
|
apiVersion: kyverno.io/v1alpha1
|
||||||
kind: ClusterPolicy
|
kind: ClusterPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: disallow-host-network-port
|
name: host-network-port
|
||||||
|
annotations:
|
||||||
|
policies.kyverno.io/category: Security
|
||||||
|
policies.kyverno.io/description: Using 'hostPort' and 'hostNetwork' allows pods to share
|
||||||
|
the host network stack, allowing potential snooping of network traffic from an application pod.
|
||||||
spec:
|
spec:
|
||||||
rules:
|
rules:
|
||||||
- name: validate-host-network-port
|
- name: validate-host-network
|
||||||
match:
|
match:
|
||||||
resources:
|
resources:
|
||||||
kinds:
|
kinds:
|
||||||
- Pod
|
- Pod
|
||||||
validate:
|
validate:
|
||||||
message: "Using host networking is not allowed"
|
message: "Use of hostNetwork is not allowed"
|
||||||
|
pattern:
|
||||||
|
spec:
|
||||||
|
=(hostNetwork): false
|
||||||
|
- name: validate-host-port
|
||||||
|
match:
|
||||||
|
resources:
|
||||||
|
kinds:
|
||||||
|
- Pod
|
||||||
|
validate:
|
||||||
|
message: "Use of hostPort is not allowed"
|
||||||
pattern:
|
pattern:
|
||||||
spec:
|
spec:
|
||||||
(hostNetwork): false
|
|
||||||
containers:
|
containers:
|
||||||
- name: "*"
|
- name: "*"
|
||||||
ports:
|
=(ports):
|
||||||
- hostPort: null
|
- X(hostPort): null
|
||||||
|
|
|
@ -5,13 +5,16 @@ input:
|
||||||
expected:
|
expected:
|
||||||
validation:
|
validation:
|
||||||
policyresponse:
|
policyresponse:
|
||||||
policy: validate-host-network-hostport
|
policy: host-network-port
|
||||||
resource:
|
resource:
|
||||||
kind: Pod
|
kind: Pod
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
namespace: ''
|
namespace: ''
|
||||||
name: "nginx-host-network"
|
name: "nginx-host-network"
|
||||||
rules:
|
rules:
|
||||||
- name: validate-host-network-port
|
- name: validate-host-network
|
||||||
type: Validation
|
type: Validation
|
||||||
success: false
|
success: true
|
||||||
|
- name: validate-host-port
|
||||||
|
type: Validation
|
||||||
|
success: false
|
||||||
|
|
Loading…
Add table
Reference in a new issue