@@ -43,39 +43,40 @@ type ThreatMixtape struct {
4343 // Base connection details
4444 AnalysisResult
4545
46- FinalScore float32 `ch:"final_score"`
46+ FinalScore float64 `ch:"final_score"`
4747 // BEACONS
4848 Beacon
49- BeaconThreatScore float32 `ch:"beacon_threat_score"` // bucketed beacon score
49+ BeaconThreatScore float64 `ch:"beacon_threat_score"` // bucketed beacon score
5050 BeaconType string `ch:"beacon_type"`
5151
5252 // LONG CONNECTIONS
53- LongConnScore float32 `ch:"long_conn_score"`
53+ LongConnScore float64 `ch:"long_conn_score"`
5454
5555 // Strobe
5656 Strobe bool `ch:"strobe"`
57- StrobeScore float32 `ch:"strobe_score"`
57+ StrobeScore float64 `ch:"strobe_score"`
5858
5959 // C2 over DNS
60- C2OverDNSScore float32 `ch:"c2_over_dns_score"`
61- C2OverDNSDirectConnScore float32 `ch:"c2_over_dns_direct_conn_score"`
60+ C2OverDNSScore float64 `ch:"c2_over_dns_score"`
61+ C2OverDNSDirectConnScore float64 `ch:"c2_over_dns_direct_conn_score"`
6262
6363 // Threat Intel
6464 ThreatIntel bool `ch:"threat_intel"`
65- ThreatIntelScore float32 `ch:"threat_intel_score"`
65+ ThreatIntelScore float64 `ch:"threat_intel_score"`
6666
6767 // **** MODIFIERS ****
6868 // for modifiers detected during the modifiers phase
6969 ModifierName string `ch:"modifier_name"`
70- ModifierScore float32 `ch:"modifier_score"`
70+ ModifierScore float64 `ch:"modifier_score"`
7171 ModifierValue string `ch:"modifier_value"`
7272
7373 // modifiers that are able to be added to the same row as the threat indicator scores
7474 // these are detected during the analysis phase (in the spagooper)
75- PrevalenceScore float32 `ch:"prevalence_score"`
76- FirstSeenScore float32 `ch:"first_seen_score"`
77- ThreatIntelDataSizeScore float32 `ch:"threat_intel_data_size_score"`
78- MissingHostHeaderScore float32 `ch:"missing_host_header_score"`
75+ PrevalenceScore float64 `ch:"prevalence_score"`
76+ NetworkSize uint64 `ch:"network_size"`
77+ FirstSeenScore float64 `ch:"first_seen_score"`
78+ ThreatIntelDataSizeScore float64 `ch:"threat_intel_data_size_score"`
79+ MissingHostHeaderScore float64 `ch:"missing_host_header_score"`
7980}
8081
8182// NewAnalyzer returns a new Analyzer object
@@ -169,6 +170,7 @@ func (analyzer *Analyzer) runAnalysis() error {
169170 ImportID : analyzer .ImportID ,
170171 AnalysisResult : entry ,
171172 BeaconType : entry .BeaconType ,
173+ NetworkSize : analyzer .networkSize ,
172174 }
173175
174176 // set the first seen historical value
@@ -213,7 +215,7 @@ func (analyzer *Analyzer) runAnalysis() error {
213215 hasThreatIndicator = true
214216 mixtape .C2OverDNSScore = c2OverDNSScore
215217 // run c2 over dns direct connection analysis
216- if shouldHaveC2OverDNSDirectConnModifier ( entry . DirectConns , entry . QueriedBy ) {
218+ if mixtape . HasC2OverDNSDirectConnectionsModifier {
217219 mixtape .C2OverDNSDirectConnScore = analyzer .Config .Modifiers .C2OverDNSDirectConnScoreIncrease
218220 }
219221 }
@@ -260,7 +262,7 @@ func (analyzer *Analyzer) runAnalysis() error {
260262
261263 // Threat Intel Data Size Score
262264 if entry .OnThreatIntel {
263- if entry .TotalBytes >= analyzer .Config .Modifiers .ThreatIntelDataSizeThreshold {
265+ if entry .TotalBytes >= uint64 ( analyzer .Config .Modifiers .ThreatIntelDataSizeThreshold ) {
264266 mixtape .ThreatIntelDataSizeScore = analyzer .Config .Modifiers .ThreatIntelScoreIncrease
265267 }
266268 }
@@ -274,7 +276,7 @@ func (analyzer *Analyzer) runAnalysis() error {
274276 // use the current time to score against unless useCurrentTime is false
275277 relativeTime := util .GetRelativeFirstSeenTimestamp (analyzer .useCurrentTime , analyzer .firstSeenMaxTS )
276278 timeSince := relativeTime .Sub (entry .FirstSeenHistorical )
277- daysSinceFirstSeen := float32 (timeSince .Hours () / 24 )
279+ daysSinceFirstSeen := float64 (timeSince .Hours () / 24 )
278280
279281 // Historical First Seen Scoring
280282 // only apply to rolling datasets
@@ -307,7 +309,7 @@ func (analyzer *Analyzer) runAnalysis() error {
307309 return nil
308310}
309311
310- func calculateBucketedScore (value float64 , thresholds config.ScoreThresholds ) float32 {
312+ func calculateBucketedScore (value float64 , thresholds config.ScoreThresholds ) float64 {
311313 base := float64 (thresholds .Base )
312314 low := float64 (thresholds .Low )
313315 medium := float64 (thresholds .Med )
@@ -319,23 +321,23 @@ func calculateBucketedScore(value float64, thresholds config.ScoreThresholds) fl
319321 mediumScore := config .MEDIUM_CATEGORY_SCORE * 100
320322 highScore := config .HIGH_CATEGORY_SCORE * 100
321323
322- score := float32 (0 )
324+ score := float64 (0 )
323325
324326 // interpolate scores between the threat category bucket thresholds
325327 switch {
326328 // (Low) 1-4hrs
327329 case value < base :
328330 return 0
329331 case value < low :
330- score = float32 (noneScore + (value - base )/ (low - base )* (lowScore - noneScore ))
332+ score = float64 (noneScore + (value - base )/ (low - base )* (lowScore - noneScore ))
331333 // (Medium) 4-8hrs
332334 case value >= low && value < medium :
333- score = float32 (lowScore + (value - low )/ (medium - low )* (mediumScore - lowScore ))
335+ score = float64 (lowScore + (value - low )/ (medium - low )* (mediumScore - lowScore ))
334336 // (High) 8-12hrs+
335337 case value >= medium :
336338 // cap the maximum duration score value to the High category threshold because we're not scoring any higher than this
337339 cappedValue := math .Min (value , high )
338- score = float32 (mediumScore + (cappedValue - medium )/ (high - medium )* (highScore - mediumScore ))
340+ score = float64 (mediumScore + (cappedValue - medium )/ (high - medium )* (highScore - mediumScore ))
339341 }
340342 return score / 100
341343}
0 commit comments