Skip to content

Conversation

ksykulev
Copy link
Contributor

Back ported: #34097 to be compatible with the 4.70 release.
Original issue #28788

@ksykulev ksykulev requested a review from a team as a code owner October 15, 2025 01:08
@ksykulev ksykulev changed the title Adding name to software checksum for mac software (#34097) Cherry-pick: Adding name to software checksum for mac software Oct 15, 2025
**Related issue:** Resolves #28788

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)

- [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

- [x] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [x] 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`).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **Bug Fixes**
* macOS app checksums now include the app name, improving grouping,
deduplication, and preventing mis-linking or duplicate entries when
multiple names share a bundle ID.
* More stable title handling when bundle IDs are missing, reducing
unintended renames and mismatches.

* **Tests**
* Re-enabled related host-software tests and added a
longest-common-prefix test to validate name reconciliation.

* **Chores**
* Database migration added to recalculate checksums for affected macOS
app records.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Copy link

codecov bot commented Oct 15, 2025

Codecov Report

❌ Patch coverage is 87.03704% with 21 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (rc-patch-fleet-v4.74.1@05fd7e9). Learn more about missing BASE report.

Files with missing lines Patch % Lines
server/datastore/mysql/software.go 87.85% 11 Missing and 2 partials ⚠️
...51014191403_AddNameToSoftwareCheckumCalculation.go 84.90% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##             rc-patch-fleet-v4.74.1   #34235   +/-   ##
=========================================================
  Coverage                          ?   63.04%           
=========================================================
  Files                             ?     1335           
  Lines                             ?   181119           
  Branches                          ?        0           
=========================================================
  Hits                              ?   114180           
  Misses                            ?    56950           
  Partials                          ?     9989           
Flag Coverage Δ
backend 63.04% <87.03%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

key := titleKey{
bundleID: sw.BundleIdentifier,
source: sw.Source,
browser: sw.Browser,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is extensionFor in the original patch. Intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser was changed to extensionFor in this PR:
41c53860e3
So I need to reverse all those changes for 4.74.0.

Here is how the code looks like in 4.74.0
https://github.com/fleetdm/fleet/blob/rc-minor-fleet-v4.74.0/server/datastore/mysql/software.go#L875-L889

Thanks for calling this out! 👍


if _, exists := uniqueTitlesToInsert[key]; !exists {
uniqueTitlesToInsert[key] = title
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped a change of const numberOfArgsPerSoftwareTitles = 6 below from the original patch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what added an additional argument, but I looked in the 4.74.0 code.
https://github.com/fleetdm/fleet/blob/rc-minor-fleet-v4.74.0/server/datastore/mysql/software.go#L926

And it's only 5 args.
titlesValues := strings.TrimSuffix(strings.Repeat("(?,?,?,?,?),", len(uniqueTitlesToInsert)), ",")

👍

}
// Log cases where the new software has no last opened timestamp, the current software does,
// and the software is marked as having a name change.
if ok && curSw.LastOpenedAt != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped && newSw.Source != "apps" here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait i'm a little confused.
4.74.0 https://github.com/fleetdm/fleet/blob/rc-minor-fleet-v4.74.0/server/datastore/mysql/software.go#L1232C4-L1232C40

if ok && curSw.LastOpenedAt != nil {

The change was to get rid of ok and add newSw.Source != "apps".
So the new code looks like

if curSw.LastOpenedAt != nil && newSw.Source != "apps" {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops sorry was looking in the wrong direction -- the change is as you said, && newSw.Source != "apps" is added in this cherry pick but missing in the original patch, which sounds like it was intentional

Copy link
Contributor

@sgress454 sgress454 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 assuming the changes I pointed out from the original patch are known and intentional

@ksykulev ksykulev marked this pull request as draft October 15, 2025 19:51
@ksykulev
Copy link
Contributor Author

Keeping this in our back pocket in case 4.75.0 does not go well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants