<?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 How to extract fields from openSCAP using regex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-openSCAP-using-regex/m-p/373711#M109897</link>
    <description>&lt;P&gt;Hey all, &lt;/P&gt;

&lt;P&gt;I'm trying to extract fields from openSCAP logs and I'm having difficulties pulling the CCE/DISA fields, which don't occur in all of the entries. For some reason, they keep getting grouped under the "Rule" field (e.g. Rule's value is "partition_for_tmp Ident CCE-26435-8 Ident DISA FSO RHEL-06-000001"). I've tried several regexes, and none of them have successfully gotten me the fields I want despite working on an online regex tester for PCRE. If I could get some feedback on why I can't get Splunk to extract the fields, I'd appreciate it.&lt;BR /&gt;
transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[fields_for_scap]
REGEX = Title\n\t(.\*)\nRule\n\t(.\*)\n(?:Ident\n\t(.\*)\n(?:Ident\n\t(.\*)\n)?)?Result\n\t(.\*)
FORMAT = Title::$1 Rule::$2 CCE::$3 DISA::$4 Result::$5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Previously attempted regexes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = Title\n\t(.\*)\nRule\n\t(.\*)\n(?:Ident\n\t(.\*)\n)?(?:Ident\n\t(.\*)\n)?Result\n\t(.\*)
REGEX = Title\n\t(.\*)\nRule\n\t(.\*)(?:\nIdent\n\t)?(.\*|)(?:\nIdent\n\t)?(.\*|)\nResult\n\t(.\*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[scap]
SHOULD_LINEMERGE=false
LINE_BREAKER = (\n\n)
TRUNCATE=1000000
DATETIME_CONFIG = CURRENT
REPORT-fields_for_scap = fields_for_scap
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Title
  Ensure Solid State Drives Do Not Contribute To Random-Number Entropy Pool
Rule
  kernel_disable_entropy_contribution_for_solid_state_drives
Result
  pass

Title
  Ensure /tmp Located On Separate Partition
Rule
  partition_for_tmp
Ident
  CCE-26435-8
Ident
  DISA FSO RHEL-06-000001
Result
  pass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit:&lt;/P&gt;

&lt;P&gt;For anybody in the future reading this wondering how I resolved this, I followed the accepted answer and defined the regex a bit more precisely, e.g. using (\w+) for the Rule field instead of (.*) so that matching issues wouldn't occur. When I broke up the regex, I realized that Splunk was having issues matching the non-capturing group (?:Ident), so there may be a problem with that.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 18:02:54 GMT</pubDate>
    <dc:creator>zsanchez113</dc:creator>
    <dc:date>2020-09-29T18:02:54Z</dc:date>
    <item>
      <title>How to extract fields from openSCAP using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-openSCAP-using-regex/m-p/373711#M109897</link>
      <description>&lt;P&gt;Hey all, &lt;/P&gt;

&lt;P&gt;I'm trying to extract fields from openSCAP logs and I'm having difficulties pulling the CCE/DISA fields, which don't occur in all of the entries. For some reason, they keep getting grouped under the "Rule" field (e.g. Rule's value is "partition_for_tmp Ident CCE-26435-8 Ident DISA FSO RHEL-06-000001"). I've tried several regexes, and none of them have successfully gotten me the fields I want despite working on an online regex tester for PCRE. If I could get some feedback on why I can't get Splunk to extract the fields, I'd appreciate it.&lt;BR /&gt;
transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[fields_for_scap]
REGEX = Title\n\t(.\*)\nRule\n\t(.\*)\n(?:Ident\n\t(.\*)\n(?:Ident\n\t(.\*)\n)?)?Result\n\t(.\*)
FORMAT = Title::$1 Rule::$2 CCE::$3 DISA::$4 Result::$5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Previously attempted regexes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = Title\n\t(.\*)\nRule\n\t(.\*)\n(?:Ident\n\t(.\*)\n)?(?:Ident\n\t(.\*)\n)?Result\n\t(.\*)
REGEX = Title\n\t(.\*)\nRule\n\t(.\*)(?:\nIdent\n\t)?(.\*|)(?:\nIdent\n\t)?(.\*|)\nResult\n\t(.\*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[scap]
SHOULD_LINEMERGE=false
LINE_BREAKER = (\n\n)
TRUNCATE=1000000
DATETIME_CONFIG = CURRENT
REPORT-fields_for_scap = fields_for_scap
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Title
  Ensure Solid State Drives Do Not Contribute To Random-Number Entropy Pool
Rule
  kernel_disable_entropy_contribution_for_solid_state_drives
Result
  pass

Title
  Ensure /tmp Located On Separate Partition
Rule
  partition_for_tmp
Ident
  CCE-26435-8
Ident
  DISA FSO RHEL-06-000001
Result
  pass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit:&lt;/P&gt;

&lt;P&gt;For anybody in the future reading this wondering how I resolved this, I followed the accepted answer and defined the regex a bit more precisely, e.g. using (\w+) for the Rule field instead of (.*) so that matching issues wouldn't occur. When I broke up the regex, I realized that Splunk was having issues matching the non-capturing group (?:Ident), so there may be a problem with that.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:02:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-openSCAP-using-regex/m-p/373711#M109897</guid>
      <dc:creator>zsanchez113</dc:creator>
      <dc:date>2020-09-29T18:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from openSCAP using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-openSCAP-using-regex/m-p/373712#M109898</link>
      <description>&lt;P&gt;Maybe just use multiple separate REPORT statements, one for each field, such that you can keep the regexes much simpler and don't have to worry about some fields not always being present.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 17:39:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-openSCAP-using-regex/m-p/373712#M109898</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-02-12T17:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from openSCAP using regex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-openSCAP-using-regex/m-p/373713#M109899</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = Title[\r\n]\s*([^\r\n]*)[\s\S]*?Rule[\r\n]*\s*([^\r\n]*)([\r\n]*\s*Ident[\r\n]*\s*([^\r\n]*)[\s\S]*?Ident[\r\n]*\s*([^\r\n]*))?[\s\S]*?Result[\r\n]*\s*([^\r\n]*)
FORMAT = Title::$1 Rule::$2 CCE::$4 DISA::$5 Result::$6
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's fairly efficient.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 00:59:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-openSCAP-using-regex/m-p/373713#M109899</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-02-13T00:59:11Z</dc:date>
    </item>
  </channel>
</rss>

