<?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: Can I filter on hostnames in an array? in Cortex XDR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253743#M9325</link>
    <description>&lt;P&gt;No, Palo Alto.&lt;BR /&gt;My own reply did not fix the problem.&lt;/P&gt;</description>
    <pubDate>Mon, 11 May 2026 07:12:44 GMT</pubDate>
    <dc:creator>edvardgooijenga</dc:creator>
    <dc:date>2026-05-11T07:12:44Z</dc:date>
    <item>
      <title>Can I filter on hostnames in an array?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253548#M9316</link>
      <description>&lt;P&gt;I'm running the following script, it should display the critical vulnerabilities on MacOS systems.&lt;BR /&gt;&lt;BR /&gt;//List critical vulnerabilities on all MacOS endpoints&lt;BR /&gt;config case_sensitive = false&lt;BR /&gt;| dataset = va_cves&lt;BR /&gt;| filter os_type = ENUM.MACOS and severity = ENUM.CRITICAL &lt;BR /&gt;| fields severity,name,description,affected_products,type,severity_score,os_type,affected_hosts_count,affected_hosts,modification_date,publication_date,exploitability_score&lt;BR /&gt;| sort desc severity_score&lt;BR /&gt;&lt;BR /&gt;The problem is that the affected_hosts array also contains Windows systems that are affected by the same CVE's.&lt;BR /&gt;How can I filter so it only reports MacOS systems?&lt;BR /&gt;All our Macbook names start with "MBP-" but I was not able to filter on that , so far.&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2026 19:16:29 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253548#M9316</guid>
      <dc:creator>edvardgooijenga</dc:creator>
      <dc:date>2026-05-06T19:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can I filter on hostnames in an array?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253621#M9318</link>
      <description>&lt;P&gt;&amp;nbsp;was able to sort it out a bit more.&lt;BR /&gt;&lt;BR /&gt;dataset = va_cves &lt;BR /&gt;| filter os_type contains "*MAC*" and severity = ENUM.CRITICAL &lt;BR /&gt;| arrayexpand affected_hosts &lt;BR /&gt;| filter affected_hosts contains "MBP-*"&lt;BR /&gt;| arrayexpand os_type&lt;BR /&gt;| filter os_type contains "*MAC*"&lt;BR /&gt;//| alter abc = json_extract(affected_hosts ,"$.version")&lt;BR /&gt;| fields severity,name,description,affected_products,type,severity_score,os_type,affected_hosts_count,affected_hosts,modification_date,publication_date,exploitability_score &lt;BR /&gt;| sort desc severity_score, desc name&lt;BR /&gt;&lt;BR /&gt;This returns Macbooks only but hostname_count field needs work and affected_products also.&lt;BR /&gt;Would be even nicer to have one row with all the Macbook name for each CVE instead of each Macbook having its own row.&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2026 10:29:02 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253621#M9318</guid>
      <dc:creator>edvardgooijenga</dc:creator>
      <dc:date>2026-05-07T10:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can I filter on hostnames in an array?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253743#M9325</link>
      <description>&lt;P&gt;No, Palo Alto.&lt;BR /&gt;My own reply did not fix the problem.&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2026 07:12:44 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253743#M9325</guid>
      <dc:creator>edvardgooijenga</dc:creator>
      <dc:date>2026-05-11T07:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can I filter on hostnames in an array?</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253759#M9326</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/1660628707"&gt;@edvardgooijenga&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Greetings for the day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-end="350" data-start="0"&gt;To filter the &lt;CODE data-end="30" data-start="14"&gt;affected_hosts&lt;/CODE&gt; array to only include MacOS systems (specifically those starting with &lt;CODE data-end="109" data-start="101"&gt;"MBP-"&lt;/CODE&gt;), you must use array-processing functions. In the &lt;CODE data-end="169" data-start="160"&gt;va_cves&lt;/CODE&gt; dataset, a single row representing a CVE may include hostnames from multiple operating systems within its array fields, even if a dataset-level filter is applied to the row itself.&lt;/P&gt;
