CrowdStrike / psfalcon

PowerShell for CrowdStrike's OAuth2 APIs
The Unlicense
350 stars 66 forks source link

[ ENHANCEMENT ] Force lowercase for `Cid` parameter when using `Add-FalconRole` #401

Closed cl6227 closed 1 week ago

cl6227 commented 4 months ago

Add-FalconRole command with -Cid parameter: In a multi-Cid environment (Parent/Child) the -Cid provided is case sensitive and appears to require lowercase. Requesting an enhancement to silently auto-lowercase the value provided for the "-Cid" parameter.

In addition, and totally optional, to detect if a Cid checksum value was provided, and extract and use the Cid from it. The Cid checksum is available on the sensor downloads page, and easily copied from the CRWD UI, which is why one might get confused.

For instance, in the example below, the "c" characters are the Cid, and the additional "-xx" is the checksum; to be removed. cccccccccccccccccccccccccccccccc-xx

Existing error when providing a wrong-case (uppercase) Cid:

> Add-FalconRole -Cid <cid here> -UserId <users id here> -Ids <roles(s) here>
Write-Result : {"code":404,"message":"customer with ID=\u0027<our Cid here>\u0027 not found"}
At C:\Users\<myusername>\Documents\WindowsPowerShell\Modules\PSFalcon\2.2.6\private\Private.ps1:663 char:9
+   Write-Result $Object
+   ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo  : InvalidResult: (@{errors=System.Object[]}:PSObject) [Write-Results], Exception
    + FullyQualifiedErrorId : Write-Result
bk-cs commented 3 months ago

I added a private function to validate Cid input and return only valid Cid values in lowercase. I've updated every command that accepts Cid as input to use this function and these changes will be included in the next PSFalcon release.

bk-cs commented 1 week ago

This improvement is included in the 2.2.7 release.