Add code comments and fix typo. No functional changes. (#27494)

For #27472
This commit is contained in:
Victor Lyuboslavsky
2025-03-25 09:08:47 -05:00
committed by GitHub
parent 5c56796403
commit 075f5bf890
4 changed files with 13 additions and 3 deletions
@@ -12,7 +12,10 @@ type FDEFileVaultOptionsPayload struct {
DontAllowFDEEnable *bool `plist:"dontAllowFDEEnable"`
}
func ContainsFDEVileVaultOptionsPayload(contents []byte) (bool, error) {
// ContainsFDEFileVaultOptionsPayload returns true if the payload contains any FileVault options.
// https://developer.apple.com/documentation/devicemanagement/fdefilevaultoptions
// Fleet users are not allowed to upload such payloads because Fleet fully manages disk encryption (FileVault).
func ContainsFDEFileVaultOptionsPayload(contents []byte) (bool, error) {
if len(contents) == 0 {
return false, nil
}
@@ -36,6 +36,7 @@ func TestContainsFDEVileVaultOptionsPayload(t *testing.T) {
contains: false,
},
{
// Add all the FileVault options to the custom settings payload
name: "com.apple.MCX payload with all FDE options",
in: getFileVaultOptionsPayload(FDEFileVaultOptionsPayload{
PayloadType: FleetCustomSettingsPayloadType,
@@ -46,6 +47,7 @@ func TestContainsFDEVileVaultOptionsPayload(t *testing.T) {
contains: true,
},
{
// Only add the dontAllowFDEDisable property to the custom settings payload
name: "contains dontAllowFDEDisable",
in: getFileVaultOptionsPayload(FDEFileVaultOptionsPayload{
PayloadType: FleetCustomSettingsPayloadType,
@@ -54,6 +56,7 @@ func TestContainsFDEVileVaultOptionsPayload(t *testing.T) {
contains: true,
},
{
// Only add the dontAllowFDEEnable property to the custom settings payload
name: "contains dontAllowFDEEnable",
in: getFileVaultOptionsPayload(FDEFileVaultOptionsPayload{
PayloadType: FleetCustomSettingsPayloadType,
@@ -62,6 +65,7 @@ func TestContainsFDEVileVaultOptionsPayload(t *testing.T) {
contains: true,
},
{
// Only add the DestroyFVKeyOnStandby property to the custom settings payload
name: "contains DestroyFVKeyOnStandby",
in: getFileVaultOptionsPayload(FDEFileVaultOptionsPayload{
PayloadType: FleetCustomSettingsPayloadType,
@@ -72,7 +76,7 @@ func TestContainsFDEVileVaultOptionsPayload(t *testing.T) {
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
result, err := ContainsFDEVileVaultOptionsPayload([]byte(tc.in))
result, err := ContainsFDEFileVaultOptionsPayload([]byte(tc.in))
require.NoError(t, err)
assert.Equal(t, tc.contains, result)
})
@@ -256,7 +256,7 @@ func (mc *Mobileconfig) ScreenPayloads() error {
case FleetFileVaultPayloadType, FleetRecoveryKeyEscrowPayloadType:
return errors.New(DiskEncryptionProfileRestrictionErrMsg)
case FleetCustomSettingsPayloadType:
contains, err := ContainsFDEVileVaultOptionsPayload(*mc)
contains, err := ContainsFDEFileVaultOptionsPayload(*mc)
if err != nil {
return fmt.Errorf("checking for FDEVileVaultOptions payload: %w", err)
}
@@ -2347,6 +2347,7 @@ func (s *integrationMDMTestSuite) TestBatchSetMDMAppleProfiles() {
// payloads with reserved types
for p := range mobileconfig.FleetPayloadTypes() {
if p == mobileconfig.FleetCustomSettingsPayloadType {
// FileVault options in the custom settings payload are checked in file_vault_options_test.go
continue
}
res := s.Do("POST", "/api/v1/fleet/mdm/apple/profiles/batch", batchSetMDMAppleProfilesRequest{Profiles: [][]byte{
@@ -4309,6 +4310,7 @@ func (s *integrationMDMTestSuite) TestBatchSetMDMProfiles() {
// payloads with reserved types
for p := range mobileconfig.FleetPayloadTypes() {
if p == mobileconfig.FleetCustomSettingsPayloadType {
// FileVault options in the custom settings payload are checked in file_vault_options_test.go
continue
}
res := s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", batchSetMDMProfilesRequest{Profiles: []fleet.MDMProfileBatchPayload{
@@ -4592,6 +4594,7 @@ func (s *integrationMDMTestSuite) TestBatchSetMDMProfilesBackwardsCompat() {
// payloads with reserved types
for p := range mobileconfig.FleetPayloadTypes() {
if p == mobileconfig.FleetCustomSettingsPayloadType {
// FileVault options in the custom settings payload are checked in file_vault_options_test.go
continue
}
res := s.Do("POST", "/api/v1/fleet/mdm/profiles/batch", map[string]any{"profiles": map[string][]byte{