-
Notifications
You must be signed in to change notification settings - Fork 69
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 ] Get-FalconRole
and Get-FalconUser
return incorrect roles
#313
Comments
Get-FalconRole
and Get-FalconUser
return incorrect roles
Can you clarify what you mean when you say "the roles aren't returned"? In my experience, custom roles are labelled by their identifier and not a "custom name". This is what is returned by the API. When a new role is created, an identifier shows for the role when using PS C:\> Get-FalconRole
VERBOSE: 09:10:42 [Get-FalconRole] /user-management/queries/roles/v1:get
VERBOSE: 09:10:42 [ApiClient.Invoke] GET https://api.crowdstrike.com/user-management/queries/roles/v1
VERBOSE: 09:10:42 [ApiClient.Invoke] Accept=application/json
VERBOSE: 09:10:42 [ApiClient.Invoke] 200: OK
VERBOSE: 09:10:42 [ApiClient.Invoke] Connection=keep-alive, Strict-Transport-Security=max-age=15724800;
includeSubDomains, max-age=31536000; includeSubDomains, X-Cs-Region=us-1,
X-Cs-Traceid=adc6bba3-cb74-4b34-b273-1d2a53e9fa8b, X-Ratelimit-Limit=6000, X-Ratelimit-Remaining=5999, Date=Fri, 12 May
2023 16:10:43 GMT, Server=nginx
VERBOSE: 09:10:42 [Write-Result] query_time=0.017971311, powered_by=cs.flightcontrolapi,
trace_id=adc6bba3-cb74-4b34-b273-1d2a53e9fa8b
6df995d6e7b54a208965e7f4811ae8e4 When checking by PS C:\> Get-FalconRole -Cid $Cid -UserId $UserId
VERBOSE: 09:03:08 [Get-FalconRole] /user-management/queries/roles/v1:get
VERBOSE: 09:03:08 [ApiClient.Invoke] GET
https://api.crowdstrike.com/user-management/queries/roles/v1?user_uuid=REDACTED&cid=REDACTED
VERBOSE: 09:03:08 [ApiClient.Invoke] Accept=application/json
VERBOSE: 09:03:08 [ApiClient.Invoke] 200: OK
VERBOSE: 09:03:08 [ApiClient.Invoke] Connection=keep-alive, Strict-Transport-Security=max-age=15724800;
includeSubDomains, max-age=31536000; includeSubDomains, X-Cs-Region=us-1,
X-Cs-Traceid=885bb710-2eb3-454d-8286-0d43b8f69c6e, X-Ratelimit-Limit=6000, X-Ratelimit-Remaining=5995, Date=Fri, 12 May
2023 16:03:09 GMT, Server=nginx
VERBOSE: 09:03:08 [Write-Result] query_time=0.03713781, powered_by=cs.flightcontrolapi,
trace_id=885bb710-2eb3-454d-8286-0d43b8f69c6e
6df995d6e7b54a208965e7f4811ae8e4 The custom role identifier also displays when running your command above: PS C:\> Get-FalconUser -Filter "assigned_cids:['$Cid']" -Detailed -Include roles
VERBOSE: [ApiClient.Invoke] GET
https://api.crowdstrike.com/user-management/queries/users/v1?filter=assigned_cids:['REDACTED']
VERBOSE: [ApiClient.Invoke] ContentType=application/json, Accept=application/json
VERBOSE: [ApiClient.Invoke] 200: OK
VERBOSE: [ApiClient.Invoke] Connection=keep-alive, Strict-Transport-Security=max-age=15724800; includeSubDomains,
max-age=31536000; includeSubDomains, X-Cs-Region=us-1, X-Cs-Traceid=a8be72cc-b636-4ff9-8bea-6573d224e920,
X-Ratelimit-Limit=6000, X-Ratelimit-Remaining=5997, Date=Fri, 12 May 2023 16:30:58 GMT, Server=nginx
VERBOSE: [Write-Result] meta.powered_by=cs.flightcontrolapi, meta.pagination.offset=0,
meta.trace_id=a8be72cc-b636-4ff9-8bea-6573d224e920, meta.pagination.total=1, meta.query_time=0.004978607,
meta.pagination.limit=100
VERBOSE: [ApiClient.Invoke] POST https://api.crowdstrike.com/user-management/entities/users/GET/v1
VERBOSE: [ApiClient.Invoke] ContentType=application/json, Accept=application/json
VERBOSE: [ApiClient.Invoke] {"ids":["REDACTED"]}
VERBOSE: [ApiClient.Invoke] 200: OK
VERBOSE: [ApiClient.Invoke] Connection=keep-alive, Strict-Transport-Security=max-age=15724800; includeSubDomains,
max-age=31536000; includeSubDomains, X-Cs-Region=us-1, X-Cs-Traceid=f2795a37-87bc-4f84-9c63-3392958ed298,
X-Ratelimit-Limit=6000, X-Ratelimit-Remaining=5996, Date=Fri, 12 May 2023 16:30:58 GMT, Server=nginx
VERBOSE: [Write-Result] meta.query_time=0.013687534, meta.trace_id=f2795a37-87bc-4f84-9c63-3392958ed298,
meta.powered_by=cs.flightcontrolapi
VERBOSE: [ApiClient.Invoke] GET
https://api.crowdstrike.com/user-management/queries/roles/v1?user_uuid=REDACTED
VERBOSE: [ApiClient.Invoke] Accept=application/json
VERBOSE: [ApiClient.Invoke] 200: OK
VERBOSE: [ApiClient.Invoke] Connection=keep-alive, Strict-Transport-Security=max-age=15724800; includeSubDomains,
max-age=31536000; includeSubDomains, X-Cs-Region=us-1, X-Cs-Traceid=4a13cac5-51e1-40f5-9d7e-f61651ecacba,
X-Ratelimit-Limit=6000, X-Ratelimit-Remaining=5995, Date=Fri, 12 May 2023 16:30:58 GMT, Server=nginx
VERBOSE: [Write-Result] meta.query_time=0.081751653, meta.trace_id=4a13cac5-51e1-40f5-9d7e-f61651ecacba,
meta.powered_by=cs.flightcontrolapi
uuid : REDACTED
cid : REDACTED
uid : bk***@crowdstrike.com
first_name : B***
last_name : K***
last_login_at : 2023-05-12T15:58:07.473297Z
created_at : 2022-08-15T19:54:17.376Z
roles : {6df995d6e7b54a208965e7f4811ae8e4, falcon_console_guest, scheduled_report_admin,
kubernetes_protection_analyst...} |
I think I see the problem. All of these parameters are causing PSFalcon to hit |
Reorganized parameter positioning for `Get-FalconRole`. Removed automatic redirection of `Id` values from `Get-FalconRole` when matching a `cid` (because it also matches custom role identifiers). Removed `UserId` as a parameter for the `/user-management/queries/roles/v1:get` endpoint when using `Get-FalconRole` because the same data is returned by the `/combined/` endpoint and they have overlapping parameters. Added `DirectOnly` parameter to `Get-FalconRole`.
Can you try replacing your local Assuming you're using 2.2.4, use this command to update the file, then reload PowerShell and re-import PSFalcon: (Invoke-WebRequest https://raw.githubusercontent.com/CrowdStrike/psfalcon/28b6cf77183505d7b254b5587864b83564ed66be/public/user-management.ps1).Content > $HOME\WindowsPowerShell\Modules\PSFalcon\2.2.4\public\user-management.ps1 If using the most current version (2.2.5), please change the destination path to reflect that. |
Your change works well - it returns correct set of roles. @{ But I think you are aware of that. J. |
Hello again. Any idea of when this fix could be available in production? J. |
I have not yet determined the next release date. I typically issue a new release once a significant number of changes have happened with the CrowdStrike APIs, or a significant performance increase is added in the general PSFalcon code. This usually falls around every 30-60 days. Were you able to apply the fix above? That should resolve the issue for you, and it can be applied after any PSFalcon installation. |
Hello! Leaving a note for our friends from parallel universes and intersecting timelines that have led them to this space. My PowerShell module path is different, mine was:
Before applying the patch:
After applying the patch:
|
Resolved in 2.2.6 release which has been published to GitHub and will be published on the PowerShell Gallery soon. |
Describe the bug
Get-FalconRole
andGet-FalconUser
return incorrect roles assigned to a user.I have 4 custom user roles created - ITOPS, SOCBASIC, SOCADM, CSADMIN - and I have assigned them to all users as needed. I am not using any of the built-in CS roles anymore.
When I use PSfalcon, I get something like this (I do not use these roles, they are not assigned to users):
falcon_console_guest,response_workflow_author,remote_responder_one,falconhost_analyst,scheduled_report_analyst...
When I use swagger (/user-management/combined/user-roles/v1), it gives me correct answer:
To Reproduce
Get-FalconUser -Include $INCL -Filter "assigned_cids:['150********************31']" -Detailed
or
Get-FalconRole -UserId <MYUSERID> -Cid '150********************31'
Expected behavior
Both PSfalcon commands must return correct set of assigned roles.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: