When building Functions, depending on which version of the Resilient Platform you are using, you may need to compose different logic to achieve the results you desire. One of the improvements in version 31 is a change in how we handle dictionary data structures. From this version onward you may iterate and access a dictionary's attributes using either the .keys() or .items() functions
Example:
if results.artifacts != None:
for artifact_type in results.artifacts.keys()
incident.addArtifact(artifact_type, result.artifacts[artifact_type], 'Artifact created using .keys() function')
if results.artifacts != None:
for artifact_type, artifact_value in results.artifacts.items()
incident.addArtifact(artifact_type, artifact_value, 'Artifact created using .items() function')
However, if you are using any previous version, you will need to change your approach to this problem. One way to get similar functionality is to break up a dictionary into 2 lists. One for the keys and one for the values. You can then get a handle on 1 key and 1 value in parallel using zip().
Example:
if results.artifact_keys_as_list and results.artifact_values_as_list:
for artifact_type, artifact_value in zip(results.artifact_keys_as_list,results.artifact_values_as_list):
incident.addArtifact(artifact_type, artifact_value, 'Gotten a handle on the key and the value simultaniously using zip()')
------------------------------
Ryan Gordon
------------------------------
Original Message:
Sent: 10-12-2018 14:11
From: Connor Costello
Subject: Tips and Tricks
Useful things you've come across while using Resilient.
It can pertain to:
- Implementation
- Integrations
- Reporting
- Workflows and functions
- And anything else you can think of
Thanks for sharing.
------------------------------
Connor Costello - Resilient
------------------------------