Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openframe/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The agent has its own switch, `--openframe-mode` / `ORBIT_OPENFRAME_MODE`.
| [server-private-key-kms.md](server-private-key-kms.md) | Server private key wrapped with Google Cloud KMS and stored in MySQL (`FLEET_SERVER_PRIVATE_KEY_KMS_KEY`) instead of passed in plaintext. |
| [enroll-machine-identity.md](enroll-machine-identity.md) | One Fleet host per OpenFrame machine: with `FLEET_OPENFRAME_MACHINE_IDENTITY` on, agents enroll with the OpenFrame machine id and move their host to it with the node key they held, so machines sharing a hardware UUID stop overwriting each other; a second machine (another osquery instance) with the same hardware UUID refused while the owner is live, takeover log for alerting, MDM refused for a UUID shared within a team. |
| [windows-wipe.md](windows-wipe.md) | `POST /hosts/{id}/wipe` wipes Windows hosts on Fleet Free, over Windows MDM (RemoteWipe CSP); refused, or cancelled before it is sent, when the hardware UUID does not identify one device; `completed_wipe` activity when the device accepts it. |
| [windows-disk-encryption.md](windows-disk-encryption.md) | BitLocker required per Windows host on Fleet Free (`POST`/`DELETE /disk_encryption/hosts`): the fleetd notification, the key and the status follow the host, not its team; archived keys are never looked up by serial. |

## Agent-side (orbit / fleetd)

