@@ -252,10 +252,10 @@ func (p *podSeccompRecorder) updateSecurityContext(
252
252
}
253
253
254
254
switch pr .Spec .Kind {
255
- case profilerecordingv1alpha1 .ProfileRecordingKindSeccompProfile ,
256
- profilerecordingv1alpha1 .ProfileRecordingKindSelinuxProfile ,
257
- profilerecordingv1alpha1 .ProfileRecordingKindAppArmorProfile :
255
+ case profilerecordingv1alpha1 .ProfileRecordingKindSeccompProfile :
258
256
p .updateSeccompSecurityContext (ctr , pr )
257
+ case profilerecordingv1alpha1 .ProfileRecordingKindSelinuxProfile :
258
+ p .updateSelinuxSecurityContext (ctr , pr )
259
259
}
260
260
261
261
p .log .Info (fmt .Sprintf (
@@ -290,6 +290,26 @@ func (p *podSeccompRecorder) updateSeccompSecurityContext(
290
290
ctr .SecurityContext .SeccompProfile .LocalhostProfile = & profile
291
291
}
292
292
293
+ func (p * podSeccompRecorder ) updateSelinuxSecurityContext (
294
+ ctr * corev1.Container ,
295
+ pr * profilerecordingv1alpha1.ProfileRecording ,
296
+ ) {
297
+ if ctr .SecurityContext == nil {
298
+ ctr .SecurityContext = & corev1.SecurityContext {}
299
+ }
300
+
301
+ if ctr .SecurityContext .SELinuxOptions == nil {
302
+ ctr .SecurityContext .SELinuxOptions = & corev1.SELinuxOptions {}
303
+ } else {
304
+ p .record .Eventf (pr ,
305
+ corev1 .EventTypeWarning ,
306
+ "SecurityContextAlreadySet" ,
307
+ "Container %s had SecurityContext already set, the profile recorder overwrote it" , ctr .Name )
308
+ }
309
+
310
+ ctr .SecurityContext .SELinuxOptions .Type = config .SelinuxPermissiveProfile
311
+ }
312
+
293
313
func (p * podSeccompRecorder ) setRecordingReferences (
294
314
ctx context.Context ,
295
315
op admissionv1.Operation ,
0 commit comments