<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Advanced SOAR python, playbook custom function use in Splunk SOAR</title>
    <link>https://community.splunk.com/t5/Splunk-SOAR/Advanced-SOAR-python-playbook-custom-function-use/m-p/678404#M1430</link>
    <description>&lt;P&gt;&lt;SPAN&gt;SOARt_of_Lost,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the reply.&amp;nbsp; The whole VPE is kinda clunky, but I guess that's what part of the SOAR is for is to provide a visual programming interface.&lt;BR /&gt;&lt;BR /&gt;I ended up writing a python module and installed it via the backend procedure with pip.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Feb 2024 23:00:43 GMT</pubDate>
    <dc:creator>jokr</dc:creator>
    <dc:date>2024-02-22T23:00:43Z</dc:date>
    <item>
      <title>Advanced SOAR python, playbook custom function use</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Advanced-SOAR-python-playbook-custom-function-use/m-p/677001#M1425</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, I've got a problem with this playbook code block, the custom functions I try to execute seem to hang indefinitely,&amp;nbsp;I also know the custom function works because I've successfully used it from a utility block&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;I've tried a few different arrangements of this logic including initializing cfid with both the custom function calls and consolidating custom function names into a single while loop with the phantom.completed and have used pass instead of sleep.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But the custom function doesn't seem to return/complete.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jokr_0-1707414958450.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29309i868273D531751221/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jokr_0-1707414958450.png" alt="jokr_0-1707414958450.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's another example, which is basically the same except it consolidates the while loops and executes both the custom functions at the same time.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jokr_1-1707421147227.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29310iB2A740EFD1B8F97D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jokr_1-1707421147227.png" alt="jokr_1-1707421147227.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Once either of these above scenarios (or something similar) are successful I need to get the results from the custom function&amp;nbsp; executions (below pic), combine it into a single string and then send "data" to another function:&lt;BR /&gt;&amp;gt;&amp;nbsp;post_http_data(container=container, body=json.dumps({"text": data})&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jokr_2-1707421406710.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29311i220C593E71FFE5FC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jokr_2-1707421406710.png" alt="jokr_2-1707421406710.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any assistance would be great. Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 21:14:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Advanced-SOAR-python-playbook-custom-function-use/m-p/677001#M1425</guid>
      <dc:creator>jokr</dc:creator>
      <dc:date>2024-02-08T21:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced SOAR python, playbook custom function use</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Advanced-SOAR-python-playbook-custom-function-use/m-p/678123#M1429</link>
      <description>&lt;P&gt;In my limited testing, SOAR doesn't seem to like handling custom functions within a single code block. It doesn't want to wait for the custom function to actually finish before moving on.&lt;/P&gt;&lt;P&gt;For reference, first_code_block just calls a custom function and second_code_block runs phantom.completed() on that function.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SOARt_of_Lost_0-1708457439506.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29417i63EFE7CE3E0AF9DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SOARt_of_Lost_0-1708457439506.png" alt="SOARt_of_Lost_0-1708457439506.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you&amp;nbsp;&lt;EM&gt;have&amp;nbsp;&lt;/EM&gt;to call the function from within a code block, you can add a callback. This will make sure the code doesn't move on until the run finishes. I wasn't able to get the callback to work on a second function within the same block. (One note on this: Phantom will call the last two lines of the code block before the custom function finishes)&lt;/P&gt;&lt;LI-CODE lang="python"&gt;phantom.custom_function(... callback=second_code_block)&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SOARt_of_Lost_1-1708457766151.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29418i23A0DBCF6DB87C0D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SOARt_of_Lost_1-1708457766151.png" alt="SOARt_of_Lost_1-1708457766151.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The easiest method by far is to just put each custom function into their own block, then do whatever processing you need in a custom code block below. By default, SOAR will wait for any simultaneous blocks to finish before running the next step.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SOARt_of_Lost_2-1708458074154.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29419iE87325F6F40634E0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SOARt_of_Lost_2-1708458074154.png" alt="SOARt_of_Lost_2-1708458074154.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 19:46:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Advanced-SOAR-python-playbook-custom-function-use/m-p/678123#M1429</guid>
      <dc:creator>SOARt_of_Lost</dc:creator>
      <dc:date>2024-02-20T19:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced SOAR python, playbook custom function use</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Advanced-SOAR-python-playbook-custom-function-use/m-p/678404#M1430</link>
      <description>&lt;P&gt;&lt;SPAN&gt;SOARt_of_Lost,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the reply.&amp;nbsp; The whole VPE is kinda clunky, but I guess that's what part of the SOAR is for is to provide a visual programming interface.&lt;BR /&gt;&lt;BR /&gt;I ended up writing a python module and installed it via the backend procedure with pip.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 23:00:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Advanced-SOAR-python-playbook-custom-function-use/m-p/678404#M1430</guid>
      <dc:creator>jokr</dc:creator>
      <dc:date>2024-02-22T23:00:43Z</dc:date>
    </item>
  </channel>
</rss>