Expand Down
1 change: 1 addition & 0 deletions openframe/docs/fork-file-manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ and the heaviest standing rebase cost.
| Agent OpenFrame mode | `orbit/cmd/orbit/orbit.go`, `orbit/cmd/orbit/openframe_identifier_test.go`, `orbit/pkg/constant/constant.go`, `orbit/pkg/osquery/osquery.go`, `orbit/pkg/osquery/openframe_command.go`, `orbit/pkg/osquery/openframe_command_test.go`, `client/orbit_client.go`, `server/fleet/api_orbit.go`, `server/fleet/orbit.go`, `server/service/orbit.go`, `server/service/orbit_client.go`, `server/service/base_client.go` |
| Shared-mode MDM | instance-wide MDM flags: `server/fleet/openframe.go`, `server/datastore/mysql/app_configs.go`, `server/service/mdm.go`; instance settings and instance-config reads: `cmd/fleet/serve.go`, `server/datastore/cached_mysql/cached_mysql.go`, `server/mdm/android/service/service.go`; enrollment routes: `server/service/openframe_middleware.go`; Android enrollment: `server/mdm/android/service/pubsub.go`; tenant change: `server/datastore/mysql/{hosts,openframe}.go`; Apple OTA: `server/datastore/mysql/apple_mdm.go`; Windows profile cleanup: `server/datastore/mysql/mdm.go`; per-tenant Windows MDM: `server/fleet/{app,datastore,microsoft_mdm,openframe_windows_mdm}.go`, `server/service/{openframe_windows_mdm,orbit,microsoft_mdm,hosts,appconfig,service,openframe_middleware}.go`, `server/service/osquery_utils/{queries,queries_openframe_windows_mdm}.go`, `{cmd/fleet,server/datastore/mysql}/openframe_windows_wstep.go`, `server/datastore/mysql/{microsoft_mdm,microsoft_mdm_batched,apple_mdm,openframe_windows_mdm}.go`, `migrations/openframe/20261127000001_AddTeamIdToMdmWindowsEnrollments.go`, `server/mdm/microsoft/openframe_wstep.go`, `server/mock/datastore_mock.go`; tests: `server/datastore/mysql/{app_configs,android,apple_ota,windows_mdm}_openframe_test.go`, `server/datastore/mysql/openframe_windows_{wstep,mdm}_test.go`, `server/service/{openframe_middleware,openframe_windows_mdm}_test.go`, `server/service/osquery_utils/queries_openframe_mdm_link_test.go`, `migrations/openframe/migration_test.go`, `server/fleet/openframe_windows_mdm_test.go`, `cmd/fleet/openframe_windows_wstep_test.go`, `server/mdm/android/service/pubsub_openframe_test.go` — see [mysql-multitenancy-feature.md](mysql-multitenancy-feature.md) |
| Windows wipe (`openframe/docs/windows-wipe.md`) | `server/service/{scripts,mdm,microsoft_mdm,openframe_windows_mdm,openframe_windows_wipe}.go`, `server/fleet/{datastore,microsoft_mdm,openframe_windows_wipe}.go`, `server/mock/datastore_mock.go`, `server/datastore/mysql/{microsoft_mdm,hosts,openframe_windows_wipe}.go`; tests: `server/service/openframe_windows_wipe_test.go`, `server/datastore/mysql/openframe_windows_wipe_test.go` |
| Windows disk encryption (`openframe/docs/windows-disk-encryption.md`) | `server/service/{orbit,hosts,handler,openframe_windows_disk_encryption}.go`, `server/fleet/{datastore,service,openframe_windows_disk_encryption}.go`, `server/mock/datastore_mock.go`, `server/mock/service/service_mock.go`, `server/datastore/mysql/{apple_mdm,disk_encryption,hosts,microsoft_mdm,openframe_windows_disk_encryption}.go`, `migrations/openframe/20261201000001_AddHostDiskEncryptionTable.go`, `schema.sql`; tests: `server/service/openframe_windows_disk_encryption_test.go`, `server/datastore/mysql/openframe_windows_disk_encryption_test.go`, `server/datastore/mysql/hosts_test.go`, `migrations/openframe/migration_test.go` |
| Agent options kept | `cmd/fleet/serve.go` (starter-library skip under multitenancy), `server/fleet/openframe.go` (trimmed seed/fallback defaults), `server/datastore/mysql/teams_openframe_test.go`, `server/fleet/openframe_test.go` |
| Agent JSON content-type | `client/orbit_client.go`, `client/device_client.go`, `orbit/cmd/fetch_cert/main.go`, `client/orbit_client_content_type_test.go` |
| Orbit 401 streak across restarts | `client/orbit_client.go`, `client/orbit_reenroll_openframe.go`; tests: `client/orbit_reenroll_openframe_test.go` — see [node-key-management.md](node-key-management.md) |
Expand Down
8 changes: 6 additions & 2 deletions openframe/docs/mysql-multitenancy-feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ role-authz grouping upstream; here it is a hard boundary regardless of token rol
Fleet where every tenant operates as the same Admin user.
- **host-assignments** (`policy_hosts`/`query_hosts`) — parent verified in team + foreign host ids
dropped (pre-existing `OPENFRAME(host-assignments)` feature, extended here).
- **disk encryption** (`openframe_host_disk_encryption`): only the pinned team's Windows hosts can be required or
released, a call without a tenant is refused in shared mode, and the requirement counts only in the tenant it was set
in (`OpenframeSetHostsDiskEncryption`, `OpenframeHostDiskEncryption`). `GetHostArchivedDiskEncryptionKey` does not
fall back to the hardware serial in OpenFrame mode ([windows-disk-encryption.md](windows-disk-encryption.md)).
- **teams** — `TeamLite`/`ListTeams` read fence.
- **app_config** cache (`cached_mysql.go`) — cache key includes the pinned team so one tenant's
config is never served to another; unpinned keeps the constant key.
Expand Down Expand Up @@ -233,8 +237,8 @@ and a malformed URL or flag stops the boot.
Windows MDM runs per tenant. Each tenant has its own public Windows MDM address,
`mdm.windows_server_url` on its tenant row (`https://<tenant domain>/mdm`, an https URL with a valid
host and no query, fragment, credentials or whitespace; `server/fleet/openframe_windows_mdm.go`),
written by OpenFrame. A tenant row is seeded without an org name and a server URL, so a pinned config
update accepts them empty as long as the row never had them (`openframeTenantNeverHad`); a tenant that
written by OpenFrame. A tenant row is seeded without an org name and a server URL, so in shared mode
a pinned config update accepts them empty as long as the row never had them (`openframeTenantNeverHad`); a tenant that
has them still can't clear them. Every Windows MDM URL is built from it
(`server/service/openframe_windows_mdm.go`): the discovery URL in the pinned orbit config; the policy
and enroll URLs of discovery, which the middleware pins by the gateway's `X-Tenant-Id` (the only
Expand Down
64 changes: 64 additions & 0 deletions openframe/docs/windows-disk-encryption.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# BitLocker required per host on Fleet Free (OpenFrame)

