-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified chainsawtests for restrict-seccomp-strict, added remediation…
… yaml for restrict-seccomp-strict and added remediation annotations yamls for disallow-capabilities and require-run-as-non-root-user Signed-off-by: anuddeeph1 <[email protected]>
- Loading branch information
1 parent
245f524
commit e1c7e03
Showing
6 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
pod-security/restricted/restrict-seccomp-strict/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: baddeployment | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: app | ||
template: | ||
metadata: | ||
labels: | ||
app: app | ||
spec: | ||
containers: | ||
- name: container01 | ||
image: busybox | ||
command: | ||
- "sleep" | ||
- "3600" | ||
securityContext: | ||
seccompProfile: | ||
type: Unconfined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
pod-security/restricted/restrict-seccomp-strict/e2e/remediation-policy-assert.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-restrict-seccomp-strict | ||
spec: | ||
validationFailureAction: Audit | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
88 changes: 88 additions & 0 deletions
88
pod-security/restricted/restrict-seccomp-strict/remediate-restrict-seccomp-strict.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-restrict-seccomp-strict | ||
annotations: | ||
annotations: | ||
policies.kyverno.io/title: Restrict Seccomp (Strict) | ||
policies.kyverno.io/category: Pod Security Standards (Restricted) | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Pod | ||
kyverno.io/kubernetes-version: "1.22-1.23" | ||
policies.nirmata.io/remediation-docs: "https://docs.nirmata.io/policysets/podsecurity/restricted/restrict-seccomp-strict/" | ||
policies.kyverno.io/description: >- | ||
The seccomp profile in the Restricted group must not be explicitly set to Unconfined | ||
but additionally must also not allow an unset value. This policy, | ||
requiring Kubernetes v1.19 or later, ensures that the fields | ||
spec.securityContext.seccompProfile.type, | ||
spec.containers[*].securityContext.seccompProfile.type, | ||
spec.initContainers[*].securityContext.seccompProfile.type, and | ||
spec.ephemeralContainers[*].securityContext.seccompProfile.type | ||
is set to `RuntimeDefault` or `Localhost`. A known issue prevents a policy such as this | ||
using `anyPattern` from being persisted properly in Kubernetes 1.23.0-1.23.2. | ||
spec: | ||
background: false | ||
rules: | ||
- name: add-seccomp-runtimedefault-containers | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Deployment | ||
- StatefulSet | ||
- Job | ||
- DaemonSet | ||
mutate: | ||
foreach: | ||
- list: "request.object.spec.template.spec.[containers, initContainers, ephemeralContainers][]" | ||
order: Descending | ||
preconditions: | ||
all: | ||
- key: "{{ element.securityContext.seccompProfile.type || '' }}" | ||
operator: AnyIn | ||
value: "Unconfined" | ||
patchStrategicMerge: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- (name): "{{ element.name }}" | ||
securityContext: | ||
seccompProfile: | ||
(type): "Unconfined" | ||
type: "RuntimeDefault" | ||
initContainers: | ||
- (name): "{{ element.name }}" | ||
securityContext: | ||
seccompProfile: | ||
(type): "Unconfined" | ||
type: "RuntimeDefault" | ||
ephemeralContainers: | ||
- (name): "{{ element.name }}" | ||
securityContext: | ||
seccompProfile: | ||
(type): "Unconfined" | ||
type: "RuntimeDefault" | ||
- name: add-seccomp-runtimedefault-pod | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Deployment | ||
- StatefulSet | ||
- Job | ||
- DaemonSet | ||
preconditions: | ||
all: | ||
- key: "{{ request.object.spec.template.spec.securityContext.seccompProfile.type || '' }}" | ||
operator: Equals | ||
value: Unconfined | ||
mutate: | ||
patchStrategicMerge: | ||
spec: | ||
template: | ||
spec: | ||
securityContext: | ||
seccompProfile: | ||
(type): "Unconfined" | ||
type: "RuntimeDefault" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters