From 838645a905f2f1df948747b2b229d2926ef7e2f0 Mon Sep 17 00:00:00 2001 From: gillespi314 <73313222+gillespi314@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:12:53 -0600 Subject: [PATCH] Screen for unsupported MDM config profile payload types in CLI (#10098) --- server/service/apple_mdm.go | 5 ++++ server/service/apple_mdm_test.go | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/server/service/apple_mdm.go b/server/service/apple_mdm.go index 3fcd759400..522035493a 100644 --- a/server/service/apple_mdm.go +++ b/server/service/apple_mdm.go @@ -1480,6 +1480,11 @@ func (svc *Service) BatchSetMDMAppleProfiles(ctx context.Context, tmID *uint, tm "invalid mobileconfig profile") } + if err := mdmProf.ScreenPayloadTypes(); err != nil { + return ctxerr.Wrap(ctx, + fleet.NewInvalidArgumentError(fmt.Sprintf("profiles[%d]", i), err.Error())) + } + if byName[mdmProf.Name] { return ctxerr.Wrap(ctx, fleet.NewInvalidArgumentError(fmt.Sprintf("profiles[%d]", i), fmt.Sprintf("Couldn’t edit custom_settings. More than one configuration profile have the same name (PayloadDisplayName): %q", mdmProf.Name)), diff --git a/server/service/apple_mdm_test.go b/server/service/apple_mdm_test.go index 372162b490..1512c686a7 100644 --- a/server/service/apple_mdm_test.go +++ b/server/service/apple_mdm_test.go @@ -1159,6 +1159,47 @@ func TestMDMBatchSetAppleProfiles(t *testing.T) { }, ``, }, + { + "unsupported payload type", + &fleet.User{GlobalRole: ptr.String(fleet.RoleAdmin)}, + false, + nil, + nil, + [][]byte{[]byte(` + + + + PayloadContent + + + Enable + On + PayloadDisplayName + FileVault 2 + PayloadIdentifier + com.apple.MCX.FileVault2.A5874654-D6BA-4649-84B5-43847953B369 + PayloadType + com.apple.MCX.FileVault2 + PayloadUUID + A5874654-D6BA-4649-84B5-43847953B369 + PayloadVersion + 1 + + + PayloadDisplayName + Config Profile Name + PayloadIdentifier + com.example.config.FE42D0A2-DBA9-4B72-BC67-9288665B8D59 + PayloadType + Configuration + PayloadUUID + FE42D0A2-DBA9-4B72-BC67-9288665B8D59 + PayloadVersion + 1 + + `)}, + "unsupported PayloadType(s)", + }, } for _, tt := range testCases {