-
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.
Merge pull request #177 from nirmata/anudeep-remediation-yamls
Anudeep remediation yamls
- Loading branch information
Showing
15 changed files
with
448 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
pod-security/baseline/disallow-capabilities/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,25 @@ | ||
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: | ||
capabilities: | ||
add: | ||
- SYS_ADMIN | ||
- NET_RAW |
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
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/baseline/disallow-capabilities/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-disallow-capabilities | ||
spec: | ||
validationFailureAction: Audit | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
139 changes: 139 additions & 0 deletions
139
pod-security/baseline/disallow-capabilities/remediate-disallow-capabilities.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,139 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-disallow-capabilities | ||
annotations: | ||
policies.kyverno.io/title: Remediate Capabilities Baseline | ||
policies.kyverno.io/category: Pod Security Standards (Baseline) | ||
policies.kyverno.io/description: >- | ||
This policy remediates the disallow-capabilities baseline policy by automatically removing any unpermitted capabilities. | ||
spec: | ||
background: false | ||
rules: | ||
- name: remove-unpermitted-capabilities | ||
match: | ||
resources: | ||
kinds: | ||
- Deployment | ||
- StatefulSet | ||
- Job | ||
- DaemonSet | ||
mutate: | ||
foreach: | ||
- list: request.object.spec.template.spec.containers[] | ||
order: Descending | ||
preconditions: | ||
all: | ||
- key: "{{ element.securityContext.capabilities.add[].to_upper(@) || `[]` }}" | ||
operator: AnyNotIn | ||
value: | ||
- AUDIT_WRITE | ||
- CHOWN | ||
- DAC_OVERRIDE | ||
- FOWNER | ||
- FSETID | ||
- KILL | ||
- MKNOD | ||
- NET_BIND_SERVICE | ||
- SETFCAP | ||
- SETGID | ||
- SETPCAP | ||
- SETUID | ||
- SYS_CHROOT | ||
patchesJson6902: |- | ||
- op: remove | ||
path: /spec/template/spec/containers/{{elementIndex}}/securityContext/capabilities/add | ||
- op: add | ||
path: /spec/template/spec/containers/{{elementIndex}}/securityContext/capabilities/add | ||
value: | ||
- AUDIT_WRITE | ||
- CHOWN | ||
- DAC_OVERRIDE | ||
- FOWNER | ||
- FSETID | ||
- KILL | ||
- MKNOD | ||
- NET_BIND_SERVICE | ||
- SETFCAP | ||
- SETGID | ||
- SETPCAP | ||
- SETUID | ||
- SYS_CHROOT | ||
- list: request.object.spec.template.spec.initContainers[] | ||
order: Descending | ||
preconditions: | ||
all: | ||
- key: "{{ element.securityContext.capabilities.add[].to_upper(@) || `[]` }}" | ||
operator: AnyNotIn | ||
value: | ||
- AUDIT_WRITE | ||
- CHOWN | ||
- DAC_OVERRIDE | ||
- FOWNER | ||
- FSETID | ||
- KILL | ||
- MKNOD | ||
- NET_BIND_SERVICE | ||
- SETFCAP | ||
- SETGID | ||
- SETPCAP | ||
- SETUID | ||
- SYS_CHROOT | ||
patchesJson6902: |- | ||
- op: remove | ||
path: /spec/template/spec/initContainers/{{elementIndex}}/securityContext/capabilities/add | ||
- op: add | ||
path: /spec/template/spec/initContainers/{{elementIndex}}/securityContext/capabilities/add | ||
value: | ||
- AUDIT_WRITE | ||
- CHOWN | ||
- DAC_OVERRIDE | ||
- FOWNER | ||
- FSETID | ||
- KILL | ||
- MKNOD | ||
- NET_BIND_SERVICE | ||
- SETFCAP | ||
- SETGID | ||
- SETPCAP | ||
- SETUID | ||
- SYS_CHROOT | ||
- list: request.object.spec.template.spec.ephemeralContainers[] | ||
order: Descending | ||
preconditions: | ||
all: | ||
- key: "{{ element.securityContext.capabilities.add[].to_upper(@) || `[]` }}" | ||
operator: AnyNotIn | ||
value: | ||
- AUDIT_WRITE | ||
- CHOWN | ||
- DAC_OVERRIDE | ||
- FOWNER | ||
- FSETID | ||
- KILL | ||
- MKNOD | ||
- NET_BIND_SERVICE | ||
- SETFCAP | ||
- SETGID | ||
- SETPCAP | ||
- SETUID | ||
- SYS_CHROOT | ||
patchesJson6902: |- | ||
- op: remove | ||
path: /spec/template/spec/ephemeralContainers/{{elementIndex}}/securityContext/capabilities/add | ||
- op: add | ||
path: /spec/template/spec/ephemeralContainers/{{elementIndex}}/securityContext/capabilities/add | ||
value: | ||
- AUDIT_WRITE | ||
- CHOWN | ||
- DAC_OVERRIDE | ||
- FOWNER | ||
- FSETID | ||
- KILL | ||
- MKNOD | ||
- NET_BIND_SERVICE | ||
- SETFCAP | ||
- SETGID | ||
- SETPCAP | ||
- SETUID | ||
- SYS_CHROOT |
24 changes: 24 additions & 0 deletions
24
pod-security/restricted/require-run-as-non-root-user/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,24 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: baddeployment02 | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: app | ||
template: | ||
metadata: | ||
labels: | ||
app: app | ||
spec: | ||
securityContext: | ||
runAsUser: 0 | ||
containers: | ||
- name: container01 | ||
image: busybox | ||
command: | ||
- "sleep" | ||
- "3600" | ||
securityContext: | ||
runAsUser: 0 |
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/require-run-as-non-root-user/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-require-run-as-non-root-user | ||
spec: | ||
validationFailureAction: Audit | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
53 changes: 53 additions & 0 deletions
53
...urity/restricted/require-run-as-non-root-user/remediate-require-run-as-non-root-user.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,53 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-require-run-as-non-root-user | ||
annotations: | ||
policies.kyverno.io/title: Require Run As Non-Root User | ||
policies.kyverno.io/category: Pod Security Standards (Restricted) | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Pod | ||
kyverno.io/kyverno-version: 1.6.0 | ||
kyverno.io/kubernetes-version: "1.22-1.23" | ||
policies.kyverno.io/description: >- | ||
Containers must be required to run as non-root users. This policy mutates the field | ||
spec.securityContext.runAsUser to a value greater than zero, | ||
and the fields spec.containers[*].securityContext.runAsUser, | ||
spec.initContainers[*].securityContext.runAsUser, and spec.ephemeralContainers[*].securityContext.runAsUser | ||
if exists, is set to a non-zero value. | ||
spec: | ||
background: false | ||
rules: | ||
- name: add-run-as-non-root-user | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Deployment | ||
- StatefulSet | ||
- Job | ||
- DaemonSet | ||
mutate: | ||
foreach: | ||
- list: "request.object.spec.template.spec.[containers, initContainers, ephemeralContainers][]" | ||
patchStrategicMerge: | ||
spec: | ||
template: | ||
spec: | ||
securityContext: | ||
runAsUser: 1000 | ||
containers: | ||
- (name): "{{ element.name }}" | ||
securityContext: | ||
(runAsUser): 0 | ||
runAsUser: 1000 | ||
initContainers: | ||
- (name): "{{ element.name }}" | ||
securityContext: | ||
(runAsUser): 0 | ||
runAsUser: 1000 | ||
ephemeralContainers: | ||
- (name): "{{ element.name }}" | ||
securityContext: | ||
(runAsUser): 0 | ||
runAsUser: 1000 |
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
Oops, something went wrong.