Skip to content

Commit 1e85387

Browse files
committed
made securitycontext and other settings generic
1 parent 8e9e68c commit 1e85387

File tree

4 files changed

+87
-18
lines changed

4 files changed

+87
-18
lines changed

.circleci/tests/golden/wiz-outpost-lite/remediation.golden.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ spec:
7979
app.kubernetes.io/instance: release-test
8080
wiz.io/runner: "remediation-aws-rds-003"
8181
spec:
82+
securityContext:
83+
fsGroup: 1000
84+
runAsGroup: 1000
85+
runAsNonRoot: true
86+
runAsUser: 1000
8287
serviceAccountName: sa-remediation-aws-rds-003
8388
restartPolicy: Always
8489
containers:
@@ -169,11 +174,17 @@ spec:
169174
requests:
170175
memory: 1024M
171176
securityContext:
177+
allowPrivilegeEscalation: false
172178
capabilities:
173-
add:
174-
- SYS_ADMIN
179+
drop:
180+
- ALL
181+
privileged: false
182+
readOnlyRootFilesystem: true
183+
runAsGroup: 1000
184+
runAsNonRoot: true
185+
runAsUser: 1000
175186
seLinuxOptions:
176-
type: spc_t
187+
type: container_t
177188
volumeMounts:
178189
- mountPath: /var/wiz
179190
name: working-dir

wiz-outpost-lite/templates/_helpers.tpl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,24 @@ container-registry -> outpost-lite-runner-container-registry
8686

8787
{{ $runnerValues | toJson }}
8888
{{- end }} {{/* define */}}
89+
90+
{{/*
91+
Get security context for a runner
92+
*/}}
93+
{{- define "wiz-outpost-lite.getSecurityContext" -}}
94+
{{- $runner := .runner }}
95+
{{- $values := .Values }}
96+
{{- $baseProfile := "standard" }}
97+
{{- if hasPrefix "remediation" $runner }}
98+
{{- $baseProfile = "secure" }}
99+
{{- end }}
100+
{{- $baseSecurityContext := get $values.securityContextProfiles $baseProfile }}
101+
{{- $runnerSecurityContext := get $values "securityContext" }}
102+
{{- if $runnerSecurityContext }}
103+
{{- $mergedPod := merge $runnerSecurityContext.pod $baseSecurityContext.pod }}
104+
{{- $mergedContainer := merge $runnerSecurityContext.container $baseSecurityContext.container }}
105+
{{- dict "pod" $mergedPod "container" $mergedContainer | toYaml }}
106+
{{- else }}
107+
{{- $baseSecurityContext | toYaml }}
108+
{{- end }}
109+
{{- end }}

wiz-outpost-lite/templates/deployment.yaml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ spec:
2525
{{- toYaml . | nindent 8 }}
2626
{{- end }}
2727
spec:
28+
{{- with (fromYaml (include "wiz-outpost-lite.getSecurityContext" .)).pod }}
2829
securityContext:
29-
runAsNonRoot: true
30-
runAsUser: 1000
31-
runAsGroup: 1000
32-
fsGroup: 1000
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
3332
{{- if .Values.serviceAccount.create }}
3433
serviceAccountName: sa-{{ .runner }}
3534
{{- end }}
@@ -147,18 +146,10 @@ spec:
147146
{{- end }}
148147
resources:
149148
{{- toYaml .Values.resources | nindent 12 }}
149+
{{- with (fromYaml (include "wiz-outpost-lite.getSecurityContext" .)).container }}
150150
securityContext:
151-
capabilities:
152-
drop:
153-
- ALL
154-
runAsNonRoot: true
155-
runAsUser: 1000
156-
runAsGroup: 1000
157-
allowPrivilegeEscalation: false
158-
privileged: false
159-
readOnlyRootFilesystem: true
160-
seLinuxOptions:
161-
type: container_t
151+
{{- toYaml . | nindent 12 }}
152+
{{- end }}
162153
volumeMounts:
163154
- mountPath: /var/wiz
164155
name: working-dir

wiz-outpost-lite/values.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,52 @@ terminationGracePeriodSeconds: 30
7474
serviceAccount:
7575
create: false
7676

77+
securityContextProfiles:
78+
secure: # Applied automatically to remediation-* runners
79+
pod:
80+
runAsNonRoot: true
81+
runAsUser: 1000
82+
runAsGroup: 1000
83+
fsGroup: 1000
84+
container:
85+
capabilities:
86+
drop:
87+
- ALL
88+
runAsNonRoot: true
89+
runAsUser: 1000
90+
runAsGroup: 1000
91+
allowPrivilegeEscalation: false
92+
privileged: false
93+
readOnlyRootFilesystem: true
94+
seLinuxOptions:
95+
type: container_t
96+
standard: # Applied automatically to non-remediation runners
97+
container:
98+
capabilities:
99+
add:
100+
- SYS_ADMIN
101+
seLinuxOptions:
102+
type: spc_t
103+
104+
77105
runners:
106+
# Example of a remediation runner with custom security settings
107+
# remediation-aws-123:
108+
# enabled: false
109+
# securityContext: # Override specific settings
110+
# container:
111+
# capabilities:
112+
# add: ["SYS_ADMIN"]
113+
# seLinuxOptions:
114+
# type: spc_t
115+
116+
# # Example of a standard runner (uses standard security profile by default)
117+
# container-registry:
118+
# enabled: false
119+
# securityContext: # Optional overrides
120+
# container:
121+
# readOnlyRootFilesystem: true # Add additional security
122+
78123
container-registry:
79124
enabled: false
80125
vcs-scheduled:
@@ -87,3 +132,4 @@ runners:
87132
name: outpost-lite-runner-vcs
88133
concurrency: 4
89134
terminationGracePeriodSeconds: 300 # 5 minutes
135+

0 commit comments

Comments
 (0)