Upstream requires disk encryption per team and only on Premium. In the fork a team is a tenant, and a tenant
requires encryption for some of its customers only, so each Windows host has its own requirement.

Only in OpenFrame mode (`FLEET_OPENFRAME_MODE`) or shared mode; otherwise everything below is upstream's. macOS
and Linux keep the team's setting, except the archived keys (below).

## Requirement

- `POST /api/_version_/fleet/disk_encryption/hosts` with `{"host_ids": [1, 2]}` requires the hosts to encrypt;
`DELETE` on the same path with the same body lifts that. Both answer `{"hosts": <n>}`, the number of hosts they
applied to, and can be repeated. Permission is the one for upstream's `POST /disk_encryption`, on the pinned team.
- 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.
- `openframe_host_disk_encryption` (`migrations/openframe/20261201000001_AddHostDiskEncryptionTable.go`) keeps a row
per host that was ever required, with the tenant it was required in. Lifting keeps the row with `required = 0`.
A host moved to another tenant is not required there, and starts there without the old tenant's error and key
time; deleting the host deletes the row.

## Result

The same row keeps what fleetd reported, without the key, so that the table can be captured by the CDC connector and
`host_disk_encryption_keys`, which holds the keys, never has to be:

- `client_error`: fleetd's last error, empty when there is none. A failing fleetd reports it again every config cycle;
a repeated error changes nothing in the row.
- `key_stored_at`: when the host's last key was stored, NULL before the first. An error keeps it.

Both are cleared where upstream deletes the key row, MDM re-enrollment and team change: after a wipe or a reinstall the
disk is another one. A required host's fleetd then sends a new key. Lifting the requirement keeps both. The archived key
stays readable after a re-enrollment, so NULL in `key_stored_at` does not mean that Fleet has no key.

## What follows it

- **fleetd** (`setDiskEncryptionNotifications`): a required host that is in MDM gets `EnforceBitLockerEncryption`
under upstream's conditions; any other host does not, whatever the team's setting is. Lifting never turns
BitLocker off.
- **The key** (`SetOrUpdateDiskEncryptionKey`): stored for a host that was ever required, also after the requirement
was lifted. 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 that opens the drive.
- **The status** (`GetMDMWindowsBitLockerStatus`, `os_settings.disk_encryption` in host details): shown on Free for a
required host, empty for any other. No startup PIN is ever required.

`GET /hosts/{id}/encryption_key` is upstream's. The host is fenced (`HostLite`), and in shared mode the key is
decrypted with the pair of the host's tenant.

## Archived keys

Without an archived key of the host itself, upstream returns one by hardware serial. In OpenFrame mode it does not,
on any platform: the serial can be another machine's, of the tenant or of another one.

## Known limits

- fleetd sends again a key that Fleet did not take only while the host is told to encrypt. A key that failed to
reach Fleet is lost if the requirement is lifted before the next try.
- The result is written after the key, not with it. Its write is retried on a deadlock or a lock timeout; if it
fails, `key_stored_at` stays as it was until the next key.
- Reading a key needs Windows MDM to be on for the tenant (`VerifyMDMWindowsConfigured`), as upstream.

## Tests

