From f5ca50a340ad123581bdfdcd162f6f82b3e99969 Mon Sep 17 00:00:00 2001 From: Ian Littman Date: Mon, 24 Feb 2025 16:38:57 -0600 Subject: [PATCH] Always record uploaded pkg files as "apps" source if they have a bundle ID to avoid conflicts with the same package appearing in inventory later (#26374) For #26373. # 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/Committing-Changes.md#changes-files) for more information. - [x] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it) - [x] Manual QA for all new/changed functionality Autoated tests cover the code in the changes. --- changes/26373-uploaded-pkg-source | 1 + ee/server/service/software_installers.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changes/26373-uploaded-pkg-source diff --git a/changes/26373-uploaded-pkg-source b/changes/26373-uploaded-pkg-source new file mode 100644 index 0000000000..fa6fd3166d --- /dev/null +++ b/changes/26373-uploaded-pkg-source @@ -0,0 +1 @@ +* Fixed a bug where uploading a macOS installer could prevent the software from being inventoried. diff --git a/ee/server/service/software_installers.go b/ee/server/service/software_installers.go index 81a9bcf825..18b18f72cc 100644 --- a/ee/server/service/software_installers.go +++ b/ee/server/service/software_installers.go @@ -1409,11 +1409,15 @@ func (svc *Service) addMetadataToSoftwarePayload(ctx context.Context, payload *f payload.UninstallScript = file.GetUninstallScript(meta.Extension) } - source, err := fleet.SofwareInstallerSourceFromExtensionAndName(meta.Extension, meta.Name) - if err != nil { - return "", ctxerr.Wrap(ctx, err, "determining source from extension and name") + if payload.BundleIdentifier != "" { + payload.Source = "apps" + } else { + source, err := fleet.SofwareInstallerSourceFromExtensionAndName(meta.Extension, meta.Name) + if err != nil { + return "", ctxerr.Wrap(ctx, err, "determining source from extension and name") + } + payload.Source = source } - payload.Source = source platform, err := fleet.SofwareInstallerPlatformFromExtension(meta.Extension) if err != nil {