question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ BUG ] Aggregate Notifications dict instead of list

See original GitHub issue

Describe the bug When making a request to the AggregateNotificationsV1 endpoint, not using the body argument, but individual keywords, the API returns: "code": 400, "message": "Invalid aggregates request, json: cannot unmarshal object into Go value of type []*msa.AggregateQueryRequest", "message_key": "INVALID_AGGREGATES" }

The problem is that the request body is sent like this: { arguments... } instead of [ { arguments.... } ]

To Reproduce

falcon = recon.Recon(access_token=self.token, base_url=self.base_url)
filter = "string" # in my case "selector_id:['x', 'y',...]"
response = falcon.aggregate_notifications(name="Hit count per selector", type="terms", field="selector_id", filter=filter, size=10)
print(response)

Expected behavior Should return a resources list based on the filter.

Environment (please complete the following information):

  • OS: Windows
  • Python: 3.9
  • FalconPy: 1.1.1

Additional context When using the body argument, it’s possible to make a successful request, however the IDE gives a warning as body should be a dict and not list[dict].

body = [{"field": "selector_id",
                 "filter": "string",
                 "name": "Hit count per selector",
                 "size": 10,
                 "type": "terms"}]
response = falcon.aggregate_notifications(body=body)
print(response)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JulianIntargiacommented, May 19, 2022

Thank you for the quick work! I tested it out and now it works as expected, and so far I’ve encountered no issues.

0reactions
jshcodescommented, May 19, 2022

Hi @JulianIntargia!

This was a good find, thank you again for reporting it. Three Service Classes had this issue where they were passing expected aggregate list payloads as dictionaries. (Detects, MessageCenter and Recon).

Interestingly enough, there are a couple of service classes that specify they do not want lists here (QuickScan, Quarantine), so addressing this within the payload handler was overly complex.

Instead, I’ve handled the issue within the affected Service Classes the same way the other classes handle it, wrapping the return from the handler in a list when it assigns it to body. For sending multiple updates via a single payload, you’ll still be able to specify body directly.

FalconPy v1.1.2 will release containing this update, and has already started the process through our approval cycle. If you’d like to test things out and let us know of any feedback or issues, you can install the crowdstrike-falconpy-dev package (v1.1.2.dev1) and check it out.

Remove the current version of FalconPy from the environment before installing this version.

python3 -m pip install crowdstrike-falconpy-dev==1.1.2.dev1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: Group and aggregate list of dictionaries [without ...
The problem you are having is that you are trying to do a dictionary comprehension which wasn't added until python 2.7.
Read more >
AsyncIOMotorDatabase — Motor 3.1.1 documentation
The aggregate() method obeys the read_preference of this MotorDatabase , except when $out or $merge are used, in which case PRIMARY is used....
Read more >
How to Handle Unhashable Type List Exceptions in Python
The Python TypeError: Unhashable Type: 'list' happens when a mutable list, instead of an immutable tuple, is used as a hash argument.
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
Notification emails - GitLab Docs
Stay informed about what's happening in GitLab with email notifications. You can receive updates about activity in issues, merge requests, epics, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found