<?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: Help with regex in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65886#M4081</link>
    <description>&lt;P&gt;I think it's because there's a hyphen missing inside the innermost square brackets.  Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?s)--[0-9a-f]+-H--\n.*\[msg \"(?P&amp;lt;msg&amp;gt;[\w\s\/.-]+)\"\]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;instead.  (In case it's hard to see, the difference is 8 characters from the end.)&lt;/P&gt;

&lt;P&gt;Your previous regex was only looking for letters, numbers, underscores, whitespace, slashes and dots between the double quotes.  Hence it didn't match because "CSRF Attack Detected - Missing CSRF Token" has a hyphen in the middle.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2013 13:01:35 GMT</pubDate>
    <dc:creator>dmr195</dc:creator>
    <dc:date>2013-03-19T13:01:35Z</dc:date>
    <item>
      <title>Help with regex</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65885#M4080</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I extracted a field with Splunk Field Extractor which seemed to work until I noticed it didn't capture all messages (i.e. &lt;STRONG&gt;CSRF Attack Detected - Missing CSRF Token&lt;/STRONG&gt;) from ModSecurity.&lt;/P&gt;

&lt;P&gt;Here some Log msg:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;--f7d234hc-H--&lt;BR /&gt;
Message: Warning. Match of "eq 1" against "&amp;amp;ARGS:CSRF_TOKEN" required. [file "/cut/modsecurity_crs_43_csrf_protection.conf"] [line "31"] [id "981143"] [msg "CSRF Attack Detected - Missing CSRF Token."]&lt;BR /&gt;
Message: Failed to write to DBM file "/tmp/global": Invalid argument&lt;BR /&gt;
Apache-Handler: perl-script&lt;BR /&gt;
--f7d3t15d-Z--&lt;/CODE&gt;&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;This is what the app gave me&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?s)--[0-9a-f]+-H--\n.*\[msg \"(?P&amp;lt;msg&amp;gt;[\w\s\/.]+)\"\]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there something wrong with it? Can it be done more efficiently?&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;

&lt;P&gt;Cheers&lt;BR /&gt;
Mike&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:32:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65885#M4080</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2020-09-28T13:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65886#M4081</link>
      <description>&lt;P&gt;I think it's because there's a hyphen missing inside the innermost square brackets.  Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?s)--[0-9a-f]+-H--\n.*\[msg \"(?P&amp;lt;msg&amp;gt;[\w\s\/.-]+)\"\]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;instead.  (In case it's hard to see, the difference is 8 characters from the end.)&lt;/P&gt;

&lt;P&gt;Your previous regex was only looking for letters, numbers, underscores, whitespace, slashes and dots between the double quotes.  Hence it didn't match because "CSRF Attack Detected - Missing CSRF Token" has a hyphen in the middle.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2013 13:01:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65886#M4081</guid>
      <dc:creator>dmr195</dc:creator>
      <dc:date>2013-03-19T13:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65887#M4082</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;here are more things to be considered: &lt;/P&gt;

&lt;P&gt;(a) it seams that the message does not start with a hex-coded ID in hyphens and that "H"&lt;BR /&gt;
(b) you aren't getting the whole message text if it contains a hyphen&lt;/P&gt;

&lt;P&gt;Something like this should work:&lt;BR /&gt;
&lt;CODE&gt;(?s)--[0-9a-z]+-[A-Z]--\n.*\[msg \"(?P&amp;lt;msg&amp;gt;[-\w\s\/.]+)\"\]&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2013 13:10:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65887#M4082</guid>
      <dc:creator>bjoernjensen</dc:creator>
      <dc:date>2013-03-19T13:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65888#M4083</link>
      <description>&lt;P&gt;It seems, that did the trick. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2013 14:12:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65888#M4083</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-03-19T14:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65889#M4084</link>
      <description>&lt;P&gt;thanks to you, too. I tried that as well and worked. have a great one.&lt;BR /&gt;
cheers&lt;BR /&gt;
Mike&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2013 14:13:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65889#M4084</guid>
      <dc:creator>lemikg</dc:creator>
      <dc:date>2013-03-19T14:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65890#M4085</link>
      <description>&lt;P&gt;I feel a little guilty that my answer was accepted here, as I missed the first required change.  The regex in this answer is the one to use.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 09:29:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Help-with-regex/m-p/65890#M4085</guid>
      <dc:creator>dmr195</dc:creator>
      <dc:date>2013-03-20T09:29:01Z</dc:date>
    </item>
  </channel>
</rss>

