fleet/server/datastore/mysql
Jonathan Katz 0d15fd6cd6
Override patch policy query (#42322)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**Related issue:** Resolves #41815
### Changes
- Extracted patch policy creation to `pkg/patch_policy`
- Added a `patch_query` column to the `software_installers` table
- By default that column is empty, and patch policies will generate with
the default query if so
- On app manifest ingestion, the appropriate entry in
`software_installers` will save the override "patch" query from the
manifest in patch_query

# 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.

- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements), JS
inline code is prevented especially for url redirects, and untrusted
data interpolated into shell scripts/commands is validated against shell
metacharacters.
- [ ] If paths of existing endpoints are modified without backwards
compatibility, checked the frontend/CLI for any necessary changes

## Testing

- [x] Added/updated automated tests
- [ ] 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)

- [ ] QA'd all new/changed functionality manually
- Relied on integration test for FMA version pinning

## Database migrations

- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [x] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
2026-03-25 10:32:41 -04:00
..
migrations Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
rdsauth slog migration: platform/mysql and related logic (#40072) 2026-02-19 08:27:24 -06:00
testdata Fixed dead rows accumulating in software host counts tables (#40288) 2026-02-24 15:35:02 -06:00
activities.go Don't clear past lock/wipe (#41504) 2026-03-13 15:21:24 -05:00
activities_test.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
aggregated_stats.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
aggregated_stats_test.go Performance stats for live queries (#15440) 2023-12-13 14:46:59 -06:00
android.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_device_test.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_enterprise_test.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_enterprises.go Moved common_mysql package to server/platform/mysql (#38017) 2026-01-08 13:17:19 -06:00
android_hosts.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_mysql.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
android_test.go Only reverify Android profiles if they failed due to non-compliance (#39645) 2026-02-10 16:50:22 -05:00
app_configs.go Fix: incorrect timestamps returned for Label and Team creation (#38846) 2026-01-27 18:02:48 -03:00
app_configs_test.go Use lighter Team call when it's obviously safe to do so, comment potential areas for further improvement (#35587) 2025-11-17 17:25:45 -06:00
apple_mdm.go SHAA: host dep details API (#42250) 2026-03-24 09:49:26 -04:00
apple_mdm_ddm_test.go Updated SQL modes in tests to match production. (#31445) 2025-08-03 08:18:13 +02:00
apple_mdm_test.go SHAA: host dep details API (#42250) 2026-03-24 09:49:26 -04:00
ca_config_assets.go Add custom SCEP configs (#27045) 2025-03-14 12:16:51 -05:00
ca_config_assets_test.go Add custom SCEP configs (#27045) 2025-03-14 12:16:51 -05:00
calendar_events.go Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
calendar_events_test.go Handle null HostID on calendar webhook endpoint (#30130) 2025-06-23 13:10:10 -04:00
campaigns.go Add CleanupCompletedCampaignTargets to cleanup old campaign targets. (#32385) 2025-08-28 11:04:05 -05:00
campaigns_test.go Add CleanupCompletedCampaignTargets to cleanup old campaign targets. (#32385) 2025-08-28 11:04:05 -05:00
carves.go Authenticate carve block endpoint before parsing the "data" field (#39353) 2026-02-05 15:55:03 -03:00
carves_test.go Improve performance of the Go test suite (#2060) 2021-09-20 14:09:38 -04:00
certificate_authorities.go Fixed GitOps failing to delete a certificate authority (#41693) 2026-03-16 15:51:28 -05:00
certificate_authorities_test.go Fixed GitOps failing to delete a certificate authority (#41693) 2026-03-16 15:51:28 -05:00
certificate_templates.go 41542 android cert resend backend (#42099) 2026-03-23 17:01:52 -04:00
certificate_templates_test.go 41542 android cert resend backend (#42099) 2026-03-23 17:01:52 -04:00
challenges.go Fixed Android certificate enrollment failures caused by SCEP challenge expiration when devices were offline. (#38753) 2026-01-28 10:33:37 -06:00
conditional_access_bypass.go Rework conditional access policy bypass conditions to use critical column (#40736) 2026-03-05 17:05:03 -05:00
conditional_access_bypass_test.go Rework conditional access policy bypass conditions to use critical column (#40736) 2026-03-05 17:05:03 -05:00
conditional_access_microsoft.go Changes to set compliance status on Entra on Windows hosts when processing policy results (#41903) 2026-03-18 12:57:49 -03:00
conditional_access_microsoft_test.go Changes to set compliance status on Entra on Windows hosts when processing policy results (#41903) 2026-03-18 12:57:49 -03:00
conditional_access_scep.go Okta IdP factor (#35143) 2025-11-07 16:19:25 -06:00
conditional_access_scep_test.go Okta IdP factor (#35143) 2025-11-07 16:19:25 -06:00
config.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
cron_stats.go Trigger vuln processing when it runs on a separate server (#39612) 2026-02-17 09:18:03 -06:00
cron_stats_test.go Fix issue with vuln jobs running in parallel. (#39806) 2026-02-16 13:59:40 -06:00
delete.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
delete_test.go Updated factory method for creating queries in tests 2023-07-07 09:05:51 -04:00
disk_encryption.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
disk_encryption_test.go Added new global activity when disk encryption key is escrowed (#31634) 2025-08-08 12:14:48 -04:00
email_changes.go Add mechanism to force read from primary DB, use it for puppet matching (#12396) 2023-06-19 13:55:15 -04:00
email_changes_test.go Improve performance of the Go test suite (#2060) 2021-09-20 14:09:38 -04:00
errors.go Fix software installer error team -> fleet (#41070) 2026-03-05 17:28:52 -06:00
errors_test.go Fix software installer error team -> fleet (#41070) 2026-03-05 17:28:52 -06:00
fulltext.go Update to Go 1.24.1 (#27506) 2025-03-31 11:14:09 -05:00
fulltext_test.go Using '@' in target search causes 422 error response (#5148) 2022-04-19 09:28:49 -04:00
host_certificate_templates.go Modified Android certificate renewal logic to make it easier to test. (#40635) 2026-03-02 16:25:48 -08:00
host_certificate_templates_test.go Modified Android certificate renewal logic to make it easier to test. (#40635) 2026-03-02 16:25:48 -08:00
host_certificates.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
host_certificates_test.go DCSW: Allow Windows profiles to hit SCEP Proxy (#35041) 2025-11-06 11:14:49 -03:00
host_identity_scep.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
host_identity_scep_test.go Fleet server verifies HTTP signature (#30825) 2025-07-16 20:08:27 +02:00
hosts.go SHAA: hosts summary and hosts filtering (#42149) 2026-03-20 16:26:14 -04:00
hosts_test.go SHAA: hosts summary and hosts filtering (#42149) 2026-03-20 16:26:14 -04:00
in_house_apps.go Backend: Support labels_include_all for installers/apps (#41324) 2026-03-18 13:27:53 -04:00
in_house_apps_test.go Move PostJSONWithTimeout to platform/http package and activity cleanup (#40561) 2026-02-26 17:39:10 -06:00
invites.go Order By Vulnerability (#40143) 2026-02-23 09:42:36 -07:00
invites_test.go Allow opting in users to email verification on login (#24273) 2024-12-05 08:37:10 -06:00
jobs.go Cancel batch execution API (#31757) 2025-08-11 15:17:57 -04:00
jobs_test.go Allow worker to filter queue by job type (#31556) 2025-08-06 17:22:48 -05:00
labels.go Allow hosts key to be empty for manual labels (#42022) 2026-03-20 10:36:14 -05:00
labels_test.go Allow hosts key to be empty for manual labels (#42022) 2026-03-20 10:36:14 -05:00
linux_mdm.go Linux OS settings + disk encryption host filter fixes (#24200) 2024-11-26 19:26:22 -06:00
linux_mdm_test.go Added new global activity when disk encryption key is escrowed (#31634) 2025-08-08 12:14:48 -04:00
locks.go Optimize software_titles query to use indexes (#25722) 2025-01-23 15:48:21 -03:00
locks_test.go Improvements for select next Apple MDM command query. (#24128) 2024-12-05 12:02:48 -06:00
maintained_apps.go Match Windows Fleet maintained apps by similar name (#40544) 2026-02-26 12:47:52 -05:00
maintained_apps_test.go Match Windows Fleet maintained apps by similar name (#40544) 2026-02-26 12:47:52 -05:00
mdm.go Log orphan MDM command references instead of returning 500 (#40877) 2026-03-09 09:54:14 -03:00
mdm_idp_accounts_test.go Add support for fully-managed android devices (#39388) 2026-02-06 10:46:25 -05:00
mdm_test.go Dismiss gosec G602 and G115 in test code (#40960) 2026-03-04 13:34:35 -05:00
microsoft_mdm.go Finishing mysql package migration to slog (#40350) 2026-02-24 16:52:36 -06:00
microsoft_mdm_test.go remove windows profile osquery verification (#40539) 2026-02-27 12:21:45 -05:00
migrations_test.go Moved common_mysql package to server/platform/mysql (#38017) 2026-01-08 13:17:19 -06:00
mysql.go Added OTEL DB stats metrics, renamed trace attributes to expected OTEL names (#42097) 2026-03-20 11:07:58 -05:00
mysql_test.go Follow-up changes to observer live query bypass (#41146) 2026-03-11 13:42:33 -03:00
nanomdm_storage.go Set recovery lock password - mdm commands (#41217) 2026-03-12 06:06:56 -06:00
nanomdm_storage_test.go slog migration: platform/mysql and related logic (#40072) 2026-02-19 08:27:24 -06:00
operating_system_vulnerabilities.go Use swap table pattern and batch delete to improve DB access patterns for vuln cron (#41729) 2026-03-17 10:34:52 -05:00
operating_system_vulnerabilities_batch_test.go os_versions endpoint performance improvements (#34897) 2025-11-03 13:07:44 -06:00
operating_system_vulnerabilities_test.go Use swap table pattern and batch delete to improve DB access patterns for vuln cron (#41729) 2026-03-17 10:34:52 -05:00
operating_systems.go Differentiate between Windows Server Core and full desktop installations (#42034) 2026-03-21 10:03:57 -05:00
operating_systems_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
packs.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
packs_test.go Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
password_reset.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
password_reset_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
policies.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
policies_test.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
queries.go Update backend error messages (#40364) 2026-02-25 13:54:45 -06:00
queries_test.go Show Manage Automations disabled button with tooltip on Queries page (#39302) 2026-02-09 15:16:28 -03:00
query_results.go [Host details > Reports] Frontend changes (#42017) 2026-03-24 10:45:34 -03:00
query_results_test.go New API endpoint for host reports (41534) 2026-03-18 11:03:48 -04:00
scep.go Add SCEP endpoint for host identity. (#30589) 2025-07-11 11:44:07 -03:00
scep_test.go Updated SQL modes in tests to match production. (#31445) 2025-08-03 08:18:13 +02:00
scheduled_queries.go Update backend error messages (#40364) 2026-02-25 13:54:45 -06:00
scheduled_queries_test.go Performance stats for live queries (#15440) 2023-12-13 14:46:59 -06:00
schema.sql Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
scim.go Surface correct HTTP status on SCIM data constraint errors (40260) (#41530) 2026-03-13 13:22:10 -04:00
scim_test.go Resend Windows profiles on IDP variables change (#37032) 2025-12-10 15:08:01 -04:00
scripts.go Add Python script support for macOS and Linux (#38562) 2026-03-24 10:01:54 -04:00
scripts_test.go Dismiss gosec G602 and G115 in test code (#40960) 2026-03-04 13:34:35 -05:00
secret_variables.go Rotate recovery lock password (#41833) 2026-03-17 16:28:25 -06:00
secret_variables_test.go Set recovery lock password - mdm commands (#41217) 2026-03-12 06:06:56 -06:00
sessions.go slog migration: initLogger + serve.go + cron + schedule (#40699) 2026-02-27 14:29:27 -06:00
sessions_test.go Include expiration info, drop "personalized", in MFA email (#24630) 2024-12-10 18:58:40 -06:00
setup_experience.go Bugfix: properly enqueue compatible setup experience items for arch/omarchy linux (#41778) 2026-03-17 15:04:33 -04:00
setup_experience_test.go Bugfix: properly enqueue compatible setup experience items for arch/omarchy linux (#41778) 2026-03-17 15:04:33 -04:00
software.go merge main 2026-03-18 14:49:08 -04:00
software_installers.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
software_installers_test.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
software_test.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
software_title_display_names.go Bugfix: use custom software title icon and display name in setup experience UI (#39223) 2026-02-03 14:56:16 -05:00
software_title_icons.go merge main 2026-03-18 14:49:08 -04:00
software_title_icons_test.go merge main 2026-03-18 14:49:08 -04:00
software_titles.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
software_titles_test.go Dismiss gosec G602 and G115 in test code (#40960) 2026-03-04 13:34:35 -05:00
software_upgrade_code_test.go Dismiss gosec G602 and G115 in test code (#40960) 2026-03-04 13:34:35 -05:00
statistics.go Add statistics for Entra conditional access (#41998) 2026-03-19 10:32:08 -03:00
statistics_test.go Override patch policy query (#42322) 2026-03-25 10:32:41 -04:00
targets.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
targets_test.go API + auth + UI changes for team labels (#37208) 2025-12-29 21:28:45 -06:00
teams.go Update backend error messages (#40364) 2026-02-25 13:54:45 -06:00
teams_test.go Add lock end user info migrations, API support and AccountConfiguration command updates (#40551) 2026-03-02 12:16:31 -05:00
testing_utils.go Move PostJSONWithTimeout to platform/http package and activity cleanup (#40561) 2026-02-26 17:39:10 -06:00
unicode_test.go Bugfix: only count hosts that user has permission to see in count field of label endpoints (#18859) 2024-05-21 12:02:08 -04:00
users.go Order By Vulnerability (#40143) 2026-02-23 09:42:36 -07:00
users_test.go Update backend error messages (#40364) 2026-02-25 13:54:45 -06:00
vpp.go merge main 2026-03-18 14:49:08 -04:00
vpp_test.go merge main 2026-03-18 14:49:08 -04:00
vulnerabilities.go Atomic vulnerability count calculations (#35317) 2025-11-12 13:09:34 -07:00
vulnerabilities_test.go Moved common_mysql package to server/platform/mysql (#38017) 2026-01-08 13:17:19 -06:00
windows_updates.go Add mechanism to force read from primary DB, use it for puppet matching (#12396) 2023-06-19 13:55:15 -04:00
windows_updates_test.go Updating golangci-lint to 1.61.0 (#22973) 2024-10-18 12:38:26 -05:00
wstep.go Add SCEP endpoint for host identity. (#30589) 2025-07-11 11:44:07 -03:00
wstep_test.go Move nanomdm dependency in monorepo (#16015) 2024-01-11 23:28:48 -03:00