fleet/changes
Lucas Manuel Rodriguez feb4e65be6
Optimize macOS CIS query 5.1.5 (#12506)
#10292

The query was processing *every* file under `/Applications/`, which
makes it super expensive both in CPU usage and Memory footprint. This
query was the main culprit of triggering worker process kills by the
watchdog.

On some runs it triggered CPU usage alerts:
```
7716:W0623 15:38:05.402959 221732864 watcher.cpp:415] osqueryd worker (72976) stopping:
Maximum sustainable CPU utilization limit 1200ms exceeded for 12 seconds
```
And on other runs it triggered memory usage alerts:
```
4431 W0626 07:28:50.868021 147312640 watcher.cpp:424] osqueryd worker (21453) stopping:
Memory limits exceeded: 214020096 bytes (limit is 200MB)
```

For the above logs I used a custom osqueryd branch to be able to print
more information: https://github.com/osquery/osquery/pull/8070

The metrics for the old query were CPU usage: ~4521 ms
```
435:level=warn ts=2023-06-26T09:58:29.665712Z query=fleet_policy_query_1233 queryTime=4521 memory=12226560 msg="distributed query performance is excessive" hostID=308 platform=darwin
```
With the new query, CPU usage: ~210 ms.
```
23893:level=debug ts=2023-06-26T18:06:08.242456Z query=fleet_policy_query_1233 queryTime=210 msg=stats memory=0 hostID=308 platform=darwin
```
Basically a ~20x improvement.

- [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~
- ~[ ] 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.~
- ~[ ] Added/updated tests~
- [X] Manual QA for all new/changed functionality
  - For Orbit and Fleet Desktop changes:
- ~[ ] 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-06-27 11:06:26 -03:00
..
.keep Issue 1009 calculate diff software (#1305) 2021-07-08 13:57:43 -03:00
10292-optimize-macos-cis-query-5.1.5 Optimize macOS CIS query 5.1.5 (#12506) 2023-06-27 11:06:26 -03:00
11037-privacy_preferences-chromeos-table ChromeOS privacy_preferences table (#12441) 2023-06-23 14:52:16 -07:00
11655-hide-osquery-table-info Fleet UI: Hiding tables and columns from the UI if they are set to hidden (#12298) 2023-06-16 11:38:52 -04:00
12310-setup-styling Fleet UI: [Released styling bug] Fix setup icon pushed off setup steps (#12318) 2023-06-14 08:52:31 -04:00
12368-copy-message Fleet UI: [tiny bug] Copy message (#12411) 2023-06-21 09:14:47 -04:00
bug-2642-fix-msrc-error Don't analyze non-windows OS using the MSRC scanner (#12421) 2023-06-21 14:19:55 -04:00
bug-2790-return-proper-status-code When authorizing users on the PolicySpec endpoint, return proper status code if team not found (#12335) 2023-06-15 12:46:54 -04:00
bug-2888-return-proper-status-code-if-smtp-invalid Return proper status code if SMTP conf is invalid (#12389) 2023-06-21 14:40:26 -04:00
bug-2888-validate-metadataurl SSO Metadata URL can only be https/http (#12388) 2023-06-22 08:17:37 -04:00
bug-10720-ratelimits-should-return-proper-status-code If the fleet/forgot_password endpoint is rate limited, it should return the proper status code (#12323) 2023-06-15 15:41:04 -04:00
bug-10867-output-warns-to-stdout Warnings in fleetctl should use Stderr not Stdout (#12316) 2023-06-15 13:13:41 -04:00
bug-11636-vuln-dropdown Fleet UI: [tiny bug] See software search and vuln dropdown when no vuln software (#12412) 2023-06-21 09:15:25 -04:00
bug-12108-weird-scroll-behavior Fleet UI: [tiny bug] Fix weird scroll behavior (#12435) 2023-06-22 08:24:57 -07:00
bug-12308-sandbox-software-image Fleet UI: Empty software SVG update (effort to fix broken image in Sandbox) (#12378) 2023-06-19 15:41:04 -04:00
bug-12332-dashboard-loading-state Fleet UI: Clean up dashboard loading state (#12395) 2023-06-19 12:08:33 -04:00
bug-12394-variable-fleet-url Fleet UI: Variable Fleet URL for ChromeOS extension (#12393) 2023-06-19 11:28:11 -04:00
bug-add-mdm-feature-flag-in-modify-appconfig Add mdm_enabled field to response of PATCH /config (#12498) 2023-06-26 09:16:42 -04:00
issue-11861-filevault-key Create new Fleet osquery extension table to read escrowed FileVault key (#12198) 2023-06-15 10:23:59 -05:00
issue-11932-improve-abm-400-error add better messaging for ABM 400 error (#12425) 2023-06-22 15:08:21 +01:00
issue-11952-UI-for-windows-mdm-on-off turn on/off windows mdm from the fleet UI (#12497) 2023-06-26 17:54:34 +01:00
issue-12129-activity-transferred-hosts Add a transferred_hosts activity when hosts are transferred to a new team (#12287) 2023-06-14 08:15:05 -04:00
issue-12257-windows-mdm-feature-flag Add Windows MDM feature flag environment variable (#12306) 2023-06-14 08:44:42 -04:00
issue-12259-windows-mdm-settings Add support to configure and enable Windows MDM, notify elegible hosts (#12340) 2023-06-20 14:06:45 -04:00
issue-12260-trigger-windows-mdm-enrollment Trigger Windows MDM host enrollment on device when notified that it is enabled (#12426) 2023-06-26 12:13:17 -04:00
issue-12261-microsoft-mdm-discovery-endpoint Pushing initial support for MS-MDE2 Discovery message (#12387) 2023-06-22 17:31:17 -03:00
issue-12297-ui-transferred-hosts-activity Add transferred hosts to activity feed UI (#12442) 2023-06-22 11:01:42 -05:00
issue-12330-mdm-verification-failed Mark "verifying" or "verified" MDM profiles as "failed" if osquery cannot confirm they are installed (#12414) 2023-06-21 13:00:49 -05:00
issue-12392-use-primary Add mechanism to force read from primary DB, use it for puppet matching (#12396) 2023-06-19 13:55:15 -04:00
provide-feedback-fleetctl-login-when-using-env-vars Provide feedback to user in fleetctl login when using env vars (#12371) 2023-06-16 11:42:04 -03:00