-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
20 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
...curity_solution/server/lib/entity_analytics/risk_score/painless/risk_scoring_map.painless
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
Map fields = new HashMap(); | ||
String category = doc['event.kind'].value; | ||
double score = doc['kibana.alert.risk_score'].value; | ||
fields.put('id', doc['kibana.alert.uuid'].value); | ||
fields.put('index', doc['_index'].value); | ||
fields.put('time', doc['@timestamp'].value); | ||
fields.put('rule_name', doc['kibana.alert.rule.name'].value); | ||
fields.put('category', category); | ||
fields.put('index', doc['_index'].value); | ||
fields.put('id', doc['kibana.alert.uuid'].value); | ||
fields.put('score', score); | ||
fields.put('category', doc['event.kind'].value); | ||
fields.put('score', doc['kibana.alert.risk_score'].value); | ||
state.inputs.add(fields); |
40 changes: 14 additions & 26 deletions
40
...ity_solution/server/lib/entity_analytics/risk_score/painless/risk_scoring_reduce.painless
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,33 @@ | ||
Map results = new HashMap(); | ||
results['notes'] = []; | ||
results['category_1_score'] = 0.0; | ||
results['category_1_count'] = 0; | ||
results['risk_inputs'] = []; | ||
results['score'] = 0; | ||
|
||
List inputs = []; | ||
for (state in states) { | ||
inputs.addAll(state.inputs) | ||
} | ||
Collections.sort(inputs, (a, b) -> b.get('score').compareTo(a.get('score'))); | ||
|
||
double num_inputs_to_score = Math.min(inputs.length, params.max_risk_inputs_per_identity); | ||
results['notes'] = []; | ||
if (num_inputs_to_score == params.max_risk_inputs_per_identity) { | ||
results['notes'].add('Number of risk inputs (' + inputs.length + ') exceeded the maximum allowed (' + params.max_risk_inputs_per_identity + ').'); | ||
} | ||
|
||
results['category_1_score'] = 0.0; | ||
results['category_1_count'] = 0; | ||
|
||
double total_score = 0; | ||
double current_score = 0; | ||
List risk_inputs = []; | ||
for (int i = 0; i < num_inputs_to_score; i++) { | ||
current_score = inputs[i].score / Math.pow(i + 1, params.p); | ||
for (int i = 0; i < inputs.length; i++) { | ||
double current_score = inputs[i].score / Math.pow(i + 1, params.p); | ||
|
||
if (i < 10) { | ||
inputs[i]["contribution"] = 100 * current_score / params.risk_cap; | ||
risk_inputs.add(inputs[i]); | ||
results['risk_inputs'].add(inputs[i]); | ||
} | ||
|
||
if (inputs[i].category == 'signal') { | ||
results['category_1_score'] += current_score; results['category_1_count'] += 1; | ||
results['category_1_score'] += current_score; | ||
results['category_1_count'] += 1; | ||
} | ||
|
||
total_score += current_score; | ||
results['score'] += current_score; | ||
} | ||
|
||
if (params.containsKey('global_identifier_type_weight') && params.global_identifier_type_weight != null) { | ||
total_score *= params.global_identifier_type_weight; | ||
} | ||
|
||
double score_norm = 100 * total_score / params.risk_cap; | ||
results['score'] = total_score; | ||
results['normalized_score'] = score_norm; | ||
results['risk_inputs'] = risk_inputs; | ||
results['score'] *= params.global_identifier_type_weight; | ||
results['normalized_score'] = 100 * results['score'] / params.risk_cap; | ||
|
||
return results; | ||
|