Fixed issue due to UUID mistmatch on BitLocker CSP cmd. (#32210)

For #28133.

When generating the payload for the BitLocker CSP used for setting the
TPM PIN policy, make sure the UUID used in the Atomic enclousure matches
the UUID used for the whole command.
This commit is contained in:
Juan Fernandez
2025-08-22 14:32:23 -04:00
committed by GitHub
parent 34914a8aab
commit b2d84ebd61
3 changed files with 17 additions and 11 deletions
+5 -1
View File
@@ -468,7 +468,11 @@ func updateMDMWindowsHostProfileStatusFromResponseDB(
sb.WriteString("(?, ?, ?, ?, ?, command_uuid, ?),")
}
stmt = fmt.Sprintf(updateHostProfilesStmt, strings.TrimSuffix(sb.String(), ","))
values := strings.TrimSuffix(sb.String(), ",")
if len(values) == 0 {
return nil
}
stmt = fmt.Sprintf(updateHostProfilesStmt, values)
_, err = tx.ExecContext(ctx, stmt, args...)
return ctxerr.Wrap(ctx, err, "updating host profiles")
}
+4 -3
View File
@@ -3,8 +3,9 @@ package microsoft_mdm
import (
"bytes"
"errors"
"github.com/fleetdm/fleet/v4/server/fleet"
"text/template"
"github.com/fleetdm/fleet/v4/server/fleet"
)
const (
@@ -24,9 +25,9 @@ var systemDriveRequiresStartupAuthTmpl = template.Must(template.New("cmd").Funcs
return *val
}}).Parse(`
<Atomic>
<CmdID>{{ .CmdUUID }}-1</CmdID>
<CmdID>{{ .CmdUUID }}</CmdID>
<Replace>
<CmdID>{{ .CmdUUID }}-2</CmdID>
<CmdID>{{ .CmdUUID }}-1</CmdID>
<Item>
<Meta>
<Format>chr</Format>
+8 -7
View File
@@ -1,10 +1,11 @@
package microsoft_mdm
import (
"github.com/fleetdm/fleet/v4/server/ptr"
"github.com/stretchr/testify/require"
"strings"
"testing"
"github.com/fleetdm/fleet/v4/server/ptr"
"github.com/stretchr/testify/require"
)
func TestSystemDriveRequiresStartupAuthSpec_validate(t *testing.T) {
@@ -105,7 +106,7 @@ func TestSystemDriveRequiresStartupAuthSpec_validate(t *testing.T) {
}
}
func TestSystemDrRequiresStartupAuthCmd_Template(t *testing.T) {
func TestSystemDriveRequiresStartupAuthCmd_Template(t *testing.T) {
tests := []struct {
name string
spec SystemDriveRequiresStartupAuthSpec
@@ -119,9 +120,9 @@ func TestSystemDrRequiresStartupAuthCmd_Template(t *testing.T) {
},
expected: `
<Atomic>
<CmdID>uuid-123-1</CmdID>
<CmdID>uuid-123</CmdID>
<Replace>
<CmdID>uuid-123-2</CmdID>
<CmdID>uuid-123-1</CmdID>
<Item>
<Meta>
<Format>chr</Format>
@@ -150,9 +151,9 @@ func TestSystemDrRequiresStartupAuthCmd_Template(t *testing.T) {
},
expected: `
<Atomic>
<CmdID>uuid-789-1</CmdID>
<CmdID>uuid-789</CmdID>
<Replace>
<CmdID>uuid-789-2</CmdID>
<CmdID>uuid-789-1</CmdID>
<Item>
<Meta>
<Format>chr</Format>