Skip to content

Commit

Permalink
[CWS] Remove UID / GID from cws instrumentation security context (#23674
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Gui774ume authored Mar 13, 2024
1 parent 9e3202c commit 2597229
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 37 deletions.
2 changes: 1 addition & 1 deletion Dockerfiles/cws-instrumentation/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM scratch
ARG TARGETARCH
COPY --chmod=0755 cws-instrumentation.$TARGETARCH /cws-instrumentation
USER 10000
USER 1000
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const (
cwsInstrumentationPodAnotationReady = "ready"
cwsInjectorInitContainerName = "cws-instrumentation"
cwsUserSessionDataMaxSize = 1024
cwsInjectorInitContainerUser = int64(10000)
cwsInjectorInitContainerGroup = int64(10000)

// PodLabelEnabled is used to label pods that should be instrumented or skipped by the CWS mutating webhook
PodLabelEnabled = "admission.datadoghq.com/cws-instrumentation.enabled"
Expand Down Expand Up @@ -451,9 +449,6 @@ func injectCWSInitContainer(pod *corev1.Pod, resources *corev1.ResourceRequireme
}
}

runAsUser := cwsInjectorInitContainerUser
runAsGroup := cwsInjectorInitContainerGroup

initContainer := corev1.Container{
Name: cwsInjectorInitContainerName,
Image: image,
Expand All @@ -464,11 +459,6 @@ func injectCWSInitContainer(pod *corev1.Pod, resources *corev1.ResourceRequireme
MountPath: cwsMountPath,
},
},
// Set a default user and group to support pod deployments with a `runAsNonRoot` security context
SecurityContext: &corev1.SecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
},
}
if resources != nil {
initContainer.Resources = *resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,6 @@ func Test_injectCWSCommandInstrumentation(t *testing.T) {

func Test_injectCWSPodInstrumentation(t *testing.T) {
commonRegistry := "gcr.io/datadoghq"
runAsUser := cwsInjectorInitContainerUser
runAsGroup := cwsInjectorInitContainerGroup

type args struct {
pod *corev1.Pod
Expand Down Expand Up @@ -501,10 +499,6 @@ func Test_injectCWSPodInstrumentation(t *testing.T) {
MountPath: cwsMountPath,
},
},
SecurityContext: &corev1.SecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
},
},
wantInstrumentation: true,
},
Expand All @@ -528,10 +522,6 @@ func Test_injectCWSPodInstrumentation(t *testing.T) {
MountPath: cwsMountPath,
},
},
SecurityContext: &corev1.SecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
},
},
wantInstrumentation: true,
},
Expand All @@ -555,10 +545,6 @@ func Test_injectCWSPodInstrumentation(t *testing.T) {
MountPath: cwsMountPath,
},
},
SecurityContext: &corev1.SecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
},
},
wantInstrumentation: true,
},
Expand Down Expand Up @@ -593,10 +579,6 @@ func Test_injectCWSPodInstrumentation(t *testing.T) {
MountPath: cwsMountPath,
},
},
SecurityContext: &corev1.SecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
},
},
wantInstrumentation: true,
},
Expand Down Expand Up @@ -657,10 +639,6 @@ func Test_injectCWSPodInstrumentation(t *testing.T) {
MountPath: cwsMountPath,
},
},
SecurityContext: &corev1.SecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
},
},
wantInstrumentation: true,
},
Expand Down Expand Up @@ -701,10 +679,6 @@ func Test_injectCWSPodInstrumentation(t *testing.T) {
MountPath: cwsMountPath,
},
},
SecurityContext: &corev1.SecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
},
},
wantInstrumentation: true,
},
Expand Down

0 comments on commit 2597229

Please sign in to comment.