@@ -252,10 +252,12 @@ 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
+ case profilerecordingv1alpha1 .ProfileRecordingKindAppArmorProfile :
260
+ p .updateApparmorSecurityContext (ctr , pr )
259
261
}
260
262
261
263
p .log .Info (fmt .Sprintf (
@@ -290,6 +292,40 @@ func (p *podSeccompRecorder) updateSeccompSecurityContext(
290
292
ctr .SecurityContext .SeccompProfile .LocalhostProfile = & profile
291
293
}
292
294
295
+ func (p * podSeccompRecorder ) updateSelinuxSecurityContext (
296
+ ctr * corev1.Container ,
297
+ pr * profilerecordingv1alpha1.ProfileRecording ,
298
+ ) {
299
+ if ctr .SecurityContext == nil {
300
+ ctr .SecurityContext = & corev1.SecurityContext {}
301
+ }
302
+
303
+ if ctr .SecurityContext .SELinuxOptions == nil {
304
+ ctr .SecurityContext .SELinuxOptions = & corev1.SELinuxOptions {}
305
+ } else {
306
+ p .record .Eventf (pr ,
307
+ corev1 .EventTypeWarning ,
308
+ "SecurityContextAlreadySet" ,
309
+ "Container %s had SecurityContext already set, the profile recorder overwrote it" , ctr .Name )
310
+ }
311
+
312
+ ctr .SecurityContext .SELinuxOptions .Type = config .SelinuxPermissiveProfile
313
+ }
314
+
315
+ func (p * podSeccompRecorder ) updateApparmorSecurityContext (
316
+ ctr * corev1.Container ,
317
+ pr * profilerecordingv1alpha1.ProfileRecording ,
318
+ ) {
319
+ if pr .Spec .Recorder != profilerecordingv1alpha1 .ProfileRecorderLogs {
320
+ return
321
+ }
322
+
323
+ p .record .Eventf (pr ,
324
+ corev1 .EventTypeWarning ,
325
+ "AppArmorNotSupported" ,
326
+ "AppArmor log-based recording is not supported, container: %s" , ctr .Name )
327
+ }
328
+
293
329
func (p * podSeccompRecorder ) setRecordingReferences (
294
330
ctx context.Context ,
295
331
op admissionv1.Operation ,
0 commit comments