<?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: Running XQL Query to XDR from an Automation Script : Receiving 500 Bad Synatax from valid query in Cortex XSOAR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/533242#M1862</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/159920"&gt;@MBeauchamp2&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have recently placed the query in the the Automation Arguments and there is still the same problem that there is a bad character. We have decided to use the playbook instead. If you have a better solution please let me know.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 05 Mar 2023 14:27:02 GMT</pubDate>
    <dc:creator>michaelsysec242</dc:creator>
    <dc:date>2023-03-05T14:27:02Z</dc:date>
    <item>
      <title>Running XQL Query to XDR from an Automation Script : Receiving 500 Bad Synatax from valid query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/532363#M1839</link>
      <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am attempting to run an XQL query from an automation script. The query is valid and can be run manually and this works well both on XSOAR and on the Query Editor section on XDR. Essentially we refer to the query under a variable and then reference the variable under the execute command.... The error I receive is 500 -&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class="ui-provider cgy cgz c d e f g h i j k l m n o p q r s t cha chb w x y z ab ac ae af ag ah ai aj ak"&gt;token recognition error at: '''\"} It appears that what is causing this is the Quote&amp;nbsp;Marks around the query that are included in the command and this is likely the cause. Is there a way to safely run an XQL query in regards to best practice etc ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider cgy cgz c d e f g h i j k l m n o p q r s t cha chb w x y z ab ac ae af ag ah ai aj ak"&gt;Another question, I can use a saved query from the tenant and then to run it with my custom variables, is it possible to run a saved query with incident variables on an automation&amp;nbsp;?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider cgy cgz c d e f g h i j k l m n o p q r s t cha chb w x y z ab ac ae af ag ah ai aj ak"&gt;Many thanks,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider cgy cgz c d e f g h i j k l m n o p q r s t cha chb w x y z ab ac ae af ag ah ai aj ak"&gt;#XDR&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider cgy cgz c d e f g h i j k l m n o p q r s t cha chb w x y z ab ac ae af ag ah ai aj ak"&gt;#XSOAR&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider cgy cgz c d e f g h i j k l m n o p q r s t cha chb w x y z ab ac ae af ag ah ai aj ak"&gt;MR&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 16:12:46 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/532363#M1839</guid>
      <dc:creator>michaelsysec242</dc:creator>
      <dc:date>2023-02-27T16:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Running XQL Query to XDR from an Automation Script : Receiving 500 Bad Synatax from valid query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/532490#M1841</link>
      <description>&lt;P&gt;If you run the query via the command line, can you copy the argument to the automation?&amp;nbsp; The result should escape the quotes for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;It should work the same when used in an automation, if you're hard coding the query then you need to escape the quotes.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively add an argument to your automation and pass the query in that way, and you won't have to escape anything.&amp;nbsp; You can grab it as a variable and pass it to the executeCommand call.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 17:02:22 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/532490#M1841</guid>
      <dc:creator>MBeauchamp2</dc:creator>
      <dc:date>2023-02-28T17:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Running XQL Query to XDR from an Automation Script : Receiving 500 Bad Synatax from valid query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/532947#M1850</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/159920"&gt;@MBeauchamp2&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I have tried running a simpler XQL Query and I have succeeded in running in an getting results. Below I will attach both queries.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From What I can understand the difference between the two queries is that In the more complex one there are elements of regex for field value extraction. It appears that this may be the problem. I will attempt to run the automation with the Query as a static argument. I will update you if this works.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May thanks,&lt;/P&gt;
&lt;P&gt;MR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simple Query:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ww b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;&amp;nbsp;demisto.executeCommand("xdr-xql-generic-query", {"query":"dataset = xdr_data | filter event_type = ENUM.NETWORK | fields action_upload, action_remote_ip as remote_ip, action_external_hostname as remote_hostname, actor_process_image_name as process_name | comp sum(action_upload) as total_upload by process_name, remote_ip, remote_hostname | sort desc total_upload | limit 10","time_frame":"1 weeks ago", "query_name":"test20"})&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="ui-provider ww b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;Complex Query:&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;test2 = demisto.executeCommand("xdr-xql-generic-query", {"query":"dataset = xdr_data | filter event_type = ENUM.EVENT_LOG and action_evtlog_event_id in (7045, 4697) | alter Service_Name = arrayindex(regextract(action_evtlog_message, 'Service Name.*?(\w+)\\r\\n'),0), Service_cmd = arrayindex(regextract(action_evtlog_message,'Service File Name.*?(\w.*)\\r\\n'),0), Service_type = arrayindex(regextract(action_evtlog_message,'Service Type.*?(\w.*)\\r\\n'),0), Service_start_type = arrayindex(regextract(action_evtlog_message,'Service Start Type.*?(\w.*)\\r\\n'),0), Service_account = arrayindex(regextract(action_evtlog_message,'Service Account.*?(\w.*)'),0) | filter Service_cmd contains 'logonui.exe' | fields Service_Name, Service_cmd, Service_type, Service_start_type, Service_account, event_id","time_frame":"1 weeks ago", "query_name":"test20"})&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt; &lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2023 13:53:03 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/532947#M1850</guid>
      <dc:creator>michaelsysec242</dc:creator>
      <dc:date>2023-03-02T13:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Running XQL Query to XDR from an Automation Script : Receiving 500 Bad Synatax from valid query</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/533242#M1862</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/159920"&gt;@MBeauchamp2&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have recently placed the query in the the Automation Arguments and there is still the same problem that there is a bad character. We have decided to use the playbook instead. If you have a better solution please let me know.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Mar 2023 14:27:02 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xsoar-discussions/running-xql-query-to-xdr-from-an-automation-script-receiving-500/m-p/533242#M1862</guid>
      <dc:creator>michaelsysec242</dc:creator>
      <dc:date>2023-03-05T14:27:02Z</dc:date>
    </item>
  </channel>
</rss>

