mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #38889 Plan was to convert `osquery_utils` package to slog. Picked up some additional code that was related. # Checklist for submitter - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - Already have changes ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit # Release Notes ## Refactor * Updated internal logging infrastructure to use improved system-level logging utilities ## Tests * Updated test suite to align with internal logging changes --- **Note:** This release contains internal infrastructure improvements with no user-facing changes or new features. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
40 lines
997 B
Go
40 lines
997 B
Go
package osquery_utils
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
)
|
|
|
|
// IsDiskEncryptionEnabledForHost checks if disk encryption is enabled for the
|
|
// host team or globally if the host is not assigned to a team.
|
|
func IsDiskEncryptionEnabledForHost(ctx context.Context, logger *slog.Logger, ds fleet.Datastore, host *fleet.Host) bool {
|
|
// team
|
|
if host.TeamID != nil {
|
|
teamMDM, err := ds.TeamMDMConfig(ctx, *host.TeamID)
|
|
if err != nil {
|
|
logger.DebugContext(ctx, "failed to get team MDM config for disk encryption check",
|
|
"host_id", host.ID,
|
|
"team_id", *host.TeamID,
|
|
"err", err,
|
|
)
|
|
return false
|
|
}
|
|
if teamMDM == nil {
|
|
return false
|
|
}
|
|
return teamMDM.EnableDiskEncryption
|
|
}
|
|
|
|
// global
|
|
appConfig, err := ds.AppConfig(ctx)
|
|
if err != nil {
|
|
logger.DebugContext(ctx, "failed to get app config for disk encryption check",
|
|
"host_id", host.ID,
|
|
"err", err,
|
|
)
|
|
return false
|
|
}
|
|
return appConfig.MDM.EnableDiskEncryption.Value
|
|
}
|