Getting Data In

Dealing with badly structured json events

david_rose
Communicator

I am pulling in some json events that are poorly structured (at least for my needs). Specifically, I need to be able to tie the VULNS data to its ip address, which is above it. But since they are not nested, splunk is not able to make the connection. Is there any way to tie the IP address to the data below it or readjust the nesting of the event in a search?

Example data below

vulnerable_hosts: [ [-] 
         { [-] 
            ip_address:  xxx.xxx.xxx.xxx 
            vulns: [ [-] 
             { [-] 
                risk_level:  High 
                service_port:  443 
                service_protocol:  TCP 
                title:  SSL/TLS server supports RC4 ciphers 
             } 
             { [-] 
                risk_level:  Medium 
                service_port:  80 
                service_protocol:  TCP 
                title:  TCP timestamp requests enabled 
             } 
             { [-] 
                risk_level:  Medium 
                service_port:  443 
                service_protocol:  TCP 
                title:  SSL certificate is signed with weak hash function: SHA1 
             } 
           ] 
         } 
         { [-] 
            ip_address:  yyy.yyy.yyy.yyy 
            vulns: [ [-] 
             { [-] 
                risk_level:  Urgent 
                service_port:  161 
                service_protocol:  UDP 
                title:  SNMP is enabled and may be vulnerable 
             } 
             { [-] 
                risk_level:  Low 
                service_port:  0 
                service_protocol:  ICMP 
                title:  ICMP timestamp requests enabled 
             } 
           ] 
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

You need a two-step approach:

... | spath vulnerable_hosts{} output=vulnerable_hosts | mvexpand vulnerable_hosts | spath input=vulnerable_hosts

First you extract the objects inside the vulnerable_hosts array, then you turn them into individual events, finally you extract the content of those objects.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

You need a two-step approach:

... | spath vulnerable_hosts{} output=vulnerable_hosts | mvexpand vulnerable_hosts | spath input=vulnerable_hosts

First you extract the objects inside the vulnerable_hosts array, then you turn them into individual events, finally you extract the content of those objects.

david_rose
Communicator

Thanks Martin. But with this method, how can I connect the vulnerability to the the correct ip ?

david_rose
Communicator

Ignore that, it was there, just not presented in the events. You rock!

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...