fleet/server/datastore/mysql
Lucas Manuel Rodriguez 5ec4fab440
Orbit to set --database_path when invoking osquery to retrieve system info (#10308)
#9132

The actual fix for the empty hosts is adding the `--database_path`
argument in the initial `osqueryd -S` invocation when retrieving the
UUID. Osquery attempts to retrieve the UUID from OS files/APIs, when not
possible (which is what happens on some linux distributions), then it
resorts to generating a new random UUID and storing it in the
`osquery.db`. The issue was Orbit's first invocation of `osqueryd -S`
was not using the same `osquery.db` as the main daemon invocation of
`osqueryd`.

I'm also adding a `hostname` + `platform` to the orbit enroll phase so
that if there are any issues in the future we can avoid the "empty" host
and have some information to help us troubleshoot.

## How to reproduce

On Linux, osquery reads `/sys/class/dmi/id/product_uuid` to load the
hardware UUID.
Some Linux distributions running on specific hardware or container
environments do not have such file available.
The way to reproduce on a Linux VM is to do the following:
```sh
$ sudo su
# chmod -r /sys/class/dmi/id/product_uuid
```
which will turn the file inaccessible to root.

## Checklist

- [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.
- ~[ ] Documented any API changes (docs/Using-Fleet/REST-API.md or
docs/Contributing/API-for-contributors.md)~
- ~[ ] Documented any permissions changes~
- [X] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [X] 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.
- [x] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
2023-03-13 18:54:18 -03:00
..
migrations add schema tables to support DEP Okta flow (#10290) 2023-03-07 10:57:26 -03:00
activities.go add attribute to GET /activities endpoint with pagination metadata (#9279) 2023-01-18 12:57:11 +00:00
activities_test.go add attribute to GET /activities endpoint with pagination metadata (#9279) 2023-01-18 12:57:11 +00:00
aggregated_stats.go Issue 3173 debug status processlist (#4009) 2022-02-03 14:56:22 -03:00
aggregated_stats_test.go Replace uses of ansi quotes (") in SQL statements (#4726) 2022-04-11 11:47:50 -07:00
app_configs.go Keep created_at timestamp of existing enroll secrets (#8062) 2022-10-05 08:35:36 -04:00
app_configs_test.go Keep created_at timestamp of existing enroll secrets (#8062) 2022-10-05 08:35:36 -04:00
apple_mdm.go allow to set up a DEP flow gated by Okta auth (#10338) 2023-03-13 10:33:32 -03:00
apple_mdm_test.go allow to set up a DEP flow gated by Okta auth (#10338) 2023-03-13 10:33:32 -03:00
campaigns.go Issue 3173 debug status processlist (#4009) 2022-02-03 14:56:22 -03:00
campaigns_test.go Improve performance of the Go test suite (#2060) 2021-09-20 14:09:38 -04:00
carves.go add attribute to GET /activities endpoint with pagination metadata (#9279) 2023-01-18 12:57:11 +00:00
carves_test.go Improve performance of the Go test suite (#2060) 2021-09-20 14:09:38 -04:00
config.go Fix double quote usage in sql query (#6707) 2022-07-20 10:10:03 -06:00
cron_stats.go Run cleanup of cron_stats outside of the schedule package to prevent outages from breaking cron jobs (#10439) 2023-03-13 16:15:30 -03:00
cron_stats_test.go Adjust max age for cron stats entries (#9190) 2023-01-16 10:23:52 -06:00
delete.go Issue 3173 debug status processlist (#4009) 2022-02-03 14:56:22 -03:00
delete_test.go Ingest pending MDM hosts (#9065) 2022-12-26 15:32:39 -06:00
email_changes.go Create errors with ctxerr, add the call to store them in redis (#2786) 2021-11-15 09:11:38 -05:00
email_changes_test.go Improve performance of the Go test suite (#2060) 2021-09-20 14:09:38 -04:00
errors.go Add UUID to Fleet errors and clean up error msgs (#10411) 2023-03-13 13:44:06 -03:00
fulltext.go Using '@' in target search causes 422 error response (#5148) 2022-04-19 09:28:49 -04:00
fulltext_test.go Using '@' in target search causes 422 error response (#5148) 2022-04-19 09:28:49 -04:00
hosts.go Orbit to set --database_path when invoking osquery to retrieve system info (#10308) 2023-03-13 18:54:18 -03:00
hosts_test.go Orbit to set --database_path when invoking osquery to retrieve system info (#10308) 2023-03-13 18:54:18 -03:00
invites.go add attribute to GET /activities endpoint with pagination metadata (#9279) 2023-01-18 12:57:11 +00:00
invites_test.go Create errors with ctxerr, add the call to store them in redis (#2786) 2021-11-15 09:11:38 -05:00
jobs.go Queue jobs for Jira integration when enabled and new vulnerabilities are found. (#4975) 2022-04-11 16:42:16 -04:00
labels.go Update API responses for hosts and labels endpoints to include host mdm info (#10141) 2023-02-27 18:40:34 -03:00
labels_test.go Support matching a host in orbit enrollment using the serial number (#9612) 2023-02-28 12:55:04 -05:00
locks.go Add holdLock and releaseLock methods to schedule package (#8464) 2022-11-16 15:14:38 -06:00
locks_test.go Enable errcheck linter for golangci-lint (#8899) 2022-12-05 16:50:49 -06:00
migrations_test.go Enable errcheck linter for golangci-lint (#8899) 2022-12-05 16:50:49 -06:00
mysql.go add mocks + tests and move things around (#9574) 2023-01-31 11:46:01 -03:00
mysql_test.go Fix server URL for hosts enrolled in Fleet MDM (#9952) 2023-02-20 12:16:56 -05:00
operating_system_vulnerabilities.go Feature 7494: Use the MSRC security bulletin artifacts for detecting Win OS vulnerabilities (#7889) 2022-10-28 11:12:21 -04:00
operating_system_vulnerabilities_test.go Feature 7494: Use the MSRC security bulletin artifacts for detecting Win OS vulnerabilities (#7889) 2022-10-28 11:12:21 -04:00
operating_systems.go Use tx instead of writer within withTx style code to prevent deadlocks (#8554) 2022-11-03 10:57:50 -03:00
operating_systems_test.go Ingest pending MDM hosts (#9065) 2022-12-26 15:32:39 -06:00
packs.go add attribute to GET /activities endpoint with pagination metadata (#9279) 2023-01-18 12:57:11 +00:00
packs_test.go Ingest pending MDM hosts (#9065) 2022-12-26 15:32:39 -06:00
password_reset.go Fix password reset request expiration (#8246) 2022-10-25 09:46:41 -05:00
password_reset_test.go Fix password reset request expiration (#8246) 2022-10-25 09:46:41 -05:00
policies.go Improve logging to detect unrecognized platforms (#10423) 2023-03-13 10:06:39 -03:00
policies_test.go Support matching a host in orbit enrollment using the serial number (#9612) 2023-02-28 12:55:04 -05:00
queries.go add attribute to GET /activities endpoint with pagination metadata (#9279) 2023-01-18 12:57:11 +00:00
queries_test.go Improve live query UX (#5749) 2022-06-10 13:29:45 -05:00
scep.go add mocks + tests and move things around (#9574) 2023-01-31 11:46:01 -03:00
scep_test.go add mocks + tests and move things around (#9574) 2023-01-31 11:46:01 -03:00
scheduled_queries.go add attribute to GET /activities endpoint with pagination metadata (#9279) 2023-01-18 12:57:11 +00:00
scheduled_queries_test.go Support async saving of scheduled query statistics (#7012) 2022-08-10 10:01:05 -04:00
schema.sql add schema tables to support DEP Okta flow (#10290) 2023-03-07 10:57:26 -03:00
sessions.go Add read replica testing helpers and fix non-sso login bug (#4908) 2022-04-04 16:52:05 -07:00
sessions_test.go Add read replica testing helpers and fix non-sso login bug (#4908) 2022-04-04 16:52:05 -07:00
software.go Feature 9386: Parse the Mac Office release notes for vulnerability processing (#9993) 2023-02-24 14:18:25 -04:00
software_test.go Feature 9386: Parse the Mac Office release notes for vulnerability processing (#9993) 2023-02-24 14:18:25 -04:00
statistics.go Enable errcheck linter for golangci-lint (#8899) 2022-12-05 16:50:49 -06:00
statistics_test.go Ingest pending MDM hosts (#9065) 2022-12-26 15:32:39 -06:00
targets.go Update live query selector logic (OR -> AND) (#9559) 2023-01-30 18:35:56 -03:00
targets_test.go Support matching a host in orbit enrollment using the serial number (#9612) 2023-02-28 12:55:04 -05:00
teams.go Add macos custom profiles support via fleetctl apply (#9824) 2023-02-15 13:01:44 -05:00
teams_test.go create and send Nudge configuration to hosts (#9491) 2023-01-25 17:03:40 -03:00
testing_utils.go add a cron job to reconcile profiles (#9946) 2023-02-22 14:49:06 -03:00
unicode_test.go Remove skipLoadingExtras and includeCVEScores from GetHost and HostByIdentifier methods (#5874) 2022-05-25 11:30:03 -05:00
users.go add attribute to GET /activities endpoint with pagination metadata (#9279) 2023-01-18 12:57:11 +00:00
users_test.go Add AvailableTeams to loginResponse and getUserResponse (#3585) 2022-01-13 13:57:44 -06:00
windows_updates.go Feature 7494: Use the MSRC security bulletin artifacts for detecting Win OS vulnerabilities (#7889) 2022-10-28 11:12:21 -04:00
windows_updates_test.go Feature 7494: Use the MSRC security bulletin artifacts for detecting Win OS vulnerabilities (#7889) 2022-10-28 11:12:21 -04:00