Skip to content

Commit

Permalink
feat(shield): [SMAGENT-8138] add full securityContext to host-shield …
Browse files Browse the repository at this point in the history
…chart

Update the host-shield chart so to include a full securityContext.
This is the equivalent of #2102.
  • Loading branch information
iurly committed Jan 15, 2025
1 parent 46850fe commit 6ac5bfd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/shield/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ maintainers:
- name: mavimo
email: [email protected]
type: application
version: 0.6.1
version: 0.6.2
appVersion: "1.0.0"
4 changes: 4 additions & 0 deletions charts/shield/templates/host/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,12 @@ true
privileged: true
runAsNonRoot: false
runAsUser: 0
runAsGroup: 0
readOnlyRootFilesystem: false
allowPrivilegeEscalation: true
capabilities:
drop:
- ALL
{{- else }}
allowPrivilegeEscalation: false
seccompProfile:
Expand Down
4 changes: 4 additions & 0 deletions charts/shield/templates/host/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ spec:
securityContext:
privileged: true
runAsNonRoot: false
runAsGroup: 0
runAsUser: 0
readOnlyRootFilesystem: false
allowPrivilegeEscalation: true
capabilities:
drop:
- ALL
resources:
{{- (include "host.kmodule_resources" .) | nindent 12 }}
env:
Expand Down
35 changes: 35 additions & 0 deletions charts/shield/tests/host/security_context_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ tests:
readOnlyRootFilesystem: false
runAsNonRoot: false
runAsUser: 0
runAsGroup: 0
capabilities:
drop:
- ALL

- it: Ensure the securityContext for a non-privileged agent contains the keys defined
set:
Expand Down Expand Up @@ -126,3 +130,34 @@ tests:
- SYS_TIME
- SYS_TTY_CONFIG
- WAKE_ALARM
- it: Ensure the securityContext contains the mandatory keys
asserts:
- isSubset:
path: spec.template.spec['initContainers','containers'][:].securityContext.capabilities
content:
drop:
- ALL
- exists:
path: spec.template.spec.initContainers[:].securityContext.runAsNonRoot
- exists:
path: spec.template.spec.containers[:].securityContext.runAsNonRoot
- exists:
path: spec.template.spec.initContainers[:].securityContext.runAsUser
- exists:
path: spec.template.spec.containers[:].securityContext.runAsUser
- exists:
path: spec.template.spec.initContainers[:].securityContext.runAsGroup
- exists:
path: spec.template.spec.containers[:].securityContext.runAsGroup
- exists:
path: spec.template.spec.initContainers[:].securityContext.privileged
- exists:
path: spec.template.spec.containers[:].securityContext.privileged
- exists:
path: spec.template.spec.initContainers[:].securityContext.allowPrivilegeEscalation
- exists:
path: spec.template.spec.containers[:].securityContext.allowPrivilegeEscalation
- exists:
path: spec.template.spec.initContainers[:].securityContext.readOnlyRootFilesystem
- exists:
path: spec.template.spec.containers[:].securityContext.readOnlyRootFilesystem

0 comments on commit 6ac5bfd

Please sign in to comment.