[sentinel_one] Enrich events with event.{category,type,outcome}#3787
[sentinel_one] Enrich events with event.{category,type,outcome}#3787andrewkroh merged 8 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/security-external-integrations (Team:Security-External Integrations) |
🌐 Coverage report
|
| def eventCategory = new HashSet(); | ||
| def eventType = new HashSet(); | ||
| if(ctx.json?.threatId != null && ctx.json?.threatId != "") { | ||
| if(ctx.json?.data?.threatClassification == "Malware") { |
There was a problem hiding this comment.
I there a reason "Trojan" is not a malware classification? It appears in some of the documents that are now classed as "threat"/"indicator".
There was a problem hiding this comment.
Oh, yes. Will update it.
| else if(ctx.json?.primaryDescription != null){ | ||
| if(ctx.json?.primaryDescription?.toLowerCase().contains("logged in")){ |
There was a problem hiding this comment.
This could be made less verbose and made to do less work by assigning a local. Also, since we know ctx.json?.primaryDescription != null, the conditional null derefs are not needed in the later steps.
| else if(ctx.json?.primaryDescription != null){ | |
| if(ctx.json?.primaryDescription?.toLowerCase().contains("logged in")){ | |
| else if(ctx.json?.primaryDescription != null) { | |
| def description = ctx.json.primaryDescription.toLowerCase(); | |
| if (description.contains("logged in")) { |
with similar uses in all the following conditions.
| eventCategory.add("authentication"); | ||
| ctx.event.outcome = "failure"; | ||
| } | ||
| eventType.add("info"); |
There was a problem hiding this comment.
Adjust the indent to match the block.
| eventType.add("info"); | ||
| } | ||
| ctx.event.category = eventCategory.size()==0 ? null : eventCategory; | ||
| ctx.event.type = eventType.size()==0 ? null : eventType; |
There was a problem hiding this comment.
How about an if (!eventCategory.isEmpty) { ctx.event.category = eventCategory } so that we don't end up with a null in the doc. Same for event.type.
| eventType.add("start"); | ||
| ctx.event.outcome = "success"; | ||
| } | ||
| if(description.contains("logged out")){ |
| eventCategory.add("authentication"); | ||
| ctx.event.outcome = "failure"; | ||
| } | ||
| eventType.add("info"); |
There was a problem hiding this comment.
Is this meant to be a catch all? Should it be part of a final else block?
f2157dd to
94b571f
Compare
94b571f to
510311b
Compare
|
/test |
| source: > | ||
| def eventCategory = new HashSet(); | ||
| def eventType = new HashSet(); | ||
| if (ctx.json?.threatId != null && ctx.json?.threatId != '') { |
There was a problem hiding this comment.
| if (ctx.json?.threatId != null && ctx.json?.threatId != '') { | |
| if (ctx.json?.threatId != null && ctx.json.threatId != '') { |
| if (!eventCategory.isEmpty()) { | ||
| ctx.event.category = eventCategory; | ||
| } | ||
| if (ctx.json?.data?.confidenceLevel != null && ['suspicious', 'malicious'].contains(ctx.json?.data?.confidenceLevel)) { |
There was a problem hiding this comment.
[...].contains(null) returns false unless the array list holds a null, so this can be rewritten:
| if (ctx.json?.data?.confidenceLevel != null && ['suspicious', 'malicious'].contains(ctx.json?.data?.confidenceLevel)) { | |
| if (['suspicious', 'malicious'].contains(ctx.json?.data?.confidenceLevel)) { |
| if (threat_classification == 'Exploit' || threat_classification == 'PUA') { | ||
| eventCategory.add('threat'); | ||
| eventType.add('indicator'); | ||
| } else if (threat_classification == 'Malware' || threat_classification == 'Ransomware' || threat_classification == 'Trojan' || threat_classification == 'Downloader') { |
There was a problem hiding this comment.
| } else if (threat_classification == 'Malware' || threat_classification == 'Ransomware' || threat_classification == 'Trojan' || threat_classification == 'Downloader') { | |
| } else if ['Malware', 'Ransomware', 'Trojan', 'Downloader'].contains(threat_classification)) { |
Maybe similar for above? I have no strong opinion either way for that though.
Type of change
What does this PR do?
This PR fixes the bug related to the value of event.category and event.type fields are being statically mapped. In this PR we have mapped the values of event.category, event.type and event.outcome based on the activity performed.
Checklist
How to test this PR locally
Related issues
Screenshots