<?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: How to assign a custom scoring scale based on device type? (eval related) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466350#M131328</link>
    <description>&lt;P&gt;First, create a &lt;CODE&gt;lookup file&lt;/CODE&gt; called &lt;CODE&gt;servertypes_scanner_weights.csv1&lt;/CODE&gt; with these fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;servertype,nessus_weight,metasploit_weight,nexpose_weight,norton_weight,tanium_weight,oprnvas_weight,Other_weight,Stuff_weight,Here_weight
routers,.4,.4,.1,0,0,0,0,0,0
another_type,0,0,0,.5,.75,0,0,0,0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, assuming that you have a field called &lt;CODE&gt;servertype&lt;/CODE&gt; (if not, create one, probably with &lt;CODE&gt;RegEx&lt;/CODE&gt; on &lt;CODE&gt;host&lt;/CODE&gt;), you do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup scanner_visbility.csv
| eventstats count(eval(ip)) as total 
             count(eval(norton="1")) as norton_count
             count(eval(tanium="1")) as tanium_count
             count(eval(nessus="1")) as nessus_count
             count(eval(metasploit="1")) as metasploit_count
             count(eval(openvas="1")) as oprnvas_count
             count(eval(nexpose="1")) as nexpose_count
| lookup servertypes_scanner_weights.csv servertype
| eval visibility = 0
| foreach *_count [ eval  visibility = visibility + (&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_weight * 100 * &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; / total) | fields - &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_* ]
| eval visibility = round(visibility, 2)
| fields visibility
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This also fixes rounding errors the way that you were doing it.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Dec 2019 17:50:40 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-12-16T17:50:40Z</dc:date>
    <item>
      <title>How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466349#M131327</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;Currently we have a scoring for our systems that counts each server, router, switch, firewall, workstation, etc on an equal playing field. We count norton as 40% (.40), tanium 25% (.25), nessus 10% (.10), openvas 5% (.05), and nexpose 10% (.10).&lt;BR /&gt;
The scoring system SPL that works is something similar to below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`comment("1 means that the device was found by a scanner in | inputlookup scanner_visbility.csv")`
| inputlookup scanner_visbility.csv
| eventstats count(eval(ip)) as total 
             count(eval(norton="1")) as norton_count
             count(eval(tanium="1")) as tanium_count
             count(eval(nessus="1")) as nessus_count
             count(eval(metasploit="1")) as metasploit_count
             count(eval(openvas="1")) as oprnvas_count
             count(eval(nexpose="1")) as nexpose_count
| eval norton_result = round((((norton_count / total) * 100) * 0.40),2)
| eval tanium_result = round((((tanium_count / total) * 100) * 0.25),2)
| eval nessus_result = round((((nessus_count / total) * 100) * 0.10),2) 
| eval metaspoit_result = round((((metasploit_count / total) * 100) * 0.10),2)
| eval openvas_result = round((((openvas_count / total) * 100) * 0.05),2)
| eval nexpose_result = round((((nexpose_count / total) * 100) * 0.10),2)
| eval visibility =  norton_result + tanium_result + nessus_result + metasploit_result + openvas_result + nexpose_result
| fields visibility 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What we want to do with the above code is to count each network device on a different scoring scale.  For Example, for routers we want ONLY count Nessus, Metasploit, and Nexpose.  We want to assign Nessus as 40%, Metasploit as 40%, and Nexpose as 10%.&lt;BR /&gt;
How would I go about assigning a different scoring scale for certain devices? &lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 17:15:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466349#M131327</guid>
      <dc:creator>UMDTERPS</dc:creator>
      <dc:date>2019-12-16T17:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466350#M131328</link>
      <description>&lt;P&gt;First, create a &lt;CODE&gt;lookup file&lt;/CODE&gt; called &lt;CODE&gt;servertypes_scanner_weights.csv1&lt;/CODE&gt; with these fields:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;servertype,nessus_weight,metasploit_weight,nexpose_weight,norton_weight,tanium_weight,oprnvas_weight,Other_weight,Stuff_weight,Here_weight
routers,.4,.4,.1,0,0,0,0,0,0
another_type,0,0,0,.5,.75,0,0,0,0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, assuming that you have a field called &lt;CODE&gt;servertype&lt;/CODE&gt; (if not, create one, probably with &lt;CODE&gt;RegEx&lt;/CODE&gt; on &lt;CODE&gt;host&lt;/CODE&gt;), you do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup scanner_visbility.csv
| eventstats count(eval(ip)) as total 
             count(eval(norton="1")) as norton_count
             count(eval(tanium="1")) as tanium_count
             count(eval(nessus="1")) as nessus_count
             count(eval(metasploit="1")) as metasploit_count
             count(eval(openvas="1")) as oprnvas_count
             count(eval(nexpose="1")) as nexpose_count
