mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #37182 # Details The `policy_membership` table records pass/fail status for each (host, policy) tuple where the policy targets that host and has run at least once on the host. It's used to get the # of failing policies for a host, for the Fleet Desktop icon menu as well as the Policies badge on the host details page. When a policy changes materially (e.g. the query changed) we wipe all of the `policy_membership` records for it, and if the `platform` changes we _selectively_ wiped records for hosts that no longer met the platform requirements. This PR adds logic to selectively wipe records for hosts that no longer meet _label_ requirements when those requirements change. This fixes issues where a policy would change which labels it applied to, but hosts that weren't members of the new label set would still show failures for that policy when clicking the Fleet Desktop icon. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [X] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) ## Testing - [X] Added/updated automated tests - [X] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [X] QA'd all new/changed functionality manually |
||
|---|---|---|
| .. | ||
| cached_mysql | ||
| failing | ||
| filesystem | ||
| mysql | ||
| mysqlredis | ||
| redis | ||
| s3 | ||