Getting Data In

Is Python the only supported language, or can I create a custom command or macro via Ruby?

daniel333
Builder

All,

A vendor just sent me this script to decode their vendor message table. It's not just a simple lookup, but a concatenation with several events. I see guides on Python. Is that the only supported language for custom commands? Should I just use Python to wrap this? Any guides on this?

thanks!

#!/usr/bin/env ruby
# to use:
#   chmod 744 threat_extract.rb
#   ./threat_extract.rb $THREATS_NUMBER

arg = ARGV.first.to_i

hsh = {
     1 => 'Known Violators',
     2 => 'Blocked Country',
     4 => 'Browser Integrity Check',
     8 => 'Known Violator User Agent',
    16 => 'Rate Limited',
    32 => 'Known Violator Honeypot Access',
    64 => 'Referrer Block',
   128 => 'Session Length Exceeded',
   256 => 'Pages Per Session Exceeded',
   512 => 'Bad User Agents',
  1024 => 'Aggregator User Agents',
  2048 => 'Filtered IP',
  4096 => 'JavaScript Not Loaded',
  8192 => 'JavaScript Check Failed',
 16384 => 'Identifier Validation Error',
 32768 => 'Known Violator Automation Tool',
 65536 => 'Form Spam Submission',
131072 => 'Unverified Signature',
262144 => 'IP Pinning Failure',
524288 => 'Invalid JavaScript Test Results',
1048576 => 'Organization Block',
2097152 => 'Known Violator Data Center'
}

puts *hsh.reject { |(k, v)| (k & arg).zero? }.map {|(k, v)| "#{k} => #{v}"}
0 Karma

woodcock
Esteemed Legend

IMHO, this is a simple enough script, I would go ahead and port it to python as a scripted/external lookup. It is well worth the exercise and once you have done it once, you can add that to your Splunk toolbox.

0 Karma
Get Updates on the Splunk Community!

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...