Skip to content

Commit fa46cfb

Browse files
jahzielvRoberto Dip
andauthored
fix: filter out software from parallels vm (#16520)
> Related issue: #15855 I followed a similar pattern to `sanitizeSoftware`, a function that modifies the `Software`. I was originally going to update `sanitizeSoftware` itself, but decided against it 1. to avoid making lots of changes to the function signature and internals 2. because the logic this issue requires is pretty different from what `sanitizeSoftware` is trying to do, so seemed to warrant its own function. # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [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. - [x] Added/updated tests - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Roberto Dip <[email protected]>
1 parent 9069850 commit fa46cfb

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

changes/15855-vm-software

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Fixes issue where software from a Parallels VM on a MacOS host would show up in Fleet as if it
2+
were the host's software.

server/service/osquery_utils/queries.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,10 @@ func directIngestSoftware(ctx context.Context, logger log.Logger, host *fleet.Ho
12671267

12681268
sanitizeSoftware(host, s, logger)
12691269

1270+
if shouldRemoveSoftware(host, s) {
1271+
continue
1272+
}
1273+
12701274
software = append(software, *s)
12711275

12721276
installedPath := strings.TrimSpace(row["installed_path"])
@@ -1394,6 +1398,16 @@ func sanitizeSoftware(h *fleet.Host, s *fleet.Software, logger log.Logger) {
13941398
}
13951399
}
13961400

1401+
// shouldRemoveSoftware returns whether or not we should remove the given Software item from this
1402+
// host's software list.
1403+
func shouldRemoveSoftware(h *fleet.Host, s *fleet.Software) bool {
1404+
// Parallels is a common VM software for MacOS. Parallels makes the VM's applications
1405+
// visible in the host as MacOS applications, which leads to confusing output (e.g. a MacOS
1406+
// host reporting that it has Notepad installed when this is just an app from the Windows VM
1407+
// under Parallels). We want to filter out those "applications" to avoid confusion.
1408+
return h.Platform == "darwin" && strings.HasPrefix(s.BundleIdentifier, "com.parallels.winapp")
1409+
}
1410+
13971411
func directIngestUsers(ctx context.Context, logger log.Logger, host *fleet.Host, ds fleet.Datastore, rows []map[string]string) error {
13981412
var users []fleet.HostUser
13991413
for _, row := range rows {

server/service/osquery_utils/queries_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,3 +1747,30 @@ func TestDirectIngestWindowsProfiles(t *testing.T) {
17471747
}
17481748
}
17491749
}
1750+
1751+
func TestShouldRemoveSoftware(t *testing.T) {
1752+
tests := []struct {
1753+
name string
1754+
want bool
1755+
s *fleet.Software
1756+
h *fleet.Host
1757+
}{
1758+
{
1759+
name: "parallels windows software on MacOS host",
1760+
want: true,
1761+
h: &fleet.Host{Platform: "darwin"},
1762+
s: &fleet.Software{BundleIdentifier: "com.parallels.winapp.notepad", Name: "Notepad.app"},
1763+
},
1764+
{
1765+
name: "regular macos software",
1766+
want: false,
1767+
h: &fleet.Host{Platform: "darwin"},
1768+
s: &fleet.Software{BundleIdentifier: "com.apple.dock", Name: "Dock.app"},
1769+
},
1770+
}
1771+
for _, tt := range tests {
1772+
t.Run(tt.name, func(t *testing.T) {
1773+
require.Equal(t, tt.want, shouldRemoveSoftware(tt.h, tt.s))
1774+
})
1775+
}
1776+
}

0 commit comments

Comments
 (0)