iPhone/iPad support (#19221)

#18119

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [X] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [x] Added/updated tests
- [X] Manual QA for all new/changed functionality

---------

Co-authored-by: RachelElysia <71795832+RachelElysia@users.noreply.github.com>
Co-authored-by: Jacob Shandling <61553566+jacobshandling@users.noreply.github.com>
Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
This commit is contained in:
Lucas Manuel Rodriguez
2024-05-28 19:17:14 -03:00
committed by GitHub
co-authored by RachelElysia Jacob Shandling Jacob Shandling
parent 0cf1f78bf1
commit cdf2a0c47c
53 changed files with 1433 additions and 378 deletions
+9 -8
View File
@@ -90,7 +90,7 @@ func mdmRunCommand() *cli.Command {
var (
hostUUIDs []string
notFoundCount int
platform string
mdmPlatform string // "darwin" or "windows"
)
for _, ident := range hostIdents {
host, err := client.HostByIdentifier(ident)
@@ -110,10 +110,11 @@ func mdmRunCommand() *cli.Command {
return err
}
if host.Platform != platform && platform != "" {
mdmHostPlatform := fleet.MDMPlatform(host.Platform)
if mdmHostPlatform != mdmPlatform && mdmPlatform != "" {
return errors.New(`Command can't run on hosts with different platforms. Make sure the hosts specified in the "hosts" flag are either all macOS or all Windows hosts.`)
}
platform = host.Platform
mdmPlatform = mdmHostPlatform
// TODO(mna): this "On" check is brittle, but looks like it's the only
// enrollment indication we have right now...
@@ -134,15 +135,15 @@ func mdmRunCommand() *cli.Command {
return errors.New("One or more targeted hosts don't exist. Make sure you provide a valid hostname, UUID, osquery host ID, or node key.")
}
result, err := client.RunMDMCommand(hostUUIDs, payload, platform)
result, err := client.RunMDMCommand(hostUUIDs, payload, mdmPlatform)
if err != nil {
if errors.Is(err, service.ErrMissingLicense) && platform == "windows" {
if errors.Is(err, service.ErrMissingLicense) && mdmPlatform == "windows" {
return errors.New(fleet.WindowsMDMRequiresPremiumCmdMessage)
}
var sce kithttp.StatusCoder
if errors.As(err, &sce) {
if sce.StatusCode() == http.StatusUnsupportedMediaType && platform == "darwin" {
if sce.StatusCode() == http.StatusUnsupportedMediaType && mdmPlatform == "darwin" {
return fmt.Errorf("The payload isn't valid. Please provide a valid MDM command in the form of a plist-encoded XML file: %w", err)
}
// this condition needs to be repeated here: maybe the user has
@@ -229,7 +230,7 @@ func mdmUnlockCommand() *cli.Command {
return fmt.Errorf("Failed to unlock host: %w", err)
}
if host.Platform == "darwin" {
if fleet.MDMPlatform(host.Platform) == "darwin" {
fmt.Fprintf(c.App.Writer, `
Use this 6 digit PIN to unlock the host:
@@ -329,7 +330,7 @@ func hostMdmActionSetup(c *cli.Context, hostIdent string, actionType string) (cl
}
// check mdm is on for the host
if host.Platform == "windows" || host.Platform == "darwin" {
if fleet.MDMSupported(host.Platform) {
if host.MDM.EnrollmentStatus == nil || !strings.HasPrefix(*host.MDM.EnrollmentStatus, "On") ||
host.MDM.Name != fleet.WellKnownMDMFleet {
return nil, nil, fmt.Errorf("Can't %s the host because it doesn't have MDM turned on.", actionType)