Skip to content

fix(software): skip executables of listed programs, Windows components and uninstallers in the Program Files scan CU-17tkuw67w42 - #270

Merged
aliaska-varieva merged 4 commits into
mainfrom
fix/program-files-scan-duplicates
Nov 30, 2026
Merged

aliaska-varieva merged 4 commits into
mainfrom
fix/program-files-scan-duplicates

Conversation

@aliaska-varieva

@aliaska-varieva aliaska-varieva commented Nov 17, 2026 •

Copy link
Copy Markdown

Ticket: https://app.clickup.com/t/17tkuw67w42
Change-Set: fix-program-files-scan-duplicates

Problem

Windows hosts list dozens of bare executables (7z.exe, node.exe, iexplore.exe, MpCmdRun.exe, Uninstall.exe…) as software with source programs. They come from upstream's windows_program_files_scan (fleetdm#42992), which adds every .exe under C:\Program Files that isn't under a programs entry's install_location. Many uninstall entries have no install location, and Windows' own folders have no entry at all. On prod about 4,750 of 4,900 Windows hosts carry these rows, about 76 per host.

Fix

In processProgramFilesScan:

  • An exe is also a duplicate when a folder between Program Files and the exe has the name of a programs entry, compared in lowercase letters and digits without a trailing version or edition ("7-Zip" ↔ "7-Zip 26.06 (x64 edition)", "nodejs" ↔ "Node.js"). Exact match only, so Adobe\DNG Converter is still reported next to "Adobe Acrobat".
  • Executables in Windows component folders (Internet Explorer, Windows Defender, Windows Media Player, Windows Mail, Windows NT, and the Windows folders inside Common Files…) are skipped, except MsMpEng.exe, which stays the source of "Windows Defender".
  • Uninstallers (unins*.exe) are skipped.

Same change as the upstream PR. Fork edits are marked OPENFRAME(program-files-scan-duplicates) and can be dropped once upstream is synced. Rows already stored drop out at each host's next software refresh.

The Defender platform version fix (CU-17tkuw67fq5) changes the same function; whichever merges second needs a small rebase.

Testing

  • TestWindowsProgramFilesScan: three new cases (folder-name match for 7-Zip, Node.js and Git without install_location; DNG Converter still reported next to Adobe Acrobat; Windows component folders and uninstallers skipped with MsMpEng.exe kept). Two fail without the change.
  • go test ./server/service/osquery_utils/ passes.

Reference

Change set flamingo-stack/fix-program-files-scan-duplicates: this pull request is the only one in it so far. Another pull request joins by naming this one in a Depends-On line, or by carrying the same Change-Set line.

  • flamingo-stack/fleetmdm#270 (this pull request): fix(software): skip executables of listed programs, Windows components and uninstallers in the Program Files scan CU-17tkuw67w42 · landed

Linked work

Linked by the Depends-On / Change-Set lines in these descriptions; this block is maintained by the hub.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦩 Flamingo Code Review

❌ Tests and checks failed on this commit: tests (go test). What each printed is in the Tests and mutation section.

3 findings: 🔴 0 action required · 🟠 0 recommended · 🔵 3 informational

Advisory: findings do not block the merge.

3 defects outside any rule

Files Lines Languages Checks 🔴 Action required 🟠 Recommended 🔵 Informational
2 +202 / -0 Go (1 go test lane) ✅ 1 / 1 passed 0 0 3

🔵 Informational (3)

# Where Finding Flagged by
1 queries.go:1887 New folder-name dedup/skip logic ignores "Program Files (x86)" installs (Minor) Review
2 queries.go:1811 Folder-name dedup matches any ancestor directory, not just the exe's immediate parent (Minor) Review
3 queries.go:1850 Common Files is not only a Windows component folder Tests and mutation

