Created
December 16, 2022 20:41
-
-
Save rylnd/64229f8615ad45f389e3a60da57bf9b1 to your computer and use it in GitHub Desktop.
Scoring Pseudocode
This file contains hidden or 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
| const RiskReasonLocation = '.alerts*' // configurable in future | |
| const IdentifierMapping = [ | |
| {sourceField: 'host.name', entityField: 'host.name'}, | |
| {sourceField: 'user.name', entityField: 'user.name'}, | |
| ]; // configurable in future | |
| for (Identifier of IdentifierMapping) { | |
| GET(`${RiskReasonLocation}/_search`, { | |
| 'event.type': 'risk_reason', | |
| [Identifier.sourceField]: '*', | |
| group_by: Identifier.sourceField | |
| }).map((group) => { | |
| const value = group.bucket; | |
| const reimanWeightingFn = generateWeightingFn(group.items); | |
| const score = group.items.reduce((sum, score) => { | |
| // decay factor based on age | |
| // sort by modified score | |
| // apply riemann zeta fn to obtain a weight | |
| // apply riemann weight to score_after_decay | |
| // sum weighted score_after_decays | |
| normalizedScore = score * decay_factor; | |
| normalizedScore *= riemanWeightingFn(score); | |
| sum += normalizedScore; | |
| }) | |
| return { | |
| id_field: Identifier.entityField, | |
| id_value: value, | |
| score, | |
| '@timestamp': Date.now(), | |
| 'risk.reasons': group.items.map(_id) | |
| } | |
| }).map(RiskScoreClient.write) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment