fleet/cmd/fleetctl
Lucas Manuel Rodriguez 3757aace08
Add UUID to Fleet errors and clean up error msgs (#10411)
#8129 

Apart from fixing the issue in #8129, this change also introduces UUIDs
to Fleet errors. To be able to match a returned error from the API to a
error in the Fleet logs. See
https://fleetdm.slack.com/archives/C019WG4GH0A/p1677780622769939 for
more context.

Samples with the changes in this PR:
```
curl -k -H "Authorization: Bearer $TEST_TOKEN" -H 'Content-Type:application/json' "https://localhost:8080/api/v1/fleet/sso" -d ''
{
  "message": "Bad request",
  "errors": [
    {
      "name": "base",
      "reason": "Expected JSON Body"
    }
  ],
  "uuid": "a01f6e10-354c-4ff0-b96e-1f64adb500b0"
}
```
```
curl -k -H "Authorization: Bearer $TEST_TOKEN" -H 'Content-Type:application/json' "https://localhost:8080/api/v1/fleet/sso" -d 'asd'
{
  "message": "Bad request",
  "errors": [
    {
      "name": "base",
      "reason": "json decoder error"
    }
  ],
  "uuid": "5f716a64-7550-464b-a1dd-e6a505a9f89d"
}
```
```
curl -k -X GET -H "Authorization: Bearer badtoken" "https://localhost:8080/api/latest/fleet/teams"
{
  "message": "Authentication required",
  "errors": [
    {
      "name": "base",
      "reason": "Authentication required"
    }
  ],
  "uuid": "efe45bc0-f956-4bf9-ba4f-aa9020a9aaaf"
}
```
```
curl -k -X PATCH -H "Authorization: Bearer $TEST_TOKEN" "https://localhost:8080/api/latest/fleet/users/14" -d '{"name": "Manuel2", "password": "what", "new_password": "p4ssw0rd.12345"}'
{
  "message": "Authorization header required",
  "errors": [
    {
      "name": "base",
      "reason": "Authorization header required"
    }
  ],
  "uuid": "57f78cd0-4559-464f-9df7-36c9ef7c89b3"
}
```
```
curl -k -X PATCH -H "Authorization: Bearer $TEST_TOKEN" "https://localhost:8080/api/latest/fleet/users/14" -d '{"name": "Manuel2", "password": "what", "new_password": "p4ssw0rd.12345"}'
{
  "message": "Permission Denied",
  "uuid": "7f0220ad-6de7-4faf-8b6c-8d7ff9d2ca06"
}
```

- [X] Changes file added for user-visible changes in `changes/` or
`orbit/changes/`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [X] Documented any API changes (docs/Using-Fleet/REST-API.md or
docs/Contributing/API-for-contributors.md)
- ~[ ] Documented any permissions changes~
- ~[ ] 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
  - For Orbit and Fleet Desktop changes:
- [X] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- ~[ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).~
2023-03-13 13:44:06 -03:00
..
testdata Add disk_encryption option to config and team YAML (#10185) 2023-02-28 15:34:46 -05:00
api.go Flag when the Apple BM terms have expired (#9091) 2023-01-06 17:44:20 -03:00
apple_mdm.go Add endpoint to trigger CSR request for APNs on fleetdm.com (#9494) 2023-01-25 14:44:29 -05:00
apple_mdm_test.go return 422 status code if fleetdm.com returns any 4xx status for CSR (#9610) 2023-02-01 12:50:22 -03:00
apply.go Workaround to set policy specs on a team (#9978) 2023-02-22 13:14:53 -03:00
apply_test.go Add UUID to Fleet errors and clean up error msgs (#10411) 2023-03-13 13:44:06 -03:00
config.go Add support for custom headers in fleetctl (#6118) 2022-06-07 16:00:09 -04:00
config_test.go Enable errcheck linter for golangci-lint (#8899) 2022-12-05 16:50:49 -06:00
convert.go Move specs parsing functionality to a new pkg/spec package (#7050) 2022-08-05 19:07:32 -03:00
convert_test.go Fix error writing coverage when running tests (#10278) 2023-03-02 17:11:15 -08:00
debug.go fix fleetctl debug commands on Windows (#6186) 2022-06-10 21:59:44 -03:00
debug_test.go Fleet server and tooling to use NETWORK_TEST_GITHUB_TOKEN when environment variable is set. (#9143) 2023-01-03 14:56:11 -03:00
delete.go Move specs parsing functionality to a new pkg/spec package (#7050) 2022-08-05 19:07:32 -03:00
delete_test.go Make activities typed and auto-generate docs for each type (#9069) 2022-12-23 13:05:16 -03:00
flags.go improve messaging of fleetctl debug errors and archive commands (#5590) 2022-05-10 10:44:06 -03:00
fleetctl.go Add fleetctl generate mdm-apple (#8812) 2022-12-07 18:24:42 +01:00
get.go Make fleetctl get teams --yaml output compatible with fleetctl apply -f (#9626) 2023-02-02 14:46:50 -03:00
get_test.go Add disk_encryption option to config and team YAML (#10185) 2023-02-28 15:34:46 -05:00
goquery.go Use new error handling approach in other packages (#2954) 2021-11-22 09:13:26 -05:00
hosts.go Use new error handling approach in other packages (#2954) 2021-11-22 09:13:26 -05:00
hosts_test.go
kill_process.go Download and launch orbit for the current device when starting preview (#2437) 2021-10-15 18:23:06 -03:00
kill_process_windows.go Download and launch orbit for the current device when starting preview (#2437) 2021-10-15 18:23:06 -03:00
login.go Tweak output for fleetctl login --help (#4776) 2022-03-23 16:40:16 -04:00
logout.go Use new error handling approach in other packages (#2954) 2021-11-22 09:13:26 -05:00
logout_test.go Simplify fleetctl implementation and improve testing (#3830) 2022-01-24 16:40:51 -03:00
package.go Enable errcheck linter for golangci-lint (#8899) 2022-12-05 16:50:49 -06:00
package_test.go Add display_name to more results (#8204) 2022-10-14 11:14:18 -03:00
preview.go Add macos custom profiles support via fleetctl apply (#9824) 2023-02-15 13:01:44 -05:00
preview_test.go Enable errcheck linter for golangci-lint (#8899) 2022-12-05 16:50:49 -06:00
query.go fleetctl query improve error message (#5141) 2022-04-20 11:35:46 -06:00
query_output.go add host_display_name to live query rows (#8251) 2022-10-17 15:52:25 +02:00
query_test.go Make activities typed and auto-generate docs for each type (#9069) 2022-12-23 13:05:16 -03:00
session_test.go Print version warning when using fleetctl (#4139) 2022-02-14 09:43:34 -07:00
setup.go Fleet Premium: de-anonymize usage stats (#7013) 2022-08-03 14:44:34 -04:00
testing_utils.go Deep-clone the appconfig when getting from cache (#8194) 2022-10-17 15:03:49 -04:00
trigger.go Add fleetctl trigger command (#8877) 2022-12-06 09:56:54 -06:00
trigger_test.go Fix error writing coverage when running tests (#10278) 2023-03-02 17:11:15 -08:00
user.go Create Bulk Users from CSV (#3372) 2022-06-22 13:34:58 -03:00
users_test.go Make activities typed and auto-generate docs for each type (#9069) 2022-12-23 13:05:16 -03:00
vulnerability_data_stream.go Feature 9386: Parse the Mac Office release notes for vulnerability processing (#9993) 2023-02-24 14:18:25 -04:00
vulnerability_data_stream_test.go Feature 9386: Parse the Mac Office release notes for vulnerability processing (#9993) 2023-02-24 14:18:25 -04:00