&lt;P data-end="350" data-start="0"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-end="426" data-start="352"&gt;There are two primary ways to achieve this in Cortex Query Language (XQL).&lt;/P&gt;
&lt;P data-end="426" data-start="352"&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 data-end="480" data-start="428" data-section-id="3nyv7s"&gt;Option 1: Clean the Array (Keep One Row per CVE)&lt;/H4&gt;
&lt;P data-end="712" data-start="482"&gt;Use the &lt;CODE data-end="504" data-start="490"&gt;array_filter&lt;/CODE&gt; function to remove non-matching hostnames from the array before displaying the results. This is ideal if you want a summary report where each CVE appears once, but the list of hosts only shows your Macbooks.&lt;/P&gt;
&lt;P data-end="799" data-start="714"&gt;For prefix matching, use the regex match operator (&lt;CODE data-end="769" data-start="765"&gt;~=&lt;/CODE&gt;) with the start anchor (&lt;CODE data-end="797" data-start="794"&gt;^&lt;/CODE&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="relative w-full mt-4 mb-1"&gt;
&lt;DIV class=""&gt;
&lt;DIV class="relative"&gt;
&lt;DIV class="h-full min-h-0 min-w-0"&gt;
&lt;DIV class="h-full min-h-0 min-w-0"&gt;
&lt;DIV class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"&gt;
&lt;DIV class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"&gt;
&lt;DIV class="pointer-events-none absolute inset-x-4 top-12 bottom-4"&gt;
&lt;DIV class="pointer-events-none sticky z-40 shrink-0 z-1!"&gt;
&lt;DIV class="sticky bg-token-border-light"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="relative"&gt;
&lt;DIV class=""&gt;
&lt;DIV class="relative z-0 flex max-w-full"&gt;
&lt;DIV id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼd ͼr" dir="ltr"&gt;
&lt;DIV class="cm-scroller"&gt;
&lt;PRE class="cm-content q9tKkq_readonly m-0"&gt;&lt;CODE&gt;&lt;SPAN&gt;// List critical vulnerabilities on MacOS endpoints starting with "MBP-"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;config case_sensitive = false&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| dataset = va_cves&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| filter os_type = ENUM.MACOS and severity = ENUM.CRITICAL&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Re-calculate the array to only include hostnames starting with "MBP-"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| alter affected_hosts = array_filter(affected_hosts, (h) =&amp;gt; h ~= "^MBP-")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Update the count to reflect the filtered array&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| alter affected_hosts_count = array_length(affected_hosts)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Optional: Filter out any CVEs that have no remaining hosts after the filter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| filter affected_hosts_count &amp;gt; 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;| fields severity,name,description,affected_products,type,severity_score,os_type,affected_hosts_count,affected_hosts,modification_date,publication_date,exploitability_score&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| sort desc severity_score&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;Option 2: Expand the Array (One Row per Macbook):&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P data-end="1825" data-start="1624"&gt;Use the &lt;CODE data-end="1645" data-start="1632"&gt;arrayexpand&lt;/CODE&gt; function to transform each element of the &lt;CODE data-end="1704" data-start="1688"&gt;affected_hosts&lt;/CODE&gt; array into its own individual record. This is the best approach if you need a detailed list of every vulnerable Macbook.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="relative w-full mt-4 mb-1"&gt;
&lt;DIV class=""&gt;
&lt;DIV class="relative"&gt;
&lt;DIV class="h-full min-h-0 min-w-0"&gt;
&lt;DIV class="h-full min-h-0 min-w-0"&gt;
&lt;DIV class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl"&gt;
&lt;DIV class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback"&gt;
&lt;DIV class="pointer-events-none absolute inset-x-4 top-12 bottom-4"&gt;
&lt;DIV class="pointer-events-none sticky z-40 shrink-0 z-1!"&gt;
&lt;DIV class="sticky bg-token-border-light"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="relative"&gt;
&lt;DIV class=""&gt;
&lt;DIV class="relative z-0 flex max-w-full"&gt;
&lt;DIV id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼd ͼr" dir="ltr"&gt;
&lt;DIV class="cm-scroller"&gt;
&lt;PRE class="cm-content q9tKkq_readonly m-0"&gt;&lt;CODE&gt;&lt;SPAN&gt;// List one row per Macbook for critical vulnerabilities&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;config case_sensitive = false&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| dataset = va_cves&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| filter os_type = ENUM.MACOS and severity = ENUM.CRITICAL&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Flattens the array so each host is a separate row&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| arrayexpand affected_hosts&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// Filter hostnames using triple double quotes for prefix wildcard search&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| filter affected_hosts = """MBP-*"""&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;| fields severity,name,description,affected_products,type,severity_score,os_type,affected_hosts,modification_date,publication_date,exploitability_score&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;| sort desc severity_score&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;Supported String Matching for Prefixes:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P data-end="2535" data-start="2425"&gt;When filtering for hostnames starting with a specific string like &lt;CODE data-end="2499" data-start="2491"&gt;"MBP-"&lt;/CODE&gt;, XQL supports the following syntax:&lt;/P&gt;
&lt;UL data-is-only-node="" data-is-last-node="" data-end="2850" data-start="2537"&gt;
&lt;LI data-end="2613" data-start="2537" data-section-id="1hlyrvc"&gt;&lt;STRONG data-end="2562" data-start="2539"&gt;Regex Match (&lt;CODE data-end="2558" data-start="2554"&gt;~=) :&amp;nbsp;&lt;/CODE&gt;&lt;/STRONG&gt; Use &lt;CODE data-end="2579" data-start="2567"&gt;~= "^MBP-"&lt;/CODE&gt; to match the start of the string.&lt;/LI&gt;
&lt;LI data-end="2711" data-start="2614" data-section-id="mxaogi"&gt;&lt;STRONG data-end="2643" data-start="2616"&gt;Wildcard Prefix Search:&lt;/STRONG&gt; Use triple double quotes with an asterisk, such as &lt;CODE data-end="2710" data-start="2695"&gt;= """MBP-*"""&lt;/CODE&gt;.&lt;/LI&gt;
&lt;LI data-is-last-node="" data-end="2850" data-start="2712" data-section-id="1qt5xk8"&gt;&lt;STRONG data-end="2730" data-start="2714"&gt;Containment:&lt;/STRONG&gt; The &lt;CODE data-end="2745" data-start="2735"&gt;CONTAINS&lt;/CODE&gt; operator can be used, but it matches the string anywhere (for example, &lt;CODE data-end="2831" data-start="2817"&gt;"OLD-MBP-01"&lt;/CODE&gt; would also match).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If you feel this has answered your query, please let us know by clicking&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;like&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and on&amp;nbsp;&lt;STRONG&gt;"mark this as a Solution".&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;BR /&gt;S. Subashkar Sekar&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2026 14:17:29 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/can-i-filter-on-hostnames-in-an-array/m-p/1253759#M9326</guid>
      <dc:creator>susekar</dc:creator>
      <dc:date>2026-05-11T14:17:29Z</dc:date>
    </item>
  </channel>
</rss>

