I used a custom function that parses out email addresses from an alert, I used the phantom.add_artifact function to add the artifact to the container. I am then using a filter to check for the artifact ("artifact:*.label", "==", "notiresponse"). It evaluates as false each time even though if I check the container it is there. What can I do to ensure that the filter is seeing this artifact? When I check the debug log, I can see the loop checking against all of the artifacts in the container except for the one I am creating via custom function. We have multiple playbooks that do this, but this one, in particular, is giving me trouble.
@crayford it sounds like you are hitting a scope issue. As the new artifact is created in the playbook run, the playbook is not aware of the new item unless you tell it to look by setting the correct scope when required.
Depending on the version of Phantom you are using there are 2 ways to fix this:
pre-v5.0.1 - In your filter or decision (or any block) where you need to query the new artifact, update the phantom.x() API call to include `scope = 'all'`
Below are the 3 main calls where scope can be set to see newly created artifacts
phantom.condition docs: https://docs.splunk.com/Documentation/Phantom/4.10.7/PlaybookAPI/PlaybookAPI#condition
phantom.decision docs: https://docs.splunk.com/Documentation/Phantom/4.10.7/PlaybookAPI/PlaybookAPI#decision
phantom.collect2 docs: https://docs.splunk.com/Documentation/Phantom/4.10.7/PlaybookAPI/DataAccessAPI#collect2
v5.0.1 - On the custom function block (Utility) you can select "Refresh event data" on the settings of the function block and this will update the "container" variable so that new items created in the function can be seen.
Hope this helps! Happy Phantoming Splunk SOAR-ing 😄
@crayford it sounds like you are hitting a scope issue. As the new artifact is created in the playbook run, the playbook is not aware of the new item unless you tell it to look by setting the correct scope when required.
Depending on the version of Phantom you are using there are 2 ways to fix this:
pre-v5.0.1 - In your filter or decision (or any block) where you need to query the new artifact, update the phantom.x() API call to include `scope = 'all'`
Below are the 3 main calls where scope can be set to see newly created artifacts
phantom.condition docs: https://docs.splunk.com/Documentation/Phantom/4.10.7/PlaybookAPI/PlaybookAPI#condition
phantom.decision docs: https://docs.splunk.com/Documentation/Phantom/4.10.7/PlaybookAPI/PlaybookAPI#decision
phantom.collect2 docs: https://docs.splunk.com/Documentation/Phantom/4.10.7/PlaybookAPI/DataAccessAPI#collect2
v5.0.1 - On the custom function block (Utility) you can select "Refresh event data" on the settings of the function block and this will update the "container" variable so that new items created in the function can be seen.
Hope this helps! Happy Phantoming Splunk SOAR-ing 😄
Very helpful answer, thanks!
That worked! Thanks for the help.