- `server/service/openframe_windows_disk_encryption_test.go`
- `server/datastore/mysql/openframe_windows_disk_encryption_test.go` (`MYSQL_TEST=1`)
2 changes: 1 addition & 1 deletion openframe/scripts/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rm -f vet.err
# 3. Marker presence: if a merge silently dropped fork code, its OPENFRAME markers
# vanish too. A slug dropping to zero is a red flag worth a human look.
step "OPENFRAME marker presence (dropped-fork-code detector)"
for slug in host-assignments managed-policies managed-queries redis-key-prefix redis-seed-nodes query-results-ttl osquery-host-id agent-openframe-mode agent-json-content-type agent-skip-setup-experience agent-host-info-diagnostics agent-verify-server-tls migration-race server-private-key-kms enroll-machine-identity; do
for slug in host-assignments managed-policies managed-queries redis-key-prefix redis-seed-nodes query-results-ttl osquery-host-id agent-openframe-mode agent-json-content-type agent-skip-setup-experience agent-host-info-diagnostics agent-verify-server-tls migration-race server-private-key-kms enroll-machine-identity windows-disk-encryption; do
n=$(grep -rIl "OPENFRAME($slug" --include='*.go' --include='*.yaml' --include='*.tpl' . 2>/dev/null | wc -l | tr -d ' ')
if [ "$n" -gt 0 ]; then ok "$slug — present in $n file(s)"; else bad "$slug — NO markers found (fork code may have been dropped in the merge)"; fi
done
Expand Down
5 changes: 5 additions & 0 deletions server/datastore/mysql/apple_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4333,167 +4333,172 @@
return nil
}

func (ds *Datastore) MDMResetEnrollment(ctx context.Context, hostUUID string, scepRenewalInProgress bool) error {
return ds.withRetryTxx(ctx, func(tx sqlx.ExtContext) error {
var hosts []fleet.Host
// >>> OPENFRAME(windows-mdm-tenant): in shared mode a pinned reset touches only its tenant's host — openframe/docs/mysql-multitenancy-feature.md
hostsStmt, hostsArgs := `SELECT id, platform, team_id FROM hosts WHERE uuid = ?`, []any{hostUUID}
if teamID, ok := fleet.OpenframeTeamID(ctx); ok && openframeSharedMode(ctx) {
hostsStmt, hostsArgs = hostsStmt+` AND team_id = ?`, append(hostsArgs, teamID)
}
err := sqlx.SelectContext(
ctx, tx, &hosts,
hostsStmt, hostsArgs...,
)
// <<< OPENFRAME(windows-mdm-tenant)
switch {
case err != nil:
return ctxerr.Wrap(ctx, err, "resetting mdm enrollment: getting host info from UUID")
case len(hosts) == 0:
return ctxerr.Wrap(ctx, notFound("Host").WithName(hostUUID), "resetting mdm enrollment: getting host info from UUID")
case len(hosts) > 1:
// >>> OPENFRAME(enroll-machine-identity): machines of one team sharing a hardware UUID get no MDM enrollment rather than each other's host — openframe/docs/enroll-machine-identity.md
if err := ds.openframeRefuseSharedHardwareUUIDOfOneTeam(ctx, hostUUID, hosts); err != nil {
return err
}
// <<< OPENFRAME(enroll-machine-identity)
// This shouldn't happen, but if it does, we log the IDs of the hosts
// with the same UUID for debugging purposes.
ids := make([]uint, len(hosts))
for _, host := range hosts {
ids = append(ids, host.ID)
}
ds.logger.InfoContext(ctx, "multiple hosts found with the same uuid", "host_ids", fmt.Sprintf("%v", ids))
}
host := hosts[0]

if !fleet.MDMSupported(host.Platform) {
return ctxerr.Errorf(ctx, "unsupported host platform: %q", host.Platform)
}

// Reconcile host_emails and host_scim_users sourced from mdm_idp_accounts.
//
// Note that we aren't deleting the mdm_idp_accounts themselves, just prior associations
// for the host. This ensures that hosts that reenroll their emails up-to-date.
switch host.Platform {
case "darwin", "ios", "ipados":
idp, err := reconcileHostEmailsFromMdmIdpAccountsDB(ctx, tx, ds.logger, host.ID)
if err != nil {
return ctxerr.Wrap(ctx, err, "resetting host_emails sourced from mdm_idp_accounts")
}
// TODO: confirm approach with Victor
if _, err := tx.ExecContext(ctx, `DELETE FROM host_scim_user WHERE host_id = ?`, host.ID); err != nil {
return ctxerr.Wrap(ctx, err, "resetting host_scim_users")
}
if err := maybeAssociateHostMDMIdPWithScimUser(ctx, tx, ds.logger, host.ID, idp); err != nil {
return ctxerr.Wrap(ctx, err, "resetting host_emails sourced from mdm_idp_accounts")
}
}

// TODO: Add test coverage for scepRenewalInProgress branching logic.
// FIXME: When revisiting scep renewal paths, think about no clear indicator for new enrollment vs only SCEP renewal coming from Authenticate
// which is why we call this method, with a distinct false value in TokenUpdate, as that is only where we have a clear indicator
// on if it is an old device that was expected to renew but was wiped.
if scepRenewalInProgress {
// FIXME: We need to revisit this flow. Short-circuiting in random places means it is
// much more difficult to reason about the state of the host. We should try instead
// to centralize the flow control in the lifecycle methods.
ds.logger.InfoContext(ctx, "host lifecycle action received for a SCEP renewal in process, skipping additional reset actions", "host_uuid", hostUUID)
return nil
}

// Deleting profiles from this table will cause all profiles to
// be re-delivered on the next cron run.
if err := ds.deleteMDMOSCustomSettingsForHost(ctx, tx, hostUUID, host.Platform); err != nil {
return ctxerr.Wrap(ctx, err, "resetting profiles status")
}

// Delete any stored disk encryption keys. This covers cases
// where hosts re-enroll without sending a CheckOut message
// first, for example:
//
// - IT admin wiping the host locally
// - Host restoring from a back-up
//
// This also means that somebody running `sudo profiles renew
// --type enrollment` will report disk encryption as "pending"
// for a short period of time.
_, err = tx.ExecContext(ctx, `
DELETE FROM host_disk_encryption_keys
WHERE host_id = ?`, host.ID)
if err != nil {
return ctxerr.Wrap(ctx, err, "resetting disk encryption key information for host")
}
// >>> OPENFRAME(windows-disk-encryption): the result goes with the key — openframe/docs/windows-disk-encryption.md
if err := openframeClearDiskEncryptionResults(ctx, tx, []uint{host.ID}); err != nil {
return err
}
// <<< OPENFRAME(windows-disk-encryption)

// Clear MDM-delivered certs for the same re-enroll-without-CheckOut
// cases (local wipe, restore from backup, manual MDM profile removal).
if err := softDeleteMDMHostCertsDB(ctx, tx, host.ID); err != nil {
return ctxerr.Wrap(ctx, err, "resetting mdm host certificates for host")
}

// Do platform-specific cleanup.
switch host.Platform {
case "ios", "ipados":
// Clear refetch commands for iOS and iPadOS hosts.
// FIXME: Do we care about wipe/lock commands? How can we consolidate this with host deletion? See https://github.com/fleetdm/fleet/pull/29283/files#r2098735905
_, err = tx.ExecContext(ctx, `
DELETE FROM host_mdm_commands
WHERE host_id = ? AND instr(command_type, ?)`, host.ID, fleet.RefetchBaseCommandUUIDPrefix)
if err != nil {
return ctxerr.Wrap(ctx, err, "resetting host_mdm_commands for host")
}

case "darwin":
// Deleting the matching entry on this table will cause
// the aggregate report to show this host as 'pending' to
// install the bootstrap package.
_, err = tx.ExecContext(ctx, `DELETE FROM host_mdm_apple_bootstrap_packages WHERE host_uuid = ?`, hostUUID)
if err != nil {
return ctxerr.Wrap(ctx, err, "resetting host_mdm_apple_bootstrap_packages")
}

_, err = tx.ExecContext(
ctx,
"UPDATE nano_enrollments SET hardware_attested = false WHERE id = ? AND enabled = 1",
hostUUID,
)
if err != nil {
return ctxerr.Wrap(ctx, err, "resetting hardware_attested")
}

// Soft-delete the recovery lock password: Apple wipes the device-side recovery lock
// whenever the MDM profile is removed, and any subsequent Authenticate means the
// device went through an unenroll/re-enroll (or wipe/restore). Also unsticks rows
// whose SetRecoveryLock command was abandoned by nanomdm's ClearQueue (same
// Authenticate fires both cleanups). Table is keyed by host_uuid.
if err := softDeleteHostRecoveryLockPassword(ctx, tx, hostUUID); err != nil {
return err
}
}

// reset the enrolled_from_migration value. We only get to this
// stage if the host is enrolling with Fleet, SCEP renewals are
// short-circuited before this.
_, err = tx.ExecContext(
ctx,
"UPDATE nano_enrollments SET enrolled_from_migration = 0 WHERE id = ? AND enabled = 1",
hostUUID,
)
if err != nil {
return ctxerr.Wrap(ctx, err, "setting enrolled_from_migration")
}
_, err = tx.ExecContext(
ctx,
`UPDATE nano_devices SET platform = ?, enroll_team_id = ? WHERE id = ?`,
host.Platform, host.TeamID, hostUUID,
)
if err != nil {
return ctxerr.Wrap(ctx, err, "setting platform and enroll_team_id")
}

return nil
})
}

