Skip to content

Commit 4761d87

Browse files
committed
fix(shield): move host response action helper to features
Signed-off-by: Roberto Scolaro <[email protected]>
1 parent cde2105 commit 4761d87

File tree

2 files changed

+8
-64
lines changed

2 files changed

+8
-64
lines changed

charts/shield/templates/host/_helpers.tpl

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,13 @@ true
231231

232232
{{/*
233233
This function checks if the response_actions feature is enabled for the host.
234-
It first checks the additional_settings and then the features.
235-
If neither is found, it defaults to false.
234+
It checks features.respond or features.responding for response_actions.
235+
If not found, it defaults to false.
236236
*/}}
237237
{{- define "host.response_actions_enabled" }}
238-
{{- $feature_respond := dig "respond" (dict) .Values.features }}
239-
{{- $additional_features := dig "features" (dict) .Values.host.additional_settings }}
240-
{{- $additional_respond := dig "respond" (dict) $additional_features }}
241-
{{- if hasKey $additional_respond "response_actions" }}
242-
{{- dig "response_actions" "enabled" false $additional_respond -}}
243-
{{- else if hasKey $feature_respond "response_actions" }}
238+
{{- $respondKey := include "host.respond_key" .Values.features }}
239+
{{- $feature_respond := dig $respondKey (dict) .Values.features }}
240+
{{- if hasKey $feature_respond "response_actions" }}
244241
{{- dig "response_actions" "enabled" false $feature_respond -}}
245242
{{- end }}
246243
{{- end }}
@@ -252,13 +249,10 @@ true
252249
*/}}
253250
{{- define "host.response_actions_needs_higher_privileges" }}
254251
{{- if eq (include "host.response_actions_enabled" .) "true" }}
255-
{{- $feature_respond := dig "respond" (dict) .Values.features }}
256-
{{- $additional_features := dig "features" (dict) .Values.host.additional_settings }}
257-
{{- $additional_respond := dig "respond" (dict) $additional_features }}
252+
{{- $respondKey := include "host.respond_key" .Values.features }}
253+
{{- $feature_respond := dig $respondKey (dict) .Values.features }}
258254
{{- $response_actions := dict }}
259-
{{- if hasKey $additional_respond "response_actions" }}
260-
{{- $response_actions = get $additional_respond "response_actions" }}
261-
{{- else if hasKey $feature_respond "response_actions" }}
255+
{{- if hasKey $feature_respond "response_actions" }}
262256
{{- $response_actions = get $feature_respond "response_actions" }}
263257
{{- end }}
264258
{{- $file_acquire_trigger := dig "file_acquire" "trigger" "all" $response_actions }}

charts/shield/tests/host/daemonset_test.yaml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -382,29 +382,6 @@ tests:
382382
- notExists:
383383
path: spec.template.spec.volumes[?(@.name == "host-tmp")]
384384

385-
- it: Host root mounted when response_actions is enabled (additional_settings)
386-
set:
387-
host:
388-
additional_settings:
389-
features:
390-
respond:
391-
response_actions:
392-
enabled: true
393-
asserts:
394-
- contains:
395-
path: spec.template.spec.volumes
396-
content:
397-
name: host-root
398-
hostPath:
399-
path: /
400-
- contains:
401-
path: spec.template.spec.containers[?(@.name == "sysdig-host-shield")].volumeMounts
402-
content:
403-
name: host-root
404-
mountPath: /host
405-
- notExists:
406-
path: spec.template.spec.volumes[?(@.name == "host-tmp")]
407-
408385
- it: Host root mounted when response_actions is enabled (features)
409386
set:
410387
features:
@@ -426,33 +403,6 @@ tests:
426403
- notExists:
427404
path: spec.template.spec.volumes[?(@.name == "host-tmp")]
428405

429-
- it: Host root mounted when response_actions is enabled (only on additional_settings)
430-
set:
431-
features:
432-
respond:
433-
response_actions:
434-
enabled: false
435-
host:
436-
additional_settings:
437-
features:
438-
respond:
439-
response_actions:
440-
enabled: true
441-
asserts:
442-
- contains:
443-
path: spec.template.spec.volumes
444-
content:
445-
name: host-root
446-
hostPath:
447-
path: /
448-
- contains:
449-
path: spec.template.spec.containers[?(@.name == "sysdig-host-shield")].volumeMounts
450-
content:
451-
name: host-root
452-
mountPath: /host
453-
- notExists:
454-
path: spec.template.spec.volumes[?(@.name == "host-tmp")]
455-
456406
- it: Host root mounted when host scanner is enabled
457407
set:
458408
features:

0 commit comments

Comments
 (0)