diff --git a/ee/maintained-apps/ingesters/homebrew/external_refs/main.go b/ee/maintained-apps/ingesters/homebrew/external_refs/main.go index 9eaa7b0d66..1b34a03ca5 100644 --- a/ee/maintained-apps/ingesters/homebrew/external_refs/main.go +++ b/ee/maintained-apps/ingesters/homebrew/external_refs/main.go @@ -42,6 +42,7 @@ var Funcs = map[string][]func(*maintained_apps.FMAManifestApp) (*maintained_apps "logitune/darwin": {LogiTunePKGInstaller}, "anka-virtualization/darwin": {AnkaVersionShortener}, "pd/darwin": {PdVersionTransformer}, + "sonos/darwin": {SonosVersionTransformer}, } func ChromePKGInstaller(app *maintained_apps.FMAManifestApp) (*maintained_apps.FMAManifestApp, error) { diff --git a/ee/maintained-apps/ingesters/homebrew/external_refs/version_shortener.go b/ee/maintained-apps/ingesters/homebrew/external_refs/version_shortener.go index 62378268d6..eaf2b8433a 100644 --- a/ee/maintained-apps/ingesters/homebrew/external_refs/version_shortener.go +++ b/ee/maintained-apps/ingesters/homebrew/external_refs/version_shortener.go @@ -75,6 +75,22 @@ func LensVersionTransformer(app *maintained_apps.FMAManifestApp) (*maintained_ap return app, nil } +// SonosVersionTransformer converts Homebrew's Sonos version scheme (e.g. +// "90.0-77070") to the dotted form macOS reports as bundle_version (e.g. +// "90.0.77070"). Sonos versions its cask by build number, which matches +// CFBundleVersion rather than CFBundleShortVersionString (the unrelated +// marketing version, e.g. "17.2.3"). The patch policy for Sonos compares +// bundle_version (see the ingester); without this transform osquery's +// version_compare treats "90.0-77070" and "90.0.77070" as different versions +// and patch policy detection breaks. +func SonosVersionTransformer(app *maintained_apps.FMAManifestApp) (*maintained_apps.FMAManifestApp, error) { + if app.Version == "" { + return app, errors.New("empty version for Sonos") + } + app.Version = strings.ReplaceAll(app.Version, "-", ".") + return app, nil +} + // PdVersionTransformer converts Homebrew's Pd version scheme (e.g. "0.56-3") to // the dotted form macOS reports as bundle_short_version (e.g. "0.56.3"). // Without this, osquery's version_compare treats "0.56-3" and "0.56.3" as diff --git a/ee/maintained-apps/ingesters/homebrew/ingester.go b/ee/maintained-apps/ingesters/homebrew/ingester.go index ee113a0b3b..9e6e698534 100644 --- a/ee/maintained-apps/ingesters/homebrew/ingester.go +++ b/ee/maintained-apps/ingesters/homebrew/ingester.go @@ -200,6 +200,16 @@ func (i *brewIngester) ingestOne(ctx context.Context, input inputApp) (*maintain out.UniqueIdentifier, out.Version, ) } + if input.Token == "sonos" { + // Sonos versions its cask by build number (matching CFBundleVersion, e.g. + // "90.0.77070" after SonosVersionTransformer), while bundle_short_version is + // the unrelated marketing version (e.g. "17.2.3"). Compare bundle_version so + // patch status reflects the actual installed build. + out.Queries.Patched = fmt.Sprintf( + "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps WHERE bundle_identifier = '%s' AND version_compare(bundle_version, '%s') < 0);", + out.UniqueIdentifier, out.Version, + ) + } return out, nil } diff --git a/ee/maintained-apps/inputs/homebrew/sonos.json b/ee/maintained-apps/inputs/homebrew/sonos.json new file mode 100644 index 0000000000..4f2f506b6e --- /dev/null +++ b/ee/maintained-apps/inputs/homebrew/sonos.json @@ -0,0 +1,10 @@ +{ + "name": "Sonos", + "unique_identifier": "com.sonos.macController2", + "token": "sonos", + "installer_format": "dmg", + "slug": "sonos/darwin", + "default_categories": [ + "Productivity" + ] +} diff --git a/ee/maintained-apps/inputs/winget/scripts/sonos_install.ps1 b/ee/maintained-apps/inputs/winget/scripts/sonos_install.ps1 new file mode 100644 index 0000000000..161c6897aa --- /dev/null +++ b/ee/maintained-apps/inputs/winget/scripts/sonos_install.ps1 @@ -0,0 +1,29 @@ +# Learn more about .exe install scripts: +# http://fleetdm.com/learn-more-about/exe-install-scripts + +$exeFilePath = "${env:INSTALLER_PATH}" + +try { + +# The Sonos installer is an InstallShield setup that wraps an MSI. The documented +# winget silent switches run the setup silently (/S) and pass /quiet /norestart +# through to the inner MSI (/V) for an unattended, machine-wide install. +$processOptions = @{ + FilePath = "$exeFilePath" + ArgumentList = "/S /V/quiet /V/norestart" + PassThru = $true + Wait = $true +} + +# Start process and track exit code +$process = Start-Process @processOptions +$exitCode = $process.ExitCode + +# Prints the exit code +Write-Host "Install exit code: $exitCode" +Exit $exitCode + +} catch { + Write-Host "Error: $_" + Exit 1 +} diff --git a/ee/maintained-apps/inputs/winget/sonos.json b/ee/maintained-apps/inputs/winget/sonos.json new file mode 100644 index 0000000000..de3c8d6134 --- /dev/null +++ b/ee/maintained-apps/inputs/winget/sonos.json @@ -0,0 +1,15 @@ +{ + "name": "Sonos", + "slug": "sonos/windows", + "package_identifier": "Sonos.Controller", + "unique_identifier": "Sonos", + "fuzzy_match_name": "Sonos%", + "installer_arch": "x86", + "installer_type": "exe", + "uninstall_type": "msi", + "installer_scope": "machine", + "default_categories": [ + "Productivity" + ], + "install_script_path": "ee/maintained-apps/inputs/winget/scripts/sonos_install.ps1" +} diff --git a/ee/maintained-apps/outputs/apps.json b/ee/maintained-apps/outputs/apps.json index 7ab88b5132..5d7b04b891 100644 --- a/ee/maintained-apps/outputs/apps.json +++ b/ee/maintained-apps/outputs/apps.json @@ -6994,6 +6994,20 @@ "unique_identifier": "com.Sonosaurus.SonoBus", "description": "SonoBus is a high-quality network audio streaming." }, + { + "name": "Sonos", + "slug": "sonos/darwin", + "platform": "darwin", + "unique_identifier": "com.sonos.macController2", + "description": "Sonos is an app to set up and control Sonos wireless speakers and home audio systems." + }, + { + "name": "Sonos", + "slug": "sonos/windows", + "platform": "windows", + "unique_identifier": "Sonos", + "description": "Sonos is an app to set up and control Sonos wireless speakers and home audio systems." + }, { "name": "PS Remote Play", "slug": "sony-ps-remote-play/darwin", diff --git a/ee/maintained-apps/outputs/sonos/darwin.json b/ee/maintained-apps/outputs/sonos/darwin.json new file mode 100644 index 0000000000..457ab0ca04 --- /dev/null +++ b/ee/maintained-apps/outputs/sonos/darwin.json @@ -0,0 +1,22 @@ +{ + "versions": [ + { + "version": "90.0.77070", + "queries": { + "exists": "SELECT 1 FROM apps WHERE bundle_identifier = 'com.sonos.macController2';", + "patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps WHERE bundle_identifier = 'com.sonos.macController2' AND version_compare(bundle_version, '90.0.77070') < 0);" + }, + "installer_url": "https://update-software.sonos.com/software/rT0797IawE/Sonos_90.0-77070.dmg", + "install_script_ref": "85c8c855", + "uninstall_script_ref": "eb46b753", + "sha256": "3a3cc74fa35e79e0499e67712ee70cc3eb51836d00970b2139cb131fc20b4cf1", + "default_categories": [ + "Productivity" + ] + } + ], + "refs": { + "85c8c855": "#!/bin/bash\n\n# variables\nAPPDIR=\"/Applications/\"\nTMPDIR=$(dirname \"$(realpath \"$INSTALLER_PATH\")\")\n# functions\n\nquit_and_track_application() {\n local bundle_id=\"$1\"\n local var_name=\"APP_WAS_RUNNING_$(echo \"$bundle_id\" | tr '.-' '__')\"\n local timeout_duration=10\n\n # check if the application is running\n local app_running\n app_running=$(osascript -e \"application id \\\"$bundle_id\\\" is running\" 2>/dev/null)\n if [[ \"$app_running\" != \"true\" ]]; then\n eval \"export $var_name=0\"\n return\n fi\n\n local console_user\n console_user=$(stat -f \"%Su\" /dev/console)\n if [[ -z \"$console_user\" || \"$console_user\" == \"root\" || \"$console_user\" == \"loginwindow\" ]]; then\n echo \"Not logged into a non-root GUI; skipping quitting application ID '$bundle_id'.\"\n eval \"export $var_name=0\"\n return\n fi\n\n # App was running, mark it for relaunch\n eval \"export $var_name=1\"\n echo \"Application '$bundle_id' was running; will relaunch after installation.\"\n\n echo \"Quitting application '$bundle_id'...\"\n\n # try to quit the application within the timeout period\n local quit_success=false\n SECONDS=0\n while (( SECONDS < timeout_duration )); do\n if osascript -e \"tell application id \\\"$bundle_id\\\" to quit\" >/dev/null 2>&1; then\n if ! pgrep -f \"$bundle_id\" >/dev/null 2>&1; then\n echo \"Application '$bundle_id' quit successfully.\"\n quit_success=true\n break\n fi\n fi\n sleep 1\n done\n\n if [[ \"$quit_success\" = false ]]; then\n echo \"Application '$bundle_id' did not quit.\"\n fi\n}\n\n\nrelaunch_application() {\n local bundle_id=\"$1\"\n local var_name=\"APP_WAS_RUNNING_$(echo \"$bundle_id\" | tr '.-' '__')\"\n local was_running\n\n # Check if the app was running before installation\n eval \"was_running=\\$$var_name\"\n if [[ \"$was_running\" != \"1\" ]]; then\n return\n fi\n\n local console_user\n console_user=$(stat -f \"%Su\" /dev/console)\n if [[ -z \"$console_user\" || \"$console_user\" == \"root\" || \"$console_user\" == \"loginwindow\" ]]; then\n echo \"Not logged into a non-root GUI; skipping relaunching application ID '$bundle_id'.\"\n return\n fi\n\n echo \"Relaunching application '$bundle_id'...\"\n\n # Launch the app in the logged-in user's GUI session. Apps launched by root\n # won't register with the user's Dock/GUI, so run 'open' as the console user.\n # Use 'launchctl asuser' to bootstrap into the console user's Mach namespace\n # and GUI session — 'sudo -u' alone doesn't do this, which can cause\n # LSOpenURLsWithRole() failures even when 'open' exits 0.\n local open_status=0\n if [[ $EUID -eq 0 ]]; then\n local console_uid\n console_uid=$(id -u \"$console_user\")\n /bin/launchctl asuser \"$console_uid\" sudo -u \"$console_user\" open -b \"$bundle_id\" >/dev/null 2>&1 || open_status=$?\n else\n open -b \"$bundle_id\" >/dev/null 2>&1 || open_status=$?\n fi\n\n if [[ $open_status -eq 0 ]]; then\n echo \"Application '$bundle_id' relaunched successfully.\"\n else\n echo \"Failed to relaunch application '$bundle_id'.\"\n fi\n}\n\n\n# extract contents\nMOUNT_POINT=$(mktemp -d /tmp/dmg_mount_XXXXXX)\nyes | hdiutil attach -plist -nobrowse -readonly -mountpoint \"$MOUNT_POINT\" \"$INSTALLER_PATH\" || exit 1\nsudo cp -R \"$MOUNT_POINT\"/* \"$TMPDIR\"\nhdiutil detach \"$MOUNT_POINT\" || true\n# copy to the applications folder\nquit_and_track_application 'com.sonos.macController2'\nif [ -d \"$APPDIR/Sonos.app\" ]; then\n\tsudo mv \"$APPDIR/Sonos.app\" \"$TMPDIR/Sonos.app.bkp\"\nfi\nsudo cp -R \"$TMPDIR/Sonos.app\" \"$APPDIR\"\nrelaunch_application 'com.sonos.macController2'\n", + "eb46b753": "#!/bin/bash\n\n# variables\nAPPDIR=\"/Applications/\"\nLOGGED_IN_USER=$(scutil <<< \"show State:/Users/ConsoleUser\" | awk '/Name :/ { print $3 }')\n# functions\n\ntrash() {\n local logged_in_user=\"$1\"\n local target_file=\"$2\"\n local timestamp=\"$(date +%Y-%m-%d-%s)\"\n local rand=\"$(jot -r 1 0 99999)\"\n\n # replace ~ with /Users/$logged_in_user\n if [[ \"$target_file\" == ~* ]]; then\n target_file=\"/Users/$logged_in_user${target_file:1}\"\n fi\n\n local trash=\"/Users/$logged_in_user/.Trash\"\n\n # If the target contains glob characters, expand it and move each match.\n if [[ \"$target_file\" == *[*?[]* ]]; then\n local file file_name\n local matched=false\n local i=0\n # compgen -G expands the (quoted) pattern itself, so paths containing\n # spaces glob correctly; reading line by line keeps each match intact.\n while IFS= read -r file; do\n [[ -n \"$file\" ]] || continue\n [[ -e \"$file\" || -L \"$file\" ]] || continue\n matched=true\n i=$((i + 1))\n file_name=\"$(basename \"$file\")\"\n echo \"removing $file.\"\n # The per-match counter keeps matches that share a basename from\n # overwriting each other in the trash.\n mv -f \"$file\" \"$trash/${file_name}_${timestamp}_${rand}_${i}\"\n done < <(compgen -G \"$target_file\" 2>/dev/null)\n if [[ \"$matched\" == false ]]; then\n echo \"$target_file doesn't exist.\"\n fi\n return\n fi\n\n local file_name=\"$(basename \"${target_file}\")\"\n\n if [[ -e \"$target_file\" ]]; then\n echo \"removing $target_file.\"\n mv -f \"$target_file\" \"$trash/${file_name}_${timestamp}_${rand}\"\n else\n echo \"$target_file doesn't exist.\"\n fi\n}\n\nsudo rm -rf \"$APPDIR/Sonos.app\"\ntrash $LOGGED_IN_USER '~/Library/Application Support/SonosV2'\n" + } +} diff --git a/ee/maintained-apps/outputs/sonos/windows.json b/ee/maintained-apps/outputs/sonos/windows.json new file mode 100644 index 0000000000..c7f9f097e7 --- /dev/null +++ b/ee/maintained-apps/outputs/sonos/windows.json @@ -0,0 +1,23 @@ +{ + "versions": [ + { + "version": "90.0.77070", + "queries": { + "exists": "SELECT 1 FROM programs WHERE name LIKE 'Sonos%' AND publisher = 'Sonos, Inc.';", + "patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM programs WHERE name LIKE 'Sonos%' AND publisher = 'Sonos, Inc.' AND version_compare(version, '90.0.77070') < 0);" + }, + "installer_url": "https://update-software.sonos.com/software/rT0797IawE/Sonos_90.0-77070.exe", + "install_script_ref": "109fa54d", + "uninstall_script_ref": "e97fd1a8", + "sha256": "041d3a74d60f94d2b2c4f63909e765efd9648fc5407e970ef6441e66db8bd8ca", + "default_categories": [ + "Productivity" + ], + "upgrade_code": "{97B3FE78-37EB-4ADA-817C-A8BE2E514454}" + } + ], + "refs": { + "109fa54d": "# Learn more about .exe install scripts:\n# http://fleetdm.com/learn-more-about/exe-install-scripts\n\n$exeFilePath = \"${env:INSTALLER_PATH}\"\n\ntry {\n\n# The Sonos installer is an InstallShield setup that wraps an MSI. The documented\n# winget silent switches run the setup silently (/S) and pass /quiet /norestart\n# through to the inner MSI (/V) for an unattended, machine-wide install.\n$processOptions = @{\n FilePath = \"$exeFilePath\"\n ArgumentList = \"/S /V/quiet /V/norestart\"\n PassThru = $true\n Wait = $true\n}\n\n# Start process and track exit code\n$process = Start-Process @processOptions\n$exitCode = $process.ExitCode\n\n# Prints the exit code\nWrite-Host \"Install exit code: $exitCode\"\nExit $exitCode\n\n} catch {\n Write-Host \"Error: $_\"\n Exit 1\n}\n", + "e97fd1a8": "# Fleet uninstalls app by finding all related product codes for the specified upgrade code\n$inst = New-Object -ComObject \"WindowsInstaller.Installer\"\n$timeoutSeconds = 300 # 5 minute timeout per product\n\n# MSI exit codes that indicate success. 3010 = ERROR_SUCCESS_REBOOT_REQUIRED,\n# 1641 = ERROR_SUCCESS_REBOOT_INITIATED. Treat these as success rather than failure.\n$successCodes = @(0, 3010, 1641)\n\nforeach ($product_code in $inst.RelatedProducts('{97B3FE78-37EB-4ADA-817C-A8BE2E514454}')) {\n $process = Start-Process msiexec -ArgumentList @(\"/quiet\", \"/x\", $product_code, \"/norestart\") -PassThru\n\n # Wait for process with timeout\n $completed = $process.WaitForExit($timeoutSeconds * 1000)\n\n if (-not $completed) {\n Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue\n Exit 1603 # ERROR_UNINSTALL_FAILURE\n }\n\n # If the uninstall failed, bail\n if ($successCodes -notcontains $process.ExitCode) {\n Write-Output \"Uninstall for $($product_code) exited $($process.ExitCode)\"\n Exit $process.ExitCode\n }\n}\n\n# All uninstalls succeeded; exit success\nExit 0\n" + } +} diff --git a/frontend/pages/SoftwarePage/components/icons/Sonos.tsx b/frontend/pages/SoftwarePage/components/icons/Sonos.tsx new file mode 100644 index 0000000000..4c75b4a800 --- /dev/null +++ b/frontend/pages/SoftwarePage/components/icons/Sonos.tsx @@ -0,0 +1,14 @@ +import * as React from "react"; + +import type { SVGProps } from "react"; + +const Sonos = (props: SVGProps) => ( + + + +); +export default Sonos; diff --git a/frontend/pages/SoftwarePage/components/icons/index.ts b/frontend/pages/SoftwarePage/components/icons/index.ts index 0fecd4c77a..9edf686a86 100644 --- a/frontend/pages/SoftwarePage/components/icons/index.ts +++ b/frontend/pages/SoftwarePage/components/icons/index.ts @@ -822,6 +822,7 @@ import SnowflakeSnowsql from "./SnowflakeSnowsql"; import Sococo from "./Sococo"; import SonicVisualiser from "./SonicVisualiser"; import Sonobus from "./Sonobus"; +import Sonos from "./Sonos"; import SonyPsRemotePlay from "./SonyPsRemotePlay"; import Soulver from "./Soulver"; import Soundanchor from "./Soundanchor"; @@ -1861,6 +1862,7 @@ export const SOFTWARE_NAME_TO_ICON_MAP = { sococo: Sococo, "sonic visualiser": SonicVisualiser, sonobus: Sonobus, + sonos: Sonos, soulver: Soulver, "sound control": SoundControl, soundanchor: Soundanchor, diff --git a/website/assets/images/app-icon-sonos-60x60@2x.png b/website/assets/images/app-icon-sonos-60x60@2x.png index 5d463035e8..45cfa0e932 100644 Binary files a/website/assets/images/app-icon-sonos-60x60@2x.png and b/website/assets/images/app-icon-sonos-60x60@2x.png differ