-
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 #169 from Chandan-DK/remediate-policies-for-rbac-b…
…est-practices NDEV-20544: add remediate policies for RBAC best practices
- Loading branch information
Showing
10 changed files
with
154 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
11 changes: 11 additions & 0 deletions
11
rbac-best-practices/restrict-automount-sa-token/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-automount-sa-token | ||
spec: | ||
validationFailureAction: Audit | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
28 changes: 28 additions & 0 deletions
28
rbac-best-practices/restrict-automount-sa-token/remediate-restrict-automount-sa-token.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,28 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-restrict-automount-sa-token | ||
annotations: | ||
policies.kyverno.io/title: Remediate Restrict Auto-Mount of Service Account Tokens | ||
policies.kyverno.io/category: RBAC Best Practices | ||
policies.kyverno.io/description: >- | ||
This policy remediates the restrict-automount-sa-token violation | ||
spec: | ||
background: false | ||
rules: | ||
- name: remediate-restrict-automount-sa-token | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
preconditions: | ||
all: | ||
- key: "{{ request.\"object\".metadata.labels.\"app.kubernetes.io/part-of\" || '' }}" | ||
operator: NotEquals | ||
value: policy-reporter | ||
mutate: | ||
patchStrategicMerge: | ||
spec: | ||
automountServiceAccountToken: false | ||
|
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
9 changes: 9 additions & 0 deletions
9
rbac-best-practices/restrict-clusterrole-nodesproxy/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,9 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-restrict-clusterrole-nodesproxy | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
34 changes: 34 additions & 0 deletions
34
...-practices/restrict-clusterrole-nodesproxy/remediate-restrict-clusterrole-nodesproxy.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,34 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-restrict-clusterrole-nodesproxy | ||
annotations: | ||
policies.kyverno.io/title: Remediate Restrict ClusterRole with Nodes Proxy | ||
policies.kyverno.io/category: RBAC Best Practices | ||
policies.kyverno.io/description: >- | ||
This policy remediates the restrict-clusterrole-nodesproxy violation | ||
spec: | ||
background: false | ||
rules: | ||
- name: remediate-restrict-clusterrole-nodesproxy | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- ClusterRole | ||
mutate: | ||
foreach: | ||
- list: request.object.rules[] | ||
foreach: | ||
- list: element.resources | ||
preconditions: | ||
all: | ||
- key: "{{element}}" | ||
operator: Equals | ||
value: "nodes/proxy" | ||
patchesJson6902: |- | ||
- path: /rules/{{elementIndex0}}/resources/{{elementIndex1}} | ||
op: replace | ||
value: "" | ||
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
9 changes: 9 additions & 0 deletions
9
rbac-best-practices/restrict-wildcard-resources/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,9 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-restrict-wildcard-resources | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |
33 changes: 33 additions & 0 deletions
33
rbac-best-practices/restrict-wildcard-resources/remediate-restrict-wildcard-resources.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,33 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: remediate-restrict-wildcard-resources | ||
annotations: | ||
policies.kyverno.io/title: Remediate Restrict Wildcard in Resources | ||
policies.kyverno.io/category: RBAC Best Practices | ||
policies.kyverno.io/description: >- | ||
This policy remediates the restrict-wildcard-resources violation | ||
spec: | ||
background: false | ||
rules: | ||
- name: remediate-restrict-wildcard-resources | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Role | ||
- ClusterRole | ||
mutate: | ||
foreach: | ||
- list: request.object.rules[] | ||
foreach: | ||
- list: element.resources | ||
preconditions: | ||
all: | ||
- key: "*" | ||
operator: Equals | ||
value: "{{element}}" | ||
patchesJson6902: |- | ||
- path: /rules/{{elementIndex0}}/resources/{{elementIndex1}} | ||
op: replace | ||
value: "" |