-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use a new strategy for finding the app name in case the title is…
… wrong (#25297) > For #24873 # 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/`, `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] Added/updated automated tests - [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 --------- Co-authored-by: Ian Littman <iansltx@gmail.com>
- Loading branch information
Showing
5 changed files
with
494 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Added a fallback for extracting app name from .pkg installers that have default or incorrect title attributes in their distribution file. |
228 changes: 228 additions & 0 deletions
228
pkg/file/testdata/distribution/distribution-cold-turkey.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<installer-gui-script authoringTool="Packages" authoringToolVersion="1.2.10" authoringToolBuild="732" minSpecVersion="1.0"> | ||
<options rootVolumeOnly="true" customize="never" hostArchitectures="x86_64"/> | ||
<installation-check script="installation_check()"/> | ||
<!--+==========================+ | ||
| Presentation | | ||
+==========================+--> | ||
<title>DISTRIBUTION_TITLE</title> | ||
<license file="license.txt"/> | ||
<!--+==========================+ | ||
| Installer | | ||
+==========================+--> | ||
<choices-outline> | ||
<line choice="installer_choice_1"/> | ||
<line choice="installer_choice_2"/> | ||
<line choice="installer_choice_3"/> | ||
<line choice="installer_choice_4"/> | ||
</choices-outline> | ||
<choice id="installer_choice_1" title="Cold Turkey Blocker" description=""> | ||
<pkg-ref id="com.getcoldturkey.coldturkeyblocker"/> | ||
</choice> | ||
<choice id="installer_choice_2" title="NMHChrome" description=""> | ||
<pkg-ref id="com.getcoldturkey.blocker-chrome-ext"/> | ||
</choice> | ||
<choice id="installer_choice_3" title="NMHFirefox" description=""> | ||
<pkg-ref id="com.getcoldturkey.blocker-firefox-ext"/> | ||
</choice> | ||
<choice id="installer_choice_4" title="NMHEdge" description=""> | ||
<pkg-ref id="com.getcoldturkey.blocker-edge-ext"/> | ||
</choice> | ||
<!--+==========================+ | ||
| Package References | | ||
+==========================+--> | ||
<pkg-ref id="com.getcoldturkey.blocker-firefox-ext" version="4.5" auth="Root" installKBytes="1335">#NMHFirefox.pkg</pkg-ref> | ||
<pkg-ref id="com.getcoldturkey.blocker-edge-ext" version="4.5" auth="Root" installKBytes="1333">#NMHEdge.pkg</pkg-ref> | ||
<pkg-ref id="com.getcoldturkey.blocker-chrome-ext" version="4.5" auth="Root" installKBytes="1333">#NMHChrome.pkg</pkg-ref> | ||
<pkg-ref id="com.getcoldturkey.coldturkeyblocker" version="4.5" auth="Root" installKBytes="22529">#Cold_Turkey_Blocker.pkg</pkg-ref> | ||
<!--+==========================+ | ||
| JavaScript Scripts | | ||
+==========================+--> | ||
<script> | ||
|
||
const __IC_FLAT_DISTRIBUTION__=true; | ||
const IC_OS_DISTRIBUTION_TYPE_ANY=0; | ||
const IC_OS_DISTRIBUTION_TYPE_CLIENT=1; | ||
const IC_DISK_TYPE_DESTINATION=0; | ||
const IC_OS_DISTRIBUTION_TYPE_SERVER=2; | ||
const IC_DISK_TYPE_STARTUP_DISK=1; | ||
|
||
const IC_CONDITION_EXIST=0; | ||
const IC_CONDITION_DOES_NOT_EXIST=1; | ||
const IC_SELECTOR_ANY=0; | ||
const IC_SELECTOR_ALL=1; | ||
|
||
function IC_CheckOS(inDiskType,inMustBeInstalled,inMinimumVersion,inMaximumVersion,inDistributionType) | ||
{ | ||
var tOSVersion=undefined; | ||
|
||
/* Check Version Constraints */ | ||
|
||
if (inDiskType==IC_DISK_TYPE_DESTINATION) | ||
{ | ||
if (my.target.systemVersion!=undefined) | ||
{ | ||
tOSVersion=my.target.systemVersion.ProductVersion; | ||
} | ||
|
||
/* Check if no OS is installed on the potential target */ | ||
|
||
if (tOSVersion==undefined) | ||
{ | ||
return (inMustBeInstalled==false); | ||
} | ||
|
||
if (inMustBeInstalled==false) | ||
{ | ||
return false; | ||
} | ||
} | ||
else | ||
{ | ||
tOSVersion=system.version.ProductVersion; | ||
} | ||
|
||
if (system.compareVersions(tOSVersion,inMinimumVersion)==-1) | ||
return false; | ||
|
||
if (inMaximumVersion!=undefined && | ||
system.compareVersions(tOSVersion,inMaximumVersion)==1) | ||
return false; | ||
|
||
/* Check Distribution Type */ | ||
|
||
if (inDistributionType!=IC_OS_DISTRIBUTION_TYPE_ANY) | ||
{ | ||
var tIsServer; | ||
|
||
if (system.compareVersions(tOSVersion,'10.8.0')==-1) | ||
{ | ||
if (inDiskType==IC_DISK_TYPE_DESTINATION) | ||
{ | ||
tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/System/Library/CoreServices/ServerVersion.plist'); | ||
} | ||
else | ||
{ | ||
tIsServer=system.files.fileExistsAtPath('/System/Library/CoreServices/ServerVersion.plist'); | ||
} | ||
} | ||
else | ||
{ | ||
if (inDiskType==IC_DISK_TYPE_DESTINATION) | ||
{ | ||
tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/Applications/Server.app'); | ||
} | ||
else | ||
{ | ||
tIsServer=system.files.fileExistsAtPath('/Applications/Server.app'); | ||
} | ||
} | ||
|
||
if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_CLIENT && tIsServer==true) | ||
{ | ||
return false; | ||
} | ||
|
||
if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_SERVER && tIsServer==false) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function IC_CheckFiles(inSelector,inCondition,inDiskType,inFiles) | ||
{ | ||
var tCount; | ||
|
||
tCount=inFiles.length; | ||
|
||
if (tCount>0) | ||
{ | ||
var tIndex; | ||
var tExists; | ||
var tPath; | ||
var atLeastOneTrue=false; | ||
|
||
for(tIndex=0;tIndex<tCount;tIndex++) | ||
{ | ||
tPath=inFiles[tIndex]; | ||
|
||
if (inDiskType==IC_DISK_TYPE_DESTINATION) | ||
{ | ||
tPath=my.target.mountpoint+tPath; | ||
} | ||
|
||
if (system.files.fileExistsAtPath(tPath)==true) | ||
{ | ||
if (inCondition==IC_CONDITION_EXIST) | ||
{ | ||
atLeastOneTrue=true; | ||
|
||
if (inSelector==IC_SELECTOR_ANY) | ||
{ | ||
return true; | ||
} | ||
} | ||
else if (inCondition==IC_CONDITION_DOES_NOT_EXIST && inSelector==IC_SELECTOR_ALL) | ||
{ | ||
return false; | ||
} | ||
} | ||
else | ||
{ | ||
if (inCondition==IC_CONDITION_EXIST && inSelector==IC_SELECTOR_ALL) | ||
{ | ||
return false; | ||
} | ||
else if (inCondition==IC_CONDITION_DOES_NOT_EXIST) | ||
{ | ||
atLeastOneTrue=true; | ||
|
||
if (inSelector==IC_SELECTOR_ANY) | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return atLeastOneTrue; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function installation_check() | ||
{ | ||
var tResult; | ||
|
||
tResult=IC_CheckOS(IC_DISK_TYPE_STARTUP_DISK,true,'10.13',undefined,IC_OS_DISTRIBUTION_TYPE_ANY); | ||
|
||
if (tResult==false) | ||
{ | ||
my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_1'); | ||
my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_1'); | ||
my.result.type = 'Fatal'; | ||
} | ||
|
||
if (tResult==true) | ||
{ | ||
var tFilesToCheck1=new Array('/Library/Application Support/Cold Turkey/installer-locked'); | ||
|
||
tResult=IC_CheckFiles(IC_SELECTOR_ANY,IC_CONDITION_DOES_NOT_EXIST,IC_DISK_TYPE_STARTUP_DISK,tFilesToCheck1); | ||
|
||
if (tResult==false) | ||
{ | ||
my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_2'); | ||
my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_2'); | ||
my.result.type = 'Fatal'; | ||
} | ||
} | ||
|
||
return tResult; | ||
} | ||
|
||
</script> | ||
</installer-gui-script> |
155 changes: 155 additions & 0 deletions
155
pkg/file/testdata/distribution/distribution-sentinelone.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<installer-gui-script authoringTool="Packages" authoringToolVersion="1.2.10" authoringToolBuild="732" minSpecVersion="1.0"> | ||
<options rootVolumeOnly="true" customize="never" hostArchitectures="x86_64,arm64"/> | ||
<installation-check script="installation_check()"/> | ||
<volume-check script="volume_check()"/> | ||
<!--+==========================+ | ||
| Presentation | | ||
+==========================+--> | ||
<title>DISTRIBUTION_TITLE</title> | ||
<background file="background" uti="public.tiff" scaling="none" alignment="bottomleft" layout-direction="natural"/> | ||
<background-darkAqua file="background" uti="public.tiff" scaling="none" alignment="bottomleft" layout-direction="natural"/> | ||
<!--+==========================+ | ||
| Installer | | ||
+==========================+--> | ||
<choices-outline> | ||
<line choice="installer_choice_1"/> | ||
</choices-outline> | ||
<choice id="installer_choice_1" title="SentinelOne" description=""> | ||
<pkg-ref id="com.sentinelone.pkg.sentinel-agent"/> | ||
</choice> | ||
<!--+==========================+ | ||
| Package References | | ||
+==========================+--> | ||
<pkg-ref id="com.sentinelone.pkg.sentinel-agent" version="24.3.2.7753" auth="Root" installKBytes="151168">#SentinelOne.pkg</pkg-ref> | ||
<!--+==========================+ | ||
| JavaScript Scripts | | ||
+==========================+--> | ||
<script> | ||
|
||
const __IC_FLAT_DISTRIBUTION__=true; | ||
const IC_OS_DISTRIBUTION_TYPE_ANY=0; | ||
const IC_OS_DISTRIBUTION_TYPE_CLIENT=1; | ||
const IC_DISK_TYPE_DESTINATION=0; | ||
const IC_OS_DISTRIBUTION_TYPE_SERVER=2; | ||
const IC_DISK_TYPE_STARTUP_DISK=1; | ||
|
||
function IC_CheckOS(inDiskType,inMustBeInstalled,inMinimumVersion,inMaximumVersion,inDistributionType) | ||
{ | ||
var tOSVersion=undefined; | ||
|
||
/* Check Version Constraints */ | ||
|
||
if (inDiskType==IC_DISK_TYPE_DESTINATION) | ||
{ | ||
if (my.target.systemVersion!=undefined) | ||
{ | ||
tOSVersion=my.target.systemVersion.ProductVersion; | ||
} | ||
|
||
/* Check if no OS is installed on the potential target */ | ||
|
||
if (tOSVersion==undefined) | ||
{ | ||
return (inMustBeInstalled==false); | ||
} | ||
|
||
if (inMustBeInstalled==false) | ||
{ | ||
return false; | ||
} | ||
} | ||
else | ||
{ | ||
tOSVersion=system.version.ProductVersion; | ||
} | ||
|
||
if (system.compareVersions(tOSVersion,inMinimumVersion)==-1) | ||
return false; | ||
|
||
if (inMaximumVersion!=undefined && | ||
system.compareVersions(tOSVersion,inMaximumVersion)==1) | ||
return false; | ||
|
||
/* Check Distribution Type */ | ||
|
||
if (inDistributionType!=IC_OS_DISTRIBUTION_TYPE_ANY) | ||
{ | ||
var tIsServer; | ||
|
||
if (system.compareVersions(tOSVersion,'10.8.0')==-1) | ||
{ | ||
if (inDiskType==IC_DISK_TYPE_DESTINATION) | ||
{ | ||
tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/System/Library/CoreServices/ServerVersion.plist'); | ||
} | ||
else | ||
{ | ||
tIsServer=system.files.fileExistsAtPath('/System/Library/CoreServices/ServerVersion.plist'); | ||
} | ||
} | ||
else | ||
{ | ||
if (inDiskType==IC_DISK_TYPE_DESTINATION) | ||
{ | ||
tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/Applications/Server.app'); | ||
} | ||
else | ||
{ | ||
tIsServer=system.files.fileExistsAtPath('/Applications/Server.app'); | ||
} | ||
} | ||
|
||
if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_CLIENT && tIsServer==true) | ||
{ | ||
return false; | ||
} | ||
|
||
if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_SERVER && tIsServer==false) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function IC_CheckMinimumAvailableDiskSpace(inMinimumAvailableSpaceKB) | ||
{ | ||
return (my.target.availableKilobytes>=inMinimumAvailableSpaceKB); | ||
} | ||
|
||
function installation_check() | ||
{ | ||
var tResult; | ||
|
||
tResult=IC_CheckOS(IC_DISK_TYPE_STARTUP_DISK,true,'13.0','15.99.99',IC_OS_DISTRIBUTION_TYPE_ANY); | ||
|
||
if (tResult==false) | ||
{ | ||
my.result.title = system.localizedString('REQUIREMENT_FAILED_MESSAGE_INSTALLATION_CHECK_1'); | ||
my.result.message = system.localizedString('REQUIREMENT_FAILED_DESCRIPTION_INSTALLATION_CHECK_1'); | ||
my.result.type = 'Fatal'; | ||
} | ||
|
||
return tResult; | ||
} | ||
|
||
function volume_check() | ||
{ | ||
var tResult; | ||
|
||
tResult=IC_CheckMinimumAvailableDiskSpace(2147483648); | ||
|
||
if (tResult==false) | ||
{ | ||
my.result.message = system.localizedString('REQUIREMENT_FAILED_MESSAGE_VOLUME_CHECK_2'); | ||
my.result.type = 'Fatal'; | ||
} | ||
|
||
return tResult; | ||
} | ||
|
||
</script> | ||
<product version="24.3.2.7753" id="com.sentinelone.sentinel-agent"/> | ||
</installer-gui-script> |
Oops, something went wrong.