-
Notifications
You must be signed in to change notification settings - Fork 919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[backend] Fix upsert indicator score since decay (#2859) #6100
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7bb0072
[backend] Fix upsert indicator score since decay (#2859)
SouadHadjiat a622284
[backend/frontend] Fix display current score on lifecycle dialog + re…
SouadHadjiat 9ad64a6
[frontend] labels & layout changes seen with JP
SouadHadjiat f49498c
[backend/frontend] fix decayChart current score + code cleaning + add…
SouadHadjiat 74d296e
[backend] exclude decay inputs from stream
SouadHadjiat 9422b92
[frontend] display current stable score before initial score
SouadHadjiat e873b4f
[backend] Fix decay when score is 0
Kedae 8e7e01f
[backend/frontend] Simple comment change + remove filtering for base …
richard-julien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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 |
---|---|---|
|
@@ -1632,7 +1632,7 @@ const updateAttributeRaw = async (context, user, instance, inputs, opts = {}) => | |
if (ins) { // If update will really produce a data change | ||
impactedInputs.push(ins); | ||
// region Compute the update to push in the stream | ||
if (!input.key.startsWith('i_') && input.key !== 'x_opencti_graph_data') { | ||
if (!input.key.startsWith('i_') && input.key !== 'x_opencti_graph_data' && !input.key.startsWith('decay_')) { | ||
const previous = getPreviousInstanceValue(input.key, instance); | ||
if (input.operation === UPDATE_OPERATION_ADD || input.operation === UPDATE_OPERATION_REMOVE) { | ||
// Check symmetric difference for add and remove | ||
|
@@ -2380,14 +2380,20 @@ const upsertElement = async (context, user, element, type, basePatch, opts = {}) | |
} | ||
} | ||
if (type === ENTITY_TYPE_INDICATOR) { | ||
// Do not compute decay again when base score does not change | ||
if (updatePatch.decay_applied_rule && updatePatch.decay_base_score === element.decay_base_score) { | ||
logApp.debug('UPSERT INDICATOR -- no decay reset because no score change', { element, basePatch }); | ||
// Do not compute decay again when base score does not change | ||
// don't reset score, valid_from & valid_until | ||
updatePatch.x_opencti_score = element.x_opencti_score; // don't change the score | ||
updatePatch.valid_from = element.valid_from; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really sure about this part, I wonder if we might have a case where valid_from / valid_until change with the same score |
||
updatePatch.valid_until = element.valid_until; | ||
// don't reset decay attributes | ||
updatePatch.decay_base_score_date = element.decay_base_score_date; | ||
updatePatch.decay_applied_rule = element.decay_applied_rule; | ||
updatePatch.decay_history = []; | ||
updatePatch.decay_history = []; // History is multiple, forcing to empty array will prevent any modification | ||
updatePatch.decay_next_reaction_date = element.decay_next_reaction_date; | ||
} else { | ||
// As base_score as change, decay will be reset by upsert | ||
logApp.debug('UPSERT INDICATOR -- Decay is reset', { element, basePatch }); | ||
} | ||
} | ||
|
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix display of current score when we have multiple times in history the same score (it was displayed "Current stable score" each time)