Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ BUG ] Uninstall-FalconSensor uses Windows script on Linux #426

Closed
anzaomar opened this issue Sep 27, 2024 · 2 comments
Closed

[ BUG ] Uninstall-FalconSensor uses Windows script on Linux #426

anzaomar opened this issue Sep 27, 2024 · 2 comments
Assignees
Labels
bug Something isn't working fix available Self-applied fix available in issue

Comments

@anzaomar
Copy link

Describe the bug
The Uninstall-FalconSensor command uses the Windows uninstallation script i.e. uninstall_sensor.ps1 instead of using the uninstall_sensor.sh.

There is a flaw in the code of the psf-sensors.ps1 file on line 365.
image

$Platform is not assigned the value of $HostList.platform_name.

The code should be changed to the following

$HostList = Get-FalconHost -Id $Id | Select-Object $Select
      if ($HostList.platform_name -notmatch '^(Windows|Linux)$') {
        throw 'Only Windows and Linux hosts are currently supported for uninstallation using PSFalcon.'
      }
      [string]$Filename = if ($HostList.platform_name -eq 'Linux') { 'uninstall_sensor.sh' } else { 'uninstall_sensor.ps1' }

OR

$HostList = Get-FalconHost -Id $Id | Select-Object $Select
      if ($HostList.platform_name -notmatch '^(Windows|Linux)$') {
        throw 'Only Windows and Linux hosts are currently supported for uninstallation using PSFalcon.'
      }
      [string]$Platform = $HostList.platform_name 
      [string]$Filename = if ($Platform -eq 'Linux') { 'uninstall_sensor.sh' } else { 'uninstall_sensor.ps1' }

To Reproduce
Try to run the uninstallation command for any linux machine.

Expected behavior
The command should use the uninstall_sensor.sh script for uninstallation.

@anzaomar anzaomar added the bug Something isn't working label Sep 27, 2024
bk-cs added a commit that referenced this issue Sep 27, 2024
Updated `Uninstall-FalconSensor` to properly select bash uninstall script when targeting Linux hosts.
@bk-cs
Copy link
Collaborator

bk-cs commented Sep 27, 2024

Nice catch! I have corrected this for the next PSFalcon release.

If you'd like to resolve it for your local module before release, you can replace public\psf-sensors.ps1 using the steps outlined below.

Import-Module -Name PSFalcon
$ModulePath = (Show-FalconModule).ModulePath
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/CrowdStrike/psfalcon/9afc0422d2cf597e8315f0d2e80db541218fa59e/public/psf-sensors.ps1 -UseBasicParsing).Content > (Join-Path (Join-Path $ModulePath public) psf-sensors.ps1)

Ensure that you restart PowerShell and re-import PSFalcon before testing.

@bk-cs bk-cs added the fix available Self-applied fix available in issue label Sep 27, 2024
@bk-cs bk-cs changed the title [ BUG ] Uninstall-FalconSensor command uses the windows uninstallation script on Linux machines. [ BUG ] Uninstall-FalconSensor uses Windows script on Linux Sep 27, 2024
@bk-cs bk-cs mentioned this issue Dec 19, 2024
@bk-cs
Copy link
Collaborator

bk-cs commented Dec 19, 2024

This fix has been included in the 2.2.8 release which is now available on GitHub. I'm going to leave this issue open until the PowerShell Gallery release is also available.

@bk-cs bk-cs closed this as completed Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix available Self-applied fix available in issue
Projects
None yet
Development

No branches or pull requests

2 participants