Check warning on line 4501 in server/datastore/mysql/apple_mdm.go

View check run for this annotation

Flamingo / Flamingo Code Review

MDMResetEnrollment duplicates an existing definition

MDMResetEnrollment duplicates an existing definition Same structure as [FleetMDM:server/datastore/mysql/apple_mdm.go:7571](https://github.com/flamingo-stack/fleetmdm/blob/399b7a8b383e382e6c91d08fe48f48858579b7a0/server/datastore/mysql/apple_mdm.go#L7571-L7608) (go:github.com/fleetdm/fleet/v4/server/datastore/mysql.Datastore.MDMAppleResetOnReenrollment) and 2 more. Reuse the existing definition, or extract one shared implementation.

func (ds *Datastore) ClearHostEnrolledFromMigration(ctx context.Context, hostUUID string) error {
const stmt = `
Expand Down
11 changes: 9 additions & 2 deletions server/datastore/mysql/disk_encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@

var key fleet.HostArchivedDiskEncryptionKey
err := sqlx.GetContext(ctx, ds.reader(ctx), &key, fmt.Sprintf(sqlFmt, `WHERE host_id = ?`), host.ID)
if err == sql.ErrNoRows && host.HardwareSerial != "" {
// >>> OPENFRAME(windows-disk-encryption): in OpenFrame mode a key is never looked up by serial: it can be another machine's, of any tenant — openframe/docs/windows-disk-encryption.md
if err == sql.ErrNoRows && host.HardwareSerial != "" && !openframeWindowsDiskEncryptionEnabled(ctx) {

Check warning on line 321 in server/datastore/mysql/disk_encryption.go

View check run for this annotation

Flamingo / Flamingo Code Review / tests and mutation

A host that is deleted and enrolls again loses access to its archived recovery key

The archived key is found only by host_id in OpenFrame mode. A PC whose Fleet host was deleted enrolls as a new host: the new host has no requirement row and GetHostArchivedDiskEncryptionKey answers NotFound, although the archive still has the key under the old host_id. Reproduced on MySQL with the same tenant and serial; upstream returns the key there. Risk: The PC stays encrypted with a key nobody can read until it is required again and fleetd rotates the key. If it locks before that, the drive can't be unlocked. Fix: Keep the lookup off (a serial can be another machine's), but record it under Known limits in openframe/docs/windows-disk-encryption.md: a new host must be required again, which makes fleetd escrow a new key. The OpenFrame caller has to do that on a new host id.
Comment thread
andrii-flamingo marked this conversation as resolved.
Resolved
// <<< OPENFRAME(windows-disk-encryption)
// If we didn't find a key by host ID, try to find it by hardware serial.
ds.logger.DebugContext(ctx, "get archived disk encryption key by host serial", "serial", host.HardwareSerial, "host_id", host.ID)
err = sqlx.GetContext(ctx, ds.reader(ctx), &key, fmt.Sprintf(sqlFmt, `WHERE hardware_serial = ?`), host.HardwareSerial)
Expand Down Expand Up @@ -380,5 +382,10 @@
}

_, err = tx.ExecContext(ctx, deleteStmt, deleteArgs...)
return err
// >>> OPENFRAME(windows-disk-encryption): the result goes with the key — openframe/docs/windows-disk-encryption.md
if err != nil {
return err
}
return openframeClearDiskEncryptionResults(ctx, tx, hostIDs)
// <<< OPENFRAME(windows-disk-encryption)
}
1 change: 1 addition & 0 deletions server/datastore/mysql/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ var hostRefs = []string{
"host_disks",
"host_updates",
"host_disk_encryption_keys",
"openframe_host_disk_encryption", // OPENFRAME(windows-disk-encryption)
"host_software_installed_paths",
"host_software_windows_details", // OPENFRAME(software-windows-details)
"query_results",
Expand Down
7 changes: 7 additions & 0 deletions server/datastore/mysql/hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9400,6 +9400,13 @@ func testHostsDeleteHosts(t *testing.T, ds *Datastore) {
Username: "test-user",
}}, fleet.HostCertificateOriginOsquery))

// OPENFRAME(windows-disk-encryption)
_, err = ds.writer(context.Background()).Exec(`
INSERT INTO openframe_host_disk_encryption (host_id, team_id, required)
VALUES (?, ?, 1);
`, host.ID, team.ID)
require.NoError(t, err)

// create an android device from this host
deviceID := strings.ReplaceAll(uuid.NewString(), "-", "")
_, err = ds.writer(context.Background()).Exec(`
Expand Down
4 changes: 3 additions & 1 deletion server/datastore/mysql/microsoft_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,9 @@ func (ds *Datastore) GetMDMWindowsBitLockerStatus(ctx context.Context, host *fle
return nil, nil
}

diskEncryptionConfig, err := ds.GetConfigEnableDiskEncryption(ctx, host.TeamID)
// >>> OPENFRAME(windows-disk-encryption): in OpenFrame mode the host's own requirement, not its team's — openframe/docs/windows-disk-encryption.md
diskEncryptionConfig, err := ds.openframeDiskEncryptionConfig(ctx, host)
// <<< OPENFRAME(windows-disk-encryption)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package openframe

import (
"database/sql"
"fmt"
)

func init() {
MigrationClient.AddMigration(Up_20261201000001, Down_20261201000001)
}

// Up_20261201000001 adds `openframe_host_disk_encryption`: the Windows hosts OpenFrame has ever required to encrypt, and
// whether it still does. A row stays when the requirement is lifted, so that a key on its way is accepted. `team_id` is
// the host's tenant when the row was written: a row does not follow the host to another tenant. `client_error` and
// `key_stored_at` repeat what host_disk_encryption_keys knows without the key, so that this table can be captured by the
// CDC connector and that one never has to be. See openframe/docs/windows-disk-encryption.md.
//
// Idempotent.
func Up_20261201000001(tx *sql.Tx) error {
if _, err := tx.Exec(`
CREATE TABLE IF NOT EXISTS openframe_host_disk_encryption (
host_id INT UNSIGNED NOT NULL,
team_id INT UNSIGNED DEFAULT NULL,
required TINYINT(1) NOT NULL,
client_error VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
key_stored_at TIMESTAMP(6) NULL DEFAULT NULL,
updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
PRIMARY KEY (host_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`); err != nil {
return fmt.Errorf("creating openframe_host_disk_encryption: %w", err)
}
return nil
}
Comment thread
andrii-flamingo marked this conversation as resolved.
Resolved
Comment thread
andrii-flamingo marked this conversation as resolved.
Resolved

func Down_20261201000001(tx *sql.Tx) error {
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestAllOpenframeMigrationsRegistered(t *testing.T) {
20261123000001, // WidenSoftwareCveId
20261123000002, // AddHostEnrollOwnersTable
20261127000001, // AddTeamIdToMdmWindowsEnrollments
20261201000001, // AddHostDiskEncryptionTable
}

var got []int64
Expand Down
Loading
Loading