| lookup servertypes_scanner_weights.csv servertype
| eval visibility = 0
| foreach *_count [ eval  visibility = visibility + (&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_weight * 100 * &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; / total) | fields - &amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_* ]
| eval visibility = round(visibility, 2)
| fields visibility
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This also fixes rounding errors the way that you were doing it.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 17:50:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466350#M131328</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-16T17:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466351#M131329</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults count=1000 
| eval count=random() % 6 
| eval vuln_soft=mvindex(split("norton#tanium#nessus#metasploit#openvas#nexpose","#"),count) 
| eval equipment=mvindex(split("server,router,switch,firewall,workstation",","),(random() % 4))
| stats count by vuln_soft equipment
| eval args1=case(vuln_soft=="norton", .40
    ,vuln_soft=="tanium",  .25
    ,vuln_soft="nessus",  .10
    ,vuln_soft="metasploit",  .10
    ,vuln_soft="openvas",  .05
    ,vuln_soft="nexpose",  .10
    ,true(), 1)
| eval args2=case(vuln_soft=="nessus", .4,vuln_soft=="metasploit", .4, vuln=="nexpose", .1, true(),1)
| eval flag=case(equipment=="router",1, true(),NULL)
| eval count=if(flag==1,count * args2,count * args1)
| stats sum(count) as count by vuln_soft
| sort 0 - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the weight doesn't change, CSV and &lt;CODE&gt;lookup&lt;/CODE&gt;  are better.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 18:16:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466351#M131329</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-16T18:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466352#M131330</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;1.  | inputlookup scanner_visibility.csv
2.  | lookup visibility_blue.csv Acronym AS application local=t OUTPUTNEW "Risk Score"
3.  | lookup server_dump.csv Acronym AS application local=t OUTPUTNEW "Authorization Removal Date"
4.  | rename norton_assets as norton 
5.  | eval norton = if(like(norton, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(norton,"%m/%d/%Y"), 1, 0)
6.  | eval tanium = if(like(tanium, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(tanium,"%m/%d/%Y"), 1, 0)
7.  | eval nessus = if(like(nessus, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(nessus,"%m/%d/%Y"), 1, 0)
8.  | eval metasploit = if(like(metasploit, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(metasploit,"%m/%d/%Y"), 1, 0)
9.  | eval openas = if(like(openvas, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(openvas,"%m/%d/%Y"), 1, 0)
10. | eval nexpose = if(like(nexpose, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(nexpose,"%m/%d/%Y"), 1, 0)
11.               count(eval(norton="1")) as norton_count
12.               count(eval(tanium="1")) as tanium_count
13.               count(eval(nessus="1")) as nessus_count
14.               count(eval(metasploit="1")) as metasploit_count
15.               count(eval(openvas="1")) as oprnvas_count
16.               count(eval(nexpose="1")) as nexpose_count
17.  | lookup servertypes_scanner_weights.csv servertype
18.  | eval visibility = 0
19.  | foreach *_count [ eval  visibility = visibility + (&amp;lt;&amp;lt;MATCHSEG&amp;gt;&amp;gt;_weight * 100 * &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; / total) | fields - &amp;lt;&amp;lt;MATCHSEG&amp;gt;&amp;gt;_* ]
20.  | eval visibility = round(visibility, 2)
21.  | fields visibility
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The code with the time I added looks at fields less than 30 days old ( it shouldn't affect the scoring).  I am getting the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'eval' command: The expression is malformed. An unexpected character is reached at '&amp;lt;&amp;lt;MATCHSEG&amp;gt;&amp;gt;_weight * 100 * field / total)'.
The search job has failed due to an error. You may be able view the job in the Job Inspector.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Dec 2019 20:46:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466352#M131330</guid>
      <dc:creator>UMDTERPS</dc:creator>
      <dc:date>2019-12-16T20:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466353#M131331</link>
      <description>&lt;P&gt;Had a typo: &lt;CODE&gt;&amp;lt;&amp;lt;MATCHSEG&amp;gt;&amp;gt;&lt;/CODE&gt; should have been &lt;CODE&gt;&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;&lt;/CODE&gt;.  I fixed the original answer text.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 22:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466353#M131331</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-16T22:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466354#M131332</link>
      <description>&lt;P&gt;The search runs with no errors, however the search does not return a visibility percentage, it's just blank.&lt;/P&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| fields application servertype ip visibility
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;HHS_System workstation 192.168.1.50&lt;BR /&gt;
HHS_System server  192.168.1.55&lt;BR /&gt;
PPH_System workstation 192.168.2.50&lt;BR /&gt;
PPH_System server 192.168.2.51 &lt;BR /&gt;
PPH_System router 192.168.1.1&lt;/P&gt;

&lt;P&gt;Any ideas? =0(&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:23:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466354#M131332</guid>
      <dc:creator>UMDTERPS</dc:creator>
      <dc:date>2020-09-30T03:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466355#M131333</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| inputlookup scanner_visibility.csv
| lookup visibility_blue.csv Acronym AS application local=t OUTPUTNEW "Risk Score"
| lookup server_dump.csv Acronym AS application local=t OUTPUTNEW "Authorization Removal Date"
| rename norton_assets as norton 
| lookup servertypes_scanner_weights.csv servertype OUTPUTNEW norton_weight tanium_weight nessus_weight metasploit_weight 
        openvas_weight nexpose_weight
| eval norton = if(like(norton, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(norton,"%m/%d/%Y"), norton_weight, 0)
| eval tanium = if(like(tanium, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(tanium,"%m/%d/%Y"), tanium_weight, 0)
| eval nessus = if(like(nessus, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(nessus,"%m/%d/%Y"), nessus_weight, 0)
| eval metasploit = if(like(metasploit, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(metasploit,"%m/%d/%Y"), metasploit_weight,0)
| eval openas = if(like(openvas, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(openvas,"%m/%d/%Y"), openvas_weight, 0)
| eval nexpose = if(like(nexpose, "%2019") AND relative_time(now(), "-30d@d") &amp;lt; strptime(nexpose,"%m/%d/%Y"), nexpose_weight, 0)
|eventstats count(ip) as total 
      sum(norton) as norton_count
      sum(tanium) as tanium_count
      sum(nessus) as nessus_count
      sum(meteasploit) as metasploit_count
      sum(openvas) as openvas_count  
      sum(nexpose) as nexpose_count
      count(eval(found="Yes")) as found_yes by system
| eval norton_score = round (((norton_count / total)*100), 2)
| eval tanium_score = round (((tanium_count / total)*100), 2)
| eval nessus_score = round (((nessus_count / total)*100), 2)
| eval metasploit_score = round (((metasploit_count / total)*100), 2)
| eval openvas_score = round (((openvas_count / total)*100), 2)
| eval nexpose_score = round (((nexpose_count / total)*100), 2)
| dedup system
| eval final_result = norton_score + tanium_score + nessus_score + metasploit_score + openvas_score + nexpose_score
| rename final_result as visbility
| fields system total visibility norton_count norton_score 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got with a programmer at work and he suggested to use an "| lookup" to loop over the weights in the  servertypes_scanner_weights.csv and OUTPUT them as new fields. With that we reworked the "count"s as "sum"s and brought back the "eval" statements without the scoring.  It worked!&lt;/P&gt;

&lt;P&gt;| fields system total visibility norton_count norton_score &lt;/P&gt;

&lt;P&gt;HHS_System 3 100% 3 100%&lt;BR /&gt;
PPH_System 6 77% 3 100%&lt;/P&gt;

&lt;P&gt;I know the above is true because I verified it manually.  Thanks for the the help! =0)&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466355#M131333</guid>
      <dc:creator>UMDTERPS</dc:creator>
      <dc:date>2020-09-30T03:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466356#M131334</link>
      <description>&lt;P&gt;I had the same typo twice; I fixed it again in my original answer.  Try it now.  It is vastly more efficient than your other one.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2019 20:02:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466356#M131334</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-12-20T20:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign a custom scoring scale based on device type? (eval related)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466357#M131335</link>
      <description>&lt;P&gt;Hi! Sorry for the late reply, I was out. I tried the following code:&lt;/P&gt;

&lt;P&gt;| inputlookup scanner_visbility.csv&lt;BR /&gt;
 | eventstats count(eval(ip)) as total &lt;BR /&gt;
              count(eval(norton="1")) as norton_count&lt;BR /&gt;
              count(eval(tanium="1")) as tanium_count&lt;BR /&gt;
              count(eval(nessus="1")) as nessus_count&lt;BR /&gt;
              count(eval(metasploit="1")) as metasploit_count&lt;BR /&gt;
              count(eval(openvas="1")) as oprnvas_count&lt;BR /&gt;
              count(eval(nexpose="1")) as nexpose_count&lt;BR /&gt;
 | lookup servertypes_scanner_weights.csv servertype&lt;BR /&gt;
 | eval visibility = 0&lt;BR /&gt;
 | foreach &lt;EM&gt;&lt;EM&gt;count [ eval  visibility = visibility + (&amp;lt;&amp;gt;_weight * 100 * &amp;lt;&amp;gt; / total) | fields - &amp;lt;&amp;gt;&lt;/EM&gt;&lt;/EM&gt; ]&lt;BR /&gt;
 | eval visibility = round(visibility, 2)&lt;BR /&gt;
 | fields visibility&lt;/P&gt;

&lt;P&gt;It only shows the application name, not the visibility score.&lt;/P&gt;

&lt;P&gt;application                            visibility  &lt;/P&gt;

&lt;P&gt;HHS_System&lt;BR /&gt;
PPH_System&lt;/P&gt;

&lt;P&gt;The solution I provided a few replies above does work, but I'm always looking for more efficient SPL.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:30:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-assign-a-custom-scoring-scale-based-on-device-type-eval/m-p/466357#M131335</guid>
      <dc:creator>UMDTERPS</dc:creator>
      <dc:date>2020-09-30T03:30:04Z</dc:date>
    </item>
  </channel>
</rss>

