<?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 cortex XDR run_script and execute_commands in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/cortex-xdr-run-script-and-execute-commands/m-p/401183#M2635</link>
    <description>&lt;P&gt;I've being testing some of the built in scripts that come with cortex.&amp;nbsp; i.e the #list_directories and&amp;nbsp;#file_exists are working nicely.&lt;BR /&gt;&lt;BR /&gt;Im having difficulty using similar parameters running the&amp;nbsp;execute_commands script.&lt;BR /&gt;&lt;BR /&gt;example of&amp;nbsp;list_directories which works:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;data='{"request_data":{"filters":[{"field":"endpoint_id_list","operator":"in","value":["REDACTED"]}],"script_uid":"REDACTED","parameters_values":{"path":"/Users/","number_of_levels":1}}}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So on the server side, the script takes in the two parameters:&lt;BR /&gt;def run(path, number_of_levels):&lt;/P&gt;&lt;P&gt;and we get the expected results back successfully&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for the&amp;nbsp;execute_commands script. Im using:&lt;BR /&gt;data='{"request_data":{"filters":[{"field":"endpoint_id_list","operator":"in","value":["REDACTED"]}],"script_uid":"REDACTED","parameters_values":{"commands_list":["pwd","ls"]}}}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the server side I see the function takes in a list, and runs through a for loop on it:&lt;BR /&gt;def run(commands_list):&lt;BR /&gt;result = {}&lt;BR /&gt;for command in commands_list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;although the error returned shows:&lt;BR /&gt;{'reply': {'err_code': 500, 'err_msg': 'Got an invalid input while processing XDR public API', 'err_extra': 'commands_list must be of type: str'}}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tested the actual function on my own laptop, and it does work fine when passing it a list of commands:&lt;/P&gt;&lt;P&gt;i.e&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-04-22 at 09.24.29.png" style="width: 867px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/32387iB39F1F8F2E44B78D/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-04-22 at 09.24.29.png" alt="Screenshot 2021-04-22 at 09.24.29.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has any pointers, thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Apr 2021 08:26:29 GMT</pubDate>
    <dc:creator>cheesy_dibbles</dc:creator>
    <dc:date>2021-04-22T08:26:29Z</dc:date>
    <item>
      <title>cortex XDR run_script and execute_commands</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/cortex-xdr-run-script-and-execute-commands/m-p/401183#M2635</link>
      <description>&lt;P&gt;I've being testing some of the built in scripts that come with cortex.&amp;nbsp; i.e the #list_directories and&amp;nbsp;#file_exists are working nicely.&lt;BR /&gt;&lt;BR /&gt;Im having difficulty using similar parameters running the&amp;nbsp;execute_commands script.&lt;BR /&gt;&lt;BR /&gt;example of&amp;nbsp;list_directories which works:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;data='{"request_data":{"filters":[{"field":"endpoint_id_list","operator":"in","value":["REDACTED"]}],"script_uid":"REDACTED","parameters_values":{"path":"/Users/","number_of_levels":1}}}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So on the server side, the script takes in the two parameters:&lt;BR /&gt;def run(path, number_of_levels):&lt;/P&gt;&lt;P&gt;and we get the expected results back successfully&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for the&amp;nbsp;execute_commands script. Im using:&lt;BR /&gt;data='{"request_data":{"filters":[{"field":"endpoint_id_list","operator":"in","value":["REDACTED"]}],"script_uid":"REDACTED","parameters_values":{"commands_list":["pwd","ls"]}}}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the server side I see the function takes in a list, and runs through a for loop on it:&lt;BR /&gt;def run(commands_list):&lt;BR /&gt;result = {}&lt;BR /&gt;for command in commands_list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;although the error returned shows:&lt;BR /&gt;{'reply': {'err_code': 500, 'err_msg': 'Got an invalid input while processing XDR public API', 'err_extra': 'commands_list must be of type: str'}}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tested the actual function on my own laptop, and it does work fine when passing it a list of commands:&lt;/P&gt;&lt;P&gt;i.e&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-04-22 at 09.24.29.png" style="width: 867px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/32387iB39F1F8F2E44B78D/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-04-22 at 09.24.29.png" alt="Screenshot 2021-04-22 at 09.24.29.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has any pointers, thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 08:26:29 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/cortex-xdr-run-script-and-execute-commands/m-p/401183#M2635</guid>
      <dc:creator>cheesy_dibbles</dc:creator>
      <dc:date>2021-04-22T08:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: cortex XDR run_script and execute_commands</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/cortex-xdr-run-script-and-execute-commands/m-p/401288#M2638</link>
      <description>&lt;P&gt;passing in different parameters Im finding that if I pass in a list:&lt;/P&gt;&lt;P&gt;"parameters_values":{"commands_list":["ls"]}&lt;BR /&gt;{'err_code': 500,&lt;BR /&gt;'err_extra': 'commands_list must be of type: str',&lt;BR /&gt;'err_msg': 'Got an invalid input while processing XDR public API'}}&lt;BR /&gt;&lt;STRONG&gt;Although if I pass in as a string:&lt;/STRONG&gt;&lt;BR /&gt;"parameters_values":{"commands_list":"ls"}&lt;/P&gt;&lt;P&gt;It does get though to the function, but then gets split apart into "l" and "s" in the function:&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;'standard_output': 'Running command &amp;lt;l&amp;gt;\n'&lt;BR /&gt;'stderr: \n'&lt;BR /&gt;'/bin/sh: l: command not found\n'&lt;BR /&gt;'\n'&lt;BR /&gt;'Running command &amp;lt;s&amp;gt;\n'&lt;BR /&gt;'stderr: \n'&lt;BR /&gt;'/bin/sh: s: command not found\n'}],&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 14:38:59 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/cortex-xdr-run-script-and-execute-commands/m-p/401288#M2638</guid>
      <dc:creator>cheesy_dibbles</dc:creator>
      <dc:date>2021-04-22T14:38:59Z</dc:date>
    </item>
  </channel>
</rss>

