Skip to content

feat(shield): convert alf config to secret #2303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 1.12.2
version: 1.13.0
appVersion: "1.0.0"
5 changes: 5 additions & 0 deletions charts/shield/templates/host/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,8 @@ true
true
{{- end }}
{{- end }}

{{/* Return the name of the local forwarder secret */}}
{{- define "host.local_forwarder_secret_name" }}
{{- include "host.fullname" . | trunc 46 | trimSuffix "-" | printf "%s-local-forwarder" }}
{{- end }}
5 changes: 0 additions & 5 deletions charts/shield/templates/host/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ data:
{{- include "host.host_shield_config" . | nindent 4 }}
dragent.yaml: |
{{- include "host.configmap" . | nindent 4 }}
{{- if .Values.features.investigations.event_forwarder.enabled }}
local_forwarder_config.yaml: |
integrations:
{{- toYaml .Values.features.investigations.event_forwarder.integrations | nindent 6 }}
{{- end }}
{{- if (include "host.prometheus_enabled" .Values.features) }}
prometheus.yaml: |
{{- with .Values.features }}
Expand Down
5 changes: 2 additions & 3 deletions charts/shield/templates/host/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ spec:
{{- end }}
{{- if .Values.features.investigations.event_forwarder.enabled }}
- name: local-forwarder-config
configMap:
name: {{ include "host.fullname" . }}
optional: true
secret:
secretName: {{ include "host.local_forwarder_secret_name" . }}
{{- end }}
{{- include "host.volumes" . | nindent 8 }}
14 changes: 14 additions & 0 deletions charts/shield/templates/host/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,17 @@ type: Opaque
data:
password: {{ (include "host.rapid_response_password" .) | b64enc | quote }}
{{- end }}

{{- if .Values.features.investigations.event_forwarder.enabled }}
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: {{ include "host.local_forwarder_secret_name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "host.labels" . | nindent 4 }}
data:
local_forwarder_config.yaml: {{ pick .Values.features.investigations.event_forwarder "integrations" | toYaml | b64enc | quote }}
{{- end }}
26 changes: 26 additions & 0 deletions charts/shield/tests/host/configmap-host-shield-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,29 @@ tests:
in_use:
enabled: false
integration_enabled: false

- it: Ensure Local Forwarder
set:
features:
investigations:
event_forwarder:
enabled: true
integrations:
- channels:
- SECURE_EVENTS_POLICIES
- ACTIVITY_AUDIT
configuration:
output: stdout
type: LOCAL
transmit_message_types:
- POLICY_EVENTS
- SECURE_AUDIT
asserts:
- matchRegex:
path: data['dragent.yaml']
pattern: |
local_forwarder:
enabled: true
transmit_message_types:
- POLICY_EVENTS
- SECURE_AUDIT
61 changes: 0 additions & 61 deletions charts/shield/tests/host/configmap-local-forwarder_test.yaml

This file was deleted.

41 changes: 41 additions & 0 deletions charts/shield/tests/host/daemonset_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -737,3 +737,44 @@ tests:
- equal:
path: spec.template.spec.dnsPolicy
value: ClusterFirst

- it: No Local Forwarder items if not enabled
asserts:
- notExists:
path: spec.template.spec.volumes[?(@.name == "local-forwarder-config")]
template: host/daemonset.yaml
- notExists:
path: spec.template.spec.containers[0].volumeMounts[?(@.name == "local-forwarder-config")]
template: host/daemonset.yaml

- it: Local Forwarder Configured as needed
set:
features:
investigations:
event_forwarder:
enabled: true
transmit_message_types:
- POLICY_EVENTS
- SECURE_AUDIT
integrations:
- channels:
- SECURE_EVENTS_POLICIES
- ACTIVITY_AUDIT
configuration:
output: stdout
type: LOCAL
asserts:
- contains:
path: spec.template.spec.volumes
content:
name: local-forwarder-config
secret:
secretName: release-name-shield-host-local-forwarder
template: host/daemonset.yaml
- contains:
path: spec.template.spec.containers[0].volumeMounts
content:
name: local-forwarder-config
mountPath: /opt/draios/etc/local_forwarder_config.yaml
subPath: local_forwarder_config.yaml
template: host/daemonset.yaml
37 changes: 37 additions & 0 deletions charts/shield/tests/host/secrets_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,40 @@ tests:
path: data.password
decodeBase64: true
value: "abc123"

- it: Test Local Forwarder secret is not created when disabled
asserts:
- containsDocument:
kind: Secret
apiVersion: v1
name: release-name-shield-host-local-forwarder
namespace: shield-namespace
not: true
template: host/secrets.yaml

- it: Test Local Forwarder secret is created when enabled
set:
features:
investigations:
event_forwarder:
enabled: true
integrations:
- channels:
- SECURE_EVENTS_POLICIES
- ACTIVITY_AUDIT
configuration:
output: stdout
type: LOCAL
asserts:
- containsDocument:
kind: Secret
apiVersion: v1
name: release-name-shield-host-local-forwarder
namespace: shield-namespace
- exists:
path: data["local_forwarder_config.yaml"]
template: host/secrets.yaml
- matchRegex:
path: data["local_forwarder_config.yaml"]
pattern: aW50ZWdyYXRpb25zOgotIGNoYW5uZWxzOgogIC0gU0VDVVJFX0VWRU5UU19QT0xJQ0lFUwogIC0gQUNUSVZJVFlfQVVESVQKICBjb25maWd1cmF0aW9uOgogICAgb3V0cHV0OiBzdGRvdXQKICB0eXBlOiBMT0NBTA==
template: host/secrets.yaml
Loading