Pod level testing (#546)

* update runAsPrivileged to test at pod level

* update runAsPrivileged to test at pod level

* add pod level success/failure tests

* add insuecure capabilities pod level testing

* update checks to include good/bad security

* update checks for good/bad security

* remove good security from runAsPrivileged
This commit is contained in:
Cydnee Owens
2021-05-25 12:59:28 -04:00
committed by GitHub
parent 68d295ec6b
commit cbc15ad069
13 changed files with 199 additions and 12 deletions
+1 -2
View File
@@ -53,5 +53,4 @@ schema:
- contains:
const: KILL
- contains:
const: AUDIT_WRITE
const: AUDIT_WRITE
+34 -7
View File
@@ -2,15 +2,42 @@ successMessage: Privilege escalation not allowed
failureMessage: Privilege escalation should not be allowed
category: Security
target: Container
schemaTarget: Pod
schema:
'$schema': http://json-schema.org/draft-07/schema
type: object
required:
- securityContext
properties:
securityContext:
required:
- allowPrivilegeEscalation
definitions:
goodSecurityContext:
type: object
anyOf:
- required:
- allowPrivilegeEscalation
properties:
allowPrivilegeEscalation:
const: false
notBadSecurityContext:
type: object
properties:
allowPrivilegeEscalation:
const: false
type: object
anyOf:
- required:
- securityContext
properties:
securityContext:
$ref: "#/definitions/goodSecurityContext"
containers:
type: array
items:
properties:
securityContext:
$ref: "#/definitions/notBadSecurityContext"
- properties:
containers:
type: array
items:
required:
- securityContext
properties:
securityContext:
$ref: "#/definitions/goodSecurityContext"
+14 -3
View File
@@ -2,12 +2,23 @@ successMessage: Not running as privileged
failureMessage: Should not be running as privileged
category: Security
target: Container
schemaTarget: Pod
schema:
'$schema': http://json-schema.org/draft-07/schema
type: object
properties:
securityContext:
definitions:
notBadSecurityContext:
type: object
properties:
privileged:
not:
const: true
type: object
properties:
securityContext:
$ref: "#/definitions/notBadSecurityContext"
containers:
type: array
items:
properties:
securityContext:
$ref: "#/definitions/notBadSecurityContext"
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
capabilities:
drop:
- ALL
containers:
- name: nginx
image: nginx
@@ -0,0 +1,31 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
capabilities:
drop:
containers:
- name: nginx
image: nginx
securityContext:
capabilities:
drop:
- NET_ADMIN
- CHOWN
- DAC_OVERRIDE
- FSETID
- FOWNER
- MKNOD
- NET_RAW
- SETGID
- SETUID
- SETFCAP
- SETPCAP
- NET_BIND_SERVICE
- SYS_CHROOT
- KILL
- AUDIT_WRITE
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
allowPrivilegeEscalation: false
containers:
- name: nginx
image: nginx
securityContext:
allowPrivilegeEscalation: true
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
allowPrivilegeEscalation: false
containers:
- name: nginx
image: nginx
securityContext:
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
allowPrivilegeEscalation: true
containers:
- name: nginx
image: nginx
securityContext:
allowPrivilegeEscalation: false
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
privileged: false
containers:
- securityContext:
privileged: true
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
privileged: false
containers:
- securityContext:
privileged: true
- securityContext:
privileged: false
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
privileged: false
containers:
- securityContext:
privileged: true
- securityContext:
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
privileged: true
containers:
- securityContext:
privileged: false
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
securityContext:
privileged: false
containers:
- securityContext: