grendel-consulting / steampipe-plugin-kolide

Use SQL to instantly query your Kolide K2 fleet
https://hub.steampipe.io/plugins/grendel-consulting/kolide
Apache License 2.0
3 stars 1 forks source link

Unable to Unmarshall Device.RegisteredOwnerInfo.Identifier #121

Closed ramirezj closed 6 months ago

ramirezj commented 6 months ago

Describe the bug Reported via MacAdmins Slack, running the following query with a Kolide Device Trust API key returned an error response:

select
  name,
  hardware_model,
  serial
from
  kolide_device;

Error reported:

Error: kolide: failed to retrieve collection at /devices/ with response: "json: cannot unmarshal number into Go struct field RegisteredOwner.data.registered_owner_info.identifier of type string" (SQLSTATE HV000)

Steampipe version (steampipe -v) v0.22.2

Plugin version (steampipe plugin list) v0.3.0

To reproduce Run the query provided with a non-K2 API key

Expected behavior Successful execution and return of reasonable results

Additional context Executing the equivalent API call yielded the following sanitised results

{
  "data": [
    {
      "id": "1234",
      "name": "johndoe",
      "registered_at": "2023-05-31T12:44:21.728Z",
      "last_authenticated_at": "2024-04-26T19:14:41.099Z",
      "registered_owner_info": {
        "identifier": 123456,
        "link": "https://api.kolide.com/people/123456"
      },
      "operating_system": "macOS 14.4.1 Sonoma",
      "hardware_model": "MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)",
      "serial": "redacted",
      "hardware_uuid": "redacted",
      "note": null,
      "auth_state": "Good",
      "will_block_at": null,
      "product_image_url": "https://assets1.kolide.com/assets/inventory/devices/MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)-88add75f01cbfa1825122278096e27106bdf41ca.png",
      "auth_configuration": {
        "device_id": "1234",
        "authentication_mode": "only_registered_owner",
        "person_groups": []
      },
      "device_type": "Mac",
      "form_factor": "computer"
    }
  ]
}
ramirezj commented 6 months ago

Debugging with the reporter showed several fixes needed in the code, the most interesting being that Device.RegisteredOwnerInfo.Identifier returns an integer not a string