Skip to content

Commit f6f35be

Browse files
authored
Remove homebrew app casks (#24593)
1 parent 7053731 commit f6f35be

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

changes/22944-homebrew-casks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* removed duplicate software records from homebrew casks already reported in the osquery `apps` table to address false positive vulnerabilities due to lack of bundle_identifier

docs/Contributing/Understanding-host-vitals.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,22 @@ SELECT
662662
'' AS vendor,
663663
0 AS last_opened_at,
664664
path AS installed_path
665-
FROM homebrew_packages;
665+
FROM homebrew_packages
666+
WHERE type = 'formula'
667+
UNION
668+
SELECT
669+
name AS name,
670+
version AS version,
671+
'' AS bundle_identifier,
672+
'' AS extension_id,
673+
'' AS browser,
674+
'homebrew_packages' AS source,
675+
'' AS vendor,
676+
0 AS last_opened_at,
677+
path AS installed_path
678+
FROM homebrew_packages
679+
WHERE type = 'cask'
680+
AND NOT EXISTS (SELECT 1 FROM file WHERE file.path LIKE CONCAT(homebrew_packages.path, '/%%') AND file.path LIKE '%.app%' LIMIT 1);
666681
```
667682
668683
## software_macos_codesign

server/service/osquery_utils/queries.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,10 @@ var softwareMacOS = DetailQuery{
823823
// ensure that the nested loops in the query generation are ordered correctly for the _extensions
824824
// tables that need a uid parameter. CROSS JOIN ensures that SQLite does not reorder the loop
825825
// nesting, which is important as described in https://youtu.be/hcn3HIcHAAo?t=77.
826+
//
827+
// Homebrew package casks are filtered to exclude those that have an associated .app bundle
828+
// as these are already included in the apps table. Apps table software includes bundle_identifier
829+
// which is used in vulnerability scanning.
826830
Query: withCachedUsers(`WITH cached_users AS (%s)
827831
SELECT
828832
name AS name,
@@ -894,7 +898,22 @@ SELECT
894898
'' AS vendor,
895899
0 AS last_opened_at,
896900
path AS installed_path
897-
FROM homebrew_packages;
901+
FROM homebrew_packages
902+
WHERE type = 'formula'
903+
UNION
904+
SELECT
905+
name AS name,
906+
version AS version,
907+
'' AS bundle_identifier,
908+
'' AS extension_id,
909+
'' AS browser,
910+
'homebrew_packages' AS source,
911+
'' AS vendor,
912+
0 AS last_opened_at,
913+
path AS installed_path
914+
FROM homebrew_packages
915+
WHERE type = 'cask'
916+
AND NOT EXISTS (SELECT 1 FROM file WHERE file.path LIKE CONCAT(homebrew_packages.path, '/%%%%') AND file.path LIKE '%%.app%%' LIMIT 1);
898917
`),
899918
Platforms: []string{"darwin"},
900919
DirectIngestFunc: directIngestSoftware,

0 commit comments

Comments
 (0)