Splunk Search

Regex question

sphc
Explorer

Hi!

if I can make groups from <VULN number ... to ... </VULN> with regex?

<VULN number="MP-412750" severity="5" cveid="CVE-2011-1276">
  <TITLE>   Excel</TITLE>
  <PCI_FLAG>1</PCI_FLAG>
  <CVSS_BASE>9.3</CVSS_BASE>
  <CVSS_TEMPORAL>6.9</CVSS_TEMPORAL>
  <CONSEQUENCE><![CDATA[Уязвимость, позволяющая удаленно выполнить код, существует в Microsoft Excel при обработке специально сформированных файлов Excel. В случае успешной эксплуатации данной уязвимости злоумышленник может получить полный контроль над системой и права на установку программ; просмотр, изменение или удаление данных или создание новых учетных записей с полными правами.]]></CONSEQUENCE>
  <DIAGNOSIS><![CDATA[Уязвимость позволяет атакующему выполнить произвольный код.]]></DIAGNOSIS>
  <RESULT>N/A</RESULT>
  <SOLUTION><![CDATA[Используйте рекомендации производителя:
  http://www.microsoft.com/technet/security/Bulletin/MS11-045.mspx]]></SOLUTION></VULN>
<VULN number="MP-412750" severity="5" cveid="CVE-2011-1276">
  <TITLE>   Excel</TITLE>
  <PCI_FLAG>1</PCI_FLAG>
  <CVSS_BASE>9.3</CVSS_BASE>
  <CVSS_TEMPORAL>6.9</CVSS_TEMPORAL>
  <CONSEQUENCE><![CDATA[Уязвимость, позволяющая удаленно выполнить код, существует в Microsoft Excel при обработке специально сформированных файлов Excel. В случае успешной эксплуатации данной уязвимости злоумышленник может получить полный контроль над системой и права на установку программ; просмотр, изменение или удаление данных или создание новых учетных записей с полными правами.]]></CONSEQUENCE>
  <DIAGNOSIS><![CDATA[Уязвимость позволяет атакующему выполнить произвольный код.]]></DIAGNOSIS>
  <RESULT>N/A</RESULT>
  <SOLUTION><![CDATA[Используйте рекомендации производителя:
  http://www.microsoft.com/technet/security/Bulletin/MS11-045.mspx]]></SOLUTION></VULN>
<VULN number="MP-412750" severity="5" cveid="CVE-2011-1276">
  <TITLE>   Excel</TITLE>
  <PCI_FLAG>1</PCI_FLAG>
  <CVSS_BASE>9.3</CVSS_BASE>
  <CVSS_TEMPORAL>6.9</CVSS_TEMPORAL>
  <CONSEQUENCE><![CDATA[Уязвимость, позволяющая удаленно выполнить код, существует в Microsoft Excel при обработке специально сформированных файлов Excel. В случае успешной эксплуатации данной уязвимости злоумышленник может получить полный контроль над системой и права на установку программ; просмотр, изменение или удаление данных или создание новых учетных записей с полными правами.]]></CONSEQUENCE>
  <DIAGNOSIS><![CDATA[Уязвимость позволяет атакующему выполнить произвольный код.]]></DIAGNOSIS>
  <RESULT>N/A</RESULT>
  <SOLUTION><![CDATA[Используйте рекомендации производителя:
  http://www.microsoft.com/technet/security/Bulletin/MS11-045.mspx]]></SOLUTION></VULN>

I want to separate them as events. Thank you!

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

For search-time extraction, try this. The exact regex string will depend on precisely what you want to extract. The mvexpand command splits the extracted fields into separate events.

<your base search> | rex max_match=0 "(?<vuln><VULN.*<\/VULN>)" | mvexpand vuln | ...
---
If this reply helps you, Karma would be appreciated.

View solution in original post

lfedak_splunk
Splunk Employee
Splunk Employee

Hey @sphc, if they solved your problem, remember to "√Accept" an answer to award karma points 🙂

0 Karma

sbbadri
Motivator

@sphc

try this in props.conf,

[yoursourcetype]
LINE_BREAKER = &lt;VULN
DATETIME_CONFIG =
KV_MODE = xml
NO_BINARY_CHECK = true
category = Custom
pulldown_type = true
SHOULD_LINEMERGE = false

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The LINE_BREAKER attribute needs a capture group. Try LINE_BREAKER = ()\<VULN.

---
If this reply helps you, Karma would be appreciated.
0 Karma

sbbadri
Motivator

i guess capture group is not necessary .. whenever it finds &lt;VULN it will break the event from there

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The docs say a capture group is necessary. Also, the contents of the capture group are discarded so be careful how you create your regex.

---
If this reply helps you, Karma would be appreciated.
0 Karma

jodyfsu
Path Finder

Here is what I came up with:

"| rex (VULN\s\w*="(?<number>\w*-\d*)"\s\w*="(?<severity>\d)"\s\w*="(?<cveid>\w*-\d*-\d*))"
0 Karma

richgalloway
SplunkTrust
SplunkTrust

For search-time extraction, try this. The exact regex string will depend on precisely what you want to extract. The mvexpand command splits the extracted fields into separate events.

<your base search> | rex max_match=0 "(?<vuln><VULN.*<\/VULN>)" | mvexpand vuln | ...
---
If this reply helps you, Karma would be appreciated.
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...