✅ What this change does well

  • server/service/osquery_utils/queries.go consistently wraps every fork-specific addition in OPENFRAME sentinel comments as required by FLEETMDM-001, making the upstream diff easy to isolate on future syncs.
  • server/service/osquery_utils/queries_test.go adds focused table-driven cases (folder-name match without install_location, whole-name matching, version/year trimming, Windows component/uninstaller skipping) that exercise the new logic's edge cases well.
  • server/service/osquery_utils/queries.go keeps every fork edit inside OPENFRAME(program-files-scan-duplicates) markers, mirroring upstream PR Skip executables of listed programs, Windows components and uninstallers in the Program Files scan fleetdm/fleet#59098, so an upstream sync can drop it cleanly.
  • server/service/osquery_utils/queries_test.go covers both directions: duplicates removed (7-Zip, Node.js, Git) and unrelated apps kept (DNG Converter, AutoCAD, Acme Suite, Microsoft folder).

Inline comments: 3 new

🧪 Tests and mutation

Tests per lane

Language Project Command Status Counts Time
Go (go test) . go vet ./server/service/osquery_utils && go test -cover ./orbit/... ❌ failed 50.8 s
Tests failed in .: what it printed last
		coverage: 0.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/software_update	13.853s	coverage: 88.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/sudo_info	5.035s	coverage: 68.4% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/tablehelpers	6.228s	coverage: 96.7% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/tcc_access	8.183s	coverage: 79.5% of statements
	github.com/fleetdm/fleet/v4/orbit/pkg/table/user_login_settings		coverage: 0.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/table/yaml_to_json	5.109s	coverage: 91.7% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/token	5.865s	coverage: 88.7% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/update	25.127s	coverage: 57.2% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/update/badgerstore	5.468s	coverage: 88.9% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/update/filestore	5.523s	coverage: 75.0% of statements
	github.com/fleetdm/fleet/v4/orbit/pkg/user		coverage: 0.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/useraction	7.105s	coverage: 29.2% of statements
	github.com/fleetdm/fleet/v4/orbit/pkg/windows/oleconv		coverage: 0.0% of statements
	github.com/fleetdm/fleet/v4/orbit/pkg/windows/windowsupdate		coverage: 0.0% of statements
ok  	github.com/fleetdm/fleet/v4/orbit/pkg/zenity	5.468s	coverage: 50.0% of statements
	github.com/fleetdm/fleet/v4/orbit/tools/build		coverage: 0.0% of statements
FAIL

Checks

Check Kind Language Project Status Time
gofmt format Go (go test) . ✅ passed 0 s

Go lane: the plan ran go vet on osquery_utils and go test ./orbit/...; the only failure is TestGetFleetdConfig in orbit/pkg/profiles, a darwin test that reads this Mac's real configuration profiles, in a package the change does not touch (environment, not the change).

The plan did not run the changed package's tests; run separately: go test -cover ./server/service/osquery_utils passes, coverage of the new code: processProgramFilesScan 96.5%, programFolderName 100%, skipProgramFilesScanExe 90.9%, programFilesScanDirs 80%.

No mutation tool for Go is configured.

What the surviving mutations leave unverified

  • queries.go:1880-1882: The branch for an exe path outside Program Files (no folders after the cut) has no test; the scan query only returns C:\Program Files paths, so it is unreachable today.
  • queries.go:1889-1891: programFilesScanDirs returning nil for a path without \program files\ is not tested; same reason, the query never yields such a path.

1 gap (not tested here):

  • Go (go test) .: no mutation testing (no mutation tool for Go is configured: read the coverage of the changed packages instead)
🤖 Prompt for AI agents: fix every finding
Address these code-review findings on pull request #270 of flamingo-stack/fleetmdm, most important first.
For each one, make the minimal change that resolves it and do not refactor unrelated code.
If you can show a finding is wrong, skip it and say why.

1. [Informational] server/service/osquery_utils/queries.go:1887 New folder-name dedup/skip logic ignores "Program Files (x86)" installs
   programFilesScanDirs only cuts on the literal substring `\program files\` (lowercased), so any executable under `C:\Program Files (x86)\...` returns nil dirs. This means both the new duplicate-by-folder-name check (knownNames) and skipProgramFilesScanExe never engage for 32-bit installs, even though the pre-existing path-prefix dedup logic in this same function explicitly handles `\program files (x86)\` via skipInstallPaths. Many real-world apps with no install_location (the exact scenario this change targets) install under Program Files (x86), so those entries will not be deduplicated or filtered the way the 64-bit equivalents now are.
2. [Informational] server/service/osquery_utils/queries.go:1811 Folder-name dedup matches any ancestor directory, not just the exe's immediate parent
   programFilesScanDirs returns every directory segment between "Program Files" and the exe, outermost first, and the new dedup loop in processProgramFilesScan checks knownNames against every one of those segments, not just the leaf folder that actually names the application. Unlike the existing install_location-based dedup (which trusts a real registered root path), this heuristic has no notion of which segment is the "install root": it will match on a vendor-level folder (e.g. "Adobe", "Microsoft", "Autodesk") if any installed program happens to share that exact normalized name, even though the file-scanned exe several levels deeper belongs to a completely different, unrelated product under that vendor folder.
3. [Informational] server/service/osquery_utils/queries.go:1850 Common Files is not only a Windows component folder
   C:\Program Files\Common Files also holds third-party shared components (vendor updaters and runtimes), and the skip list drops all of its exes.

Next: commit a suggestion, or hand a comment's prompt to your coding agent. React 👍 on a finding that helped and 👎 on one that is wrong: the reviewer learns from both.

Review again. New commits are not reviewed until you ask:

  • Review the new commits: only what was pushed since this review
  • Review the whole diff again: everything, including what was already reviewed

Or comment @flamingo-review (new commits) or @flamingo-review full (everything). Add the flamingo-review-always label to review every push.

Updated 2026-11-19 00:03 UTC · reviewed from Aliaska Varieva's machine

Comment thread server/service/osquery_utils/queries.go Resolved
Comment thread server/service/osquery_utils/queries.go Resolved
Comment thread server/service/osquery_utils/queries.go Resolved
@aliaska-varieva
aliaska-varieva marked this pull request as ready for review November 20, 2026 00:44
@aliaska-varieva
aliaska-varieva marked this pull request as draft November 24, 2026 15:44
@aliaska-varieva
aliaska-varieva marked this pull request as ready for review November 30, 2026 18:40
…s and uninstallers in the Program Files scan CU-17tkuw67w42
… in the Program Files scan CU-17tkuw67w42

"Autodesk 3ds Max 2026" was cut to "autodesk" at the first digit-led word,
which hid every executable under C:\Program Files\Autodesk. Also strip versions
joined by a hyphen ("7-Zip-26.06").
…ames in the Program Files scan CU-17tkuw67w42

"Acme (CAD) Suite" was reduced to "acmesuite" and hid executables under an
unrelated "Acme Suite" folder.
Only the Windows folders inside Common Files are skipped; other vendors'
components there are still reported. Same as upstream fleetdm#59098.
@aliaska-varieva
aliaska-varieva force-pushed the fix/program-files-scan-duplicates branch from efc920e to a014e27 Compare November 30, 2026 18:41
Comment thread server/service/osquery_utils/queries.go Resolved
@flamingo

flamingo Bot commented Nov 30, 2026

Copy link
Copy Markdown

🦩 Flamingo Code Review

2 findings: 🔴 0 action required · 🟠 0 recommended · 🔵 2 informational

Advisory: findings do not block the merge.

Rules cited: FLEETMDM-001 · 1 defect outside any rule

Files Lines 🔴 Action required 🟠 Recommended 🔵 Informational
2 +224 / -0 0 0 2

🔵 Informational (2)

# Where Finding Flagged by
1 queries.go:1946 programFilesScanDirs ignores Program Files (x86), so the new skip/folder-name dedup never applies to 32-bit installs (Minor) Review
2 queries.go:1764 OPENFRAME sentinel in queries.go omits the required openframe/docs/doc.md reference (Minor) FLEETMDM-001

✅ What this change does well

  • All fork edits inside the shared upstream file server/service/osquery_utils/queries.go are enclosed in OPENFRAME(program-files-scan-duplicates) / `` sentinels, keeping upstream syncs able to re-apply them.
  • queries_test.go adds table cases that cover each new branch (folder-name match, partial-name non-match, version/year trimming, Windows component folders and the MsMpEng.exe exception).

Inline comments: 1 new · 1 already on this pull request from an earlier review (not posted again; the existing thread is linked below)

Already commented on by an earlier review

  • 🔵 Informational · info · Minor · server/service/osquery_utils/queries.go:1946: programFilesScanDirs ignores Program Files (x86), so the new skip/folder-name dedup never applies to 32-bit installs (existing thread)
🤖 Prompt for AI agents: fix every finding
Address these code-review findings on pull request #270 of flamingo-stack/fleetmdm, most important first.
For each one, make the minimal change that resolves it and do not refactor unrelated code.
If you can show a finding is wrong, skip it and say why.

1. [Informational] server/service/osquery_utils/queries.go:1946 programFilesScanDirs ignores Program Files (x86), so the new skip/folder-name dedup never applies to 32-bit installs
   programFilesScanDirs only cuts on the literal `\program files\`. Paths under `C:\Program Files (x86)\...` do not contain that substring (they contain `\program files (x86)\`), so the function returns nil for every 32-bit install. Both new behaviours added in this diff depend on it: skipProgramFilesScanExe (queries.go:1930) returns false for all x86 paths, and the knownNames folder-name dedup loop (queries.go:1818) iterates over an empty slice. The surrounding upstream code explicitly treats both roots as equivalent (skipInstallPaths lists `\program files\` and `\program files (x86)\` at lines 1760-1761), so the asymmetry is unintended: `C:\Program Files (x86)\Internet Explorer\iexplore.exe` and x86 uninstaller-adjacent Windows component exes are still reported, and x86 apps without install_location still produce duplicate inventory rows.
2. [Informational] server/service/osquery_utils/queries.go:1764 OPENFRAME sentinel in queries.go omits the required openframe/docs/<doc>.md reference
   FLEETMDM-001 requires the opening sentinel in a shared upstream file to be of the form `// >>> OPENFRAME(<slug>): <why> — openframe/docs/<doc>.md`. The block opened at line 1764 of server/service/osquery_utils/queries.go (an upstream fleetdm/fleet file) carries a slug and a rationale but points at an upstream issue (`upstream fleetdm/fleet#59098`) instead of a fork doc under `openframe/docs/`. The same omission applies to the later blocks in this diff (lines ~1770, ~1797, ~1816, ~1892), which carry only `// >>> OPENFRAME(program-files-scan-duplicates)` with no why and no doc path.

Next: commit a suggestion, or hand a comment's prompt to your coding agent. React 👍 on a finding that helped and 👎 on one that is wrong: the reviewer learns from both.

Review again. New commits are not reviewed until you ask:

  • Review the new commits: only what was pushed since this review
  • Review the whole diff again: everything, including what was already reviewed
  • Run a security review: a review that looks for security problems only, with its own check

Or comment @flamingo-review (new commits) or @flamingo-review full (everything). Add the flamingo-review-always label to review every push.

Updated 2026-11-30 18:45 UTC · reviewed from Aliaska Varieva's machine

@aliaska-varieva
aliaska-varieva merged commit eab89b7 into main Nov 30, 2026
27 checks passed
@aliaska-varieva
aliaska-varieva deleted the fix/program-files-scan-duplicates branch November 30, 2026 20:07
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