Skip to content

Commit fee290a

Browse files
[PROF-15238] Seccomp toggle for Host Profiler (#2755)
add new host profiler setting to toggle off seccomp initcontainer and enablement on host profiler align the seccomp enabled test on the disabled; explicitly check for volume seccomp should be unconfined if not enabled chore: update charts - bump version for datadog to 3.231.0 (minor-version) - update changelog for datadog with version 3.231.0 - update readme for datadog chore: update charts - update readme for datadog chore: update charts - update readme for datadog chore: update charts - update readme for datadog chore: update charts - update readme for datadog Co-authored-by: dd-octo-sts[bot] <200755185+dd-octo-sts[bot]@users.noreply.github.com> Co-authored-by: theo.demagalhaes <theo.demagalhaes@datadoghq.com>
1 parent 7782aba commit fee290a

10 files changed

Lines changed: 84 additions & 7 deletions

File tree

charts/datadog/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Datadog changelog
22

3+
## 3.231.0
4+
5+
* [PROF-15238] Seccomp toggle for Host Profiler ([#2755](https://github.com/DataDog/helm-charts/pull/2755)).
6+
37
## 3.230.1
48

59
* Update `fips.image.tag` to `1.1.28` fixing CVEs and updating packages.

charts/datadog/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
apiVersion: v1
33
name: datadog
4-
version: 3.230.1
4+
version: 3.231.0
55
appVersion: "7"
66
description: Datadog Agent
77
keywords:

charts/datadog/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Datadog
22

3-
![Version: 3.230.1](https://img.shields.io/badge/Version-3.230.1-informational?style=flat-square) ![AppVersion: 7](https://img.shields.io/badge/AppVersion-7-informational?style=flat-square)
3+
![Version: 3.231.0](https://img.shields.io/badge/Version-3.231.0-informational?style=flat-square) ![AppVersion: 7](https://img.shields.io/badge/AppVersion-7-informational?style=flat-square)
44

55
> [!WARNING]
66
> The Datadog Operator is now enabled by default since version [3.157.0](https://github.com/DataDog/helm-charts/blob/main/charts/datadog/CHANGELOG.md#31570) to collect chart metadata for display in [Fleet Automation](https://docs.datadoghq.com/agent/fleet_automation/). We are aware of issues affecting some environments and are actively working on fixes. We apologize for the inconvenience and appreciate your patience while we address these issues.
@@ -852,6 +852,8 @@ helm install <RELEASE_NAME> \
852852
| datadog.hostProfiler.enabled | bool | `false` | Enable the Host Profiler. This feature is experimental and subject to change. |
853853
| datadog.hostProfiler.image | string | `""` | Image the Host Profiler. This parameter is experimental and will be removed once official image is available. |
854854
| datadog.hostProfiler.imagePullPolicy | string | `""` | Pull policy for the Host Profiler image. Defaults to agents.image.pullPolicy when unset. |
855+
| datadog.hostProfiler.seccomp | object | `{"enabled":true}` | Seccomp profile configuration for the Host Profiler |
856+
| datadog.hostProfiler.seccomp.enabled | bool | `true` | Apply the localhost seccomp profile to the host-profiler container and run the init container that installs it on the node. Disable to run the host-profiler container Unconfined (no init container, no profile installed on the node). |
855857
| datadog.hostProfiler.seccompRoot | string | `"/var/lib/kubelet/seccomp"` | Specify the seccomp profile root directory |
856858
| datadog.hostVolumeMountPropagation | string | `"None"` | Allow to specify the `mountPropagation` value on all volumeMounts using HostPath |
857859
| datadog.ignoreAutoConfig | list | `[]` | List of integration to ignore auto_conf.yaml. |

charts/datadog/templates/_container-host-profiler.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
command:
1010
- "host-profiler"
1111
- "--core-config={{ template "datadog.confPath" . }}/datadog.yaml"
12-
{{ include "generate-security-context" (dict "securityContext" .Values.agents.containers.hostProfiler.securityContext "targetSystem" .Values.targetSystem "seccomp" (printf "localhost/%s" (include "host-profiler-seccomp-name" .)) "kubeversion" .Capabilities.KubeVersion.Version "apparmor" (and .Values.agents.podSecurity.apparmor.enabled .Values.datadog.hostProfiler.apparmor)) | nindent 2 }}
12+
{{ include "generate-security-context" (dict "securityContext" .Values.agents.containers.hostProfiler.securityContext "targetSystem" .Values.targetSystem "seccomp" (include "host-profiler-seccomp-profile" .) "kubeversion" .Capabilities.KubeVersion.Version "apparmor" (and .Values.agents.podSecurity.apparmor.enabled .Values.datadog.hostProfiler.apparmor)) | nindent 2 }}
1313
resources:
1414
{{ toYaml .Values.agents.containers.hostProfiler.resources | indent 4 }}
1515
{{- if or .Values.datadog.envFrom .Values.agents.containers.hostProfiler.envFrom }}

charts/datadog/templates/_daemonset-volumes-linux.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
type: DirectoryOrCreate
7777
name: apmsocket
7878
{{- end }}
79-
{{- if eq (include "should-enable-host-profiler" .) "true" }}
79+
{{- if eq (include "should-enable-host-profiler-seccomp" .) "true" }}
8080
- hostPath:
8181
path: {{ .Values.datadog.hostProfiler.seccompRoot }}
8282
name: host-profiler-seccomp-root

charts/datadog/templates/_helpers.tpl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,32 @@ false
270270
{{- end -}}
271271
{{- end -}}
272272

273+
{{/*
274+
Return true if the host-profiler seccomp profile (and its setup init container) should be
275+
applied. Requires the host-profiler to be enabled and the seccomp toggle to not be disabled
276+
(defaults to enabled).
277+
*/}}
278+
{{- define "should-enable-host-profiler-seccomp" -}}
279+
{{- if and (eq (include "should-enable-host-profiler" .) "true") (ne (toString .Values.datadog.hostProfiler.seccomp.enabled) "false") -}}
280+
true
281+
{{- else -}}
282+
false
283+
{{- end -}}
284+
{{- end -}}
285+
286+
{{/*
287+
Return the seccomp profile to apply to the host-profiler container: the hashed localhost
288+
profile when seccomp is enabled, otherwise "unconfined" so the container runs without a
289+
seccomp profile.
290+
*/}}
291+
{{- define "host-profiler-seccomp-profile" -}}
292+
{{- if eq (include "should-enable-host-profiler-seccomp" .) "true" -}}
293+
localhost/{{ include "host-profiler-seccomp-name" . }}
294+
{{- else -}}
295+
unconfined
296+
{{- end -}}
297+
{{- end -}}
298+
273299
{{/*
274300
Return the seccomp profile filename for the host-profiler, scoped to the image ref
275301
to avoid races when multiple host-profiler versions coexist on the same node.

charts/datadog/templates/agent-scc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ seLinuxContext:
2929
# system-probe requires some specific seccomp and capabilities
3030
seccompProfiles:
3131
{{ toYaml .Values.agents.podSecurity.seccompProfiles | indent 2 }}
32-
{{- if eq (include "should-enable-host-profiler" .) "true" }}
32+
{{- if eq (include "should-enable-host-profiler-seccomp" .) "true" }}
3333
- "localhost/{{ include "host-profiler-seccomp-name" . }}"
3434
{{- end }}
3535
allowedCapabilities:

charts/datadog/templates/daemonset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ spec:
182182
{{- if eq .Values.targetSystem "linux" }}
183183
{{- include "containers-init-linux" . | nindent 6 -}}
184184
{{- end }}
185-
{{- if eq (include "should-enable-host-profiler" .) "true" }}
185+
{{- if eq (include "should-enable-host-profiler-seccomp" .) "true" }}
186186
{{ include "host-profiler-seccomp-init" . | nindent 6 }}
187187
{{- end }}
188188
{{- if and (eq (include "should-enable-system-probe" .) "true") (eq .Values.datadog.systemProbe.seccomp "localhost/system-probe") }}

charts/datadog/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,10 @@ datadog:
811811
image: ""
812812
# datadog.hostProfiler.imagePullPolicy -- Pull policy for the Host Profiler image. Defaults to agents.image.pullPolicy when unset.
813813
imagePullPolicy: ""
814+
# datadog.hostProfiler.seccomp -- Seccomp profile configuration for the Host Profiler
815+
seccomp:
816+
# datadog.hostProfiler.seccomp.enabled -- Apply the localhost seccomp profile to the host-profiler container and run the init container that installs it on the node. Disable to run the host-profiler container Unconfined (no init container, no profile installed on the node).
817+
enabled: true
814818
# datadog.hostProfiler.seccompRoot -- Specify the seccomp profile root directory
815819
seccompRoot: /var/lib/kubelet/seccomp
816820
# datadog.hostProfiler.apparmor -- Specify an AppArmor profile for the host-profiler container (e.g. "localhost/datadog-host-profiler").

test/datadog/host_profiler_test.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,53 @@ func TestHostProfilerSeccomp(t *testing.T) {
4545
profileRef := *hpContainer.SecurityContext.SeccompProfile.LocalhostProfile
4646
assert.Regexp(t, `^host-profiler-[0-9a-f]{8}$`, profileRef)
4747

48+
// seccomp-root volume must be present.
49+
var seccompVolume *corev1.Volume
50+
for i := range ds.Spec.Template.Spec.Volumes {
51+
if ds.Spec.Template.Spec.Volumes[i].Name == "host-profiler-seccomp-root" {
52+
seccompVolume = &ds.Spec.Template.Spec.Volumes[i]
53+
break
54+
}
55+
}
56+
require.NotNil(t, seccompVolume, "host-profiler-seccomp-root volume should be present when seccomp is enabled")
57+
require.NotNil(t, seccompVolume.HostPath, "host-profiler-seccomp-root volume should be a hostPath volume")
58+
assert.Equal(t, "/var/lib/kubelet/seccomp", seccompVolume.HostPath.Path)
59+
4860
// Init container copies to the matching hashed filename.
4961
initContainer, ok := getContainer(t, ds.Spec.Template.Spec.InitContainers, "host-profiler-seccomp-setup")
50-
require.True(t, ok, "host-profiler-seccomp-setup init container should be present")
62+
require.True(t, ok, "host-profiler-seccomp-setup init container should be present when seccomp is enabled")
5163
assert.Equal(t, "myreg/host-profiler:v1.2.3", initContainer.Image)
5264
assert.True(t, containsString(initContainer.Command, "/host/var/lib/kubelet/seccomp/"+profileRef),
5365
"init container cp destination should match the seccomp profile name; command: %v", initContainer.Command)
66+
67+
}
68+
69+
func TestHostProfilerSeccompDisabled(t *testing.T) {
70+
overrides := copyMap(hostProfilerBaseOverrides)
71+
overrides["datadog.hostProfiler.seccomp.enabled"] = "false"
72+
73+
ds := renderHostProfilerDaemonSet(t, overrides)
74+
75+
// Container must run Unconfined, but other hardening still applies.
76+
hpContainer, ok := getContainer(t, ds.Spec.Template.Spec.Containers, "host-profiler")
77+
require.True(t, ok, "host-profiler container should be present")
78+
require.NotNil(t, hpContainer.SecurityContext)
79+
require.NotNil(t, hpContainer.SecurityContext.SeccompProfile,
80+
"host-profiler should carry a seccomp profile when datadog.hostProfiler.seccomp.enabled=false")
81+
assert.Equal(t, corev1.SeccompProfileTypeUnconfined, hpContainer.SecurityContext.SeccompProfile.Type,
82+
"host-profiler should run Unconfined when datadog.hostProfiler.seccomp.enabled=false")
83+
assert.Nil(t, hpContainer.SecurityContext.SeccompProfile.LocalhostProfile,
84+
"Unconfined profile should not reference a localhost profile")
85+
86+
// Seccomp setup init container must be absent.
87+
_, ok = getContainer(t, ds.Spec.Template.Spec.InitContainers, "host-profiler-seccomp-setup")
88+
assert.False(t, ok, "host-profiler-seccomp-setup init container should be absent when seccomp is disabled")
89+
90+
// seccomp-root volume must be absent.
91+
for _, v := range ds.Spec.Template.Spec.Volumes {
92+
assert.NotEqual(t, "host-profiler-seccomp-root", v.Name,
93+
"host-profiler-seccomp-root volume should be absent when seccomp is disabled")
94+
}
5495
}
5596

5697
func TestHostProfilerSeccompDifferentImages(t *testing.T) {

0 commit comments

Comments
 (0)