Skip to content

feat(mdm): require BitLocker per Windows host on Fleet Free CU-17tkuw6a8db - #293

Merged
andrii-flamingo merged 8 commits into
mainfrom
feat/windows-disk-encryption
Dec 2, 2026
Merged

andrii-flamingo merged 8 commits into
mainfrom
feat/windows-disk-encryption

Conversation

@andrii-flamingo

@andrii-flamingo andrii-flamingo commented Dec 1, 2026 •

Copy link
Copy Markdown

Upstream requires disk encryption per team and only on Premium. A Fleet team is a tenant here, and a tenant requires BitLocker for some of its organizations only, so in OpenFrame mode each Windows host has its own requirement. Outside OpenFrame and shared mode everything stays upstream's.

Requirement

  • POST /api/_version_/fleet/disk_encryption/hosts with {"host_ids": [...]} requires the hosts to encrypt, DELETE with the same body lifts that. Both can be repeated.
  • Hosts of another tenant, hosts that don't exist and hosts that don't run Windows are dropped. In shared mode a call without a tenant is refused.
  • Kept in the new table openframe_host_disk_encryption (fork migration 20261201000001, no data changes), with the tenant it was required in: it does not follow the host to another tenant.

What follows it

  • fleetd: only a required host that is in MDM is told to encrypt. Lifting never turns BitLocker off.
  • Key escrow: a key is accepted after the requirement is lifted, too. On a drive that was already encrypted fleetd removes the other recovery keys before it sends the new one, so a dropped key would leave none.
  • Status: the BitLocker status is in host details on Free for a required host.
  • Archived keys: in OpenFrame mode they are not looked up by hardware serial, which can be another machine's.
  • Result for CDC: the row keeps fleetd's last error and when the key was stored, without the key, so host_disk_encryption_keys never has to be captured. A repeated error changes nothing in the row.

Callers and order

No caller yet. The Fleet image with this change and its migration goes first; the SDK methods with their README rows and the CDC connector change come after it.

Known limits

  • The result is written after the key, not in one transaction with it: if that write fails, key_stored_at stays as it was until the next key.
  • Reading a key needs Windows MDM to be on for the tenant, as upstream.
  • Not checked on a real Windows PC yet.

Tests

Two-tenant MySQL tests and service tests in openframe_windows_disk_encryption_test.go. TestHosts/DeleteHosts fails on main, too, on host_software_windows_details.

Details: openframe/docs/windows-disk-encryption.md.

Change-Set: windows-disk-encryption

Change set flamingo-stack/windows-disk-encryption: this pull request is the only one in it so far. Another pull request joins by naming this one in a Depends-On line, or by carrying the same Change-Set line.

  • flamingo-stack/fleetmdm#293 (this pull request): feat(mdm): require BitLocker per Windows host on Fleet Free CU-17tkuw6a8db · landed

Linked work

  • …and 1 linked item not shown here

Linked by the Depends-On / Change-Set lines in these descriptions; this block is maintained by the hub.

… Free

Upstream requires disk encryption per team and only on Premium. A team is a
tenant here, and a tenant requires encryption for some of its organizations
only, so in OpenFrame mode each Windows host has its own requirement.

POST and DELETE /disk_encryption/hosts set and lift it, within the pinned
tenant. The fleetd notification, the key escrow and the BitLocker status follow
the host. A key is accepted after the requirement is lifted, archived keys are
not looked up by serial, and fleetd's last error and the time the key was stored
are kept in openframe_host_disk_encryption, without the key.
@flamingo

flamingo Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦩 Flamingo Code Review

✅ Tests and checks passed on this commit (3 lanes).

✅ No findings on the current head.

Advisory: findings do not block the merge.

Files Lines Languages Checks 🔴 Action required 🟠 Recommended 🔵 Informational
27 +1272 / -19 Go (1 go test lane), Shell (1 bash -n lane) ✅ 1 / 1 passed 0 0 0

✅ What this change does well

  • The lift in server/datastore/mysql/hosts.go runs inside the same AddHostsToTeam transaction as the upstream key cleanup, so the requirement cannot be left set if the team move rolls back.
  • openframeArchivedKeyBySerial keeps the serial-fallback decision in one fork-only helper, leaving the upstream call site in server/datastore/mysql/disk_encryption.go a single sentinel-wrapped condition.
  • TestOpenframeDiskEncryptionLiftedOnTeamChange covers both the OpenFrame and the plain-upstream branch, and the archived-key test now exercises the new pinned-but-not-OpenFrame case.
  • server/datastore/mysql/openframe_windows_disk_encryption.go lifts the old tenant's requirement in the same row and keeps its team_id, so a CDC consumer keyed by tenant sees the requirement end.
  • server/datastore/mysql/disk_encryption.go now skips the archived-key serial fallback for any tenant-pinned request, not only in OpenFrame mode.
1 possible problem checked and ruled out, 1 after reading more of the repository
  • server/datastore/mysql/openframe_windows_disk_encryption.go:142 Requirement is only lifted on AddHostsToTeam, not when the tenant team is deleted: Verified: the hook is only wired at server/datastore/mysql/hosts.go:3740 (AddHostsToTeam), while team deletion at ee/server/service/teams.go:873-884 deletes the team and calls CleanupDiskEncryptionKeysOnTeamChange, whose datastore impl (disk_encryption.go:351-355) only runs cleanupDiskEncryptionKeysOnTeamChangeDB, so openframe_host_disk_encryption rows keep required=1 with the dead team_id. Real…

🧪 Tests and mutation

Tests per lane

Language Project Command Status Counts Time
Go (go test) . go vet ./server/datastore/mysql ./server/datastore/mysql/migrations/openframe ./server/fleet ./server/mock ./server/mock/service ./server/service && go test -cover ./orbit/... ✅ passed 14.1 s
Shell (bash -n) . bash -n openframe/scripts/verify.sh ✅ passed 0 s

Checks

Check Kind Language Project Status Time
OpenGrep security Go (OpenGrep) . ✅ passed 13.8 s

The test services of flamingo-stack/fleetmdm (server/mdm/nanodep/storage/mysql/docker-compose-test.yml) did not come up: the integration tests may fail for that reason.

The Go lane's own test command runs packages without MySQL; the MySQL-backed tests of this change were run separately with MYSQL_TEST=1 on a local MySQL 8.0.44: all 10 TestOpenframeDiskEncryption* tests, TestDiskEncryption, TestMDMWindows and TestMigrateOpenframeIdempotent pass.

Go has no mutation tool configured; three hand-made mutants of the new lines (dropping the tenant comparison in the team-change lift, ignoring the tenant pin before the serial lookup, skipping the lift call in AddHostsToTeam) were each killed by TestOpenframeDiskEncryptionLiftedOnTeamChange or TestOpenframeDiskEncryptionArchivedKeyNotBySerial.

TestHosts/DeleteHosts fails on main as well (host_software_windows_details), unrelated to this change.

2 gaps (not tested here):

  • Go (go test) .: no mutation testing (no mutation tool for Go is configured: read the coverage of the changed packages instead)
  • Shell (bash -n) .: no mutation testing (no tool configured)

Review again. New commits are not reviewed until you ask:

  • Review the new commits: only what was pushed since this review
  • Review the whole diff again: everything, including what was already reviewed

Or comment @flamingo-review (new commits) or @flamingo-review full (everything). Add the flamingo-review-always label to review every push.

Updated 2026-12-02 12:12 UTC · reviewed from Andrii Koropets's machine

@flamingo

flamingo Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦩 Flamingo Code Review / security

✅ No findings on the current head.

Advisory: findings do not block the merge.

Files Lines 🔴 Action required 🟠 Recommended 🔵 Informational
27 +1272 / -19 0 0 0

Review again. New commits are not reviewed until you ask:

  • Security-check the new commits: only what was pushed since this security review
  • Security-check the whole diff again: everything, including what was already checked

Or comment @flamingo-review security (new commits) or @flamingo-review security full (everything). Add the flamingo-security-review-always label to security-review every push.

Updated 2026-12-02 12:35 UTC · reviewed from Andrii Koropets's machine

Comment thread server/mock/datastore_mock.go Resolved
Comment thread server/mock/datastore_mock.go Resolved
Comment thread server/mock/datastore_mock.go Resolved
Comment thread server/mock/datastore_mock.go Resolved
Comment thread server/mock/service/service_mock.go Resolved
Comment thread server/fleet/service.go Resolved
Comment thread server/mock/service/service_mock.go Resolved
Comment thread server/mock/service/service_mock.go Resolved
Comment thread server/mock/service/service_mock.go Resolved
@andrii-flamingo
andrii-flamingo enabled auto-merge (squash) December 2, 2026 13:03
@andrii-flamingo
andrii-flamingo merged commit 7c0329d into main Dec 2, 2026
20 checks passed
@andrii-flamingo
andrii-flamingo deleted the feat/windows-disk-encryption branch December 2, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants