fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.16k stars 432 forks source link

API returns incorrect information when attempting to turn off Windows mdm #23158

Open harrisonravazzolo opened 1 month ago

harrisonravazzolo commented 1 month ago

Fleet version: 4.58 Web browser and operating system: Chrome


💥  Actual behavior

Attempting to use the api to turn off mdm on Windows device at this endpoint /api/v1/fleet/hosts/{:id}/mdm returns a conflict 409 with the message:

{
    "message": "Conflict",
    "errors": [
        {
            "name": "base",
            "reason": "mdm is not enabled for host 392"
        }
    ],
    "uuid": "e8b8ea76-3186-404e-904b-09a519b9b029"
}

This api endpoint does not support removing Windows devices, per https://github.com/fleetdm/fleet/blob/d1c3b5b28e45eb02034eb0bebf8db4a58d5e7ca8/server/service/handler.go#L628-L628

The api should return a message similar to the one returned when trying to remove an iOS device (unsupported) through this endpoind:

{
    "message": "Bad request",
    "errors": [
        {
            "name": "base",
            "reason": "Can't turn off MDM for iOS or iPadOS hosts. Use wipe instead."
        }
    ],
    "uuid": "3c8f5c10-125b-453e-9042-39618fd2609f"
}

🧑‍💻  Steps to reproduce

Try to call the endpoint on a Windows host.

jahzielv commented 5 days ago

This is a pretty easy fix (just add another check under here I think).

@marko-lisica is going with something like "Can't turn off MDM for Windows hosts." an OK error to return in this case? Or do we need to take this through the product process?

marko-lisica commented 3 days ago

@jahzielv Can't turn off MDM for Windows hosts. sounds good to me.