QUESTION

 When I write a detection with Panther, how do I retrieve a value from a field in ingested data when the field is nested in other JSON fields?

ANSWER

You can use the Python helper function deep_get for this. It returns a value nested in data at any depth. It is used in many of Panther's built-in detections and helpers, such as this one.

To use deep_get:

Example JSON data:

In the case where deep_get doesn't find the field it's looking for, it returns the Python None instead of the value of the field. For example, when using this JSON:

{ "event": { "outcome": { "result": "SUCCESS" } } }

this Python prints SUCCESS 

print(deep_get(data, "event", "outcome", "result"))

and this Python prints None

print(deep_get(data, "event", "outcome", "resulterino"))