Skip to content
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 8 commits into from
Feb 27, 2024

Conversation

SouadHadjiat
Copy link
Member

@SouadHadjiat SouadHadjiat commented Feb 23, 2024

Proposed changes

  • Don't change x_opencti_score (and valid_from / valid_until) during upsert when indicator score is the same as the base score (score at creation)
  • Add Decay manager user
  • Fix display of current stable score in dialog in case the same score is present multiple times in history (happens when the base score is updated)
  • Change messages & translations (seen with JP)

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.75%. Comparing base (fa68be5) to head (8b53c55).
Report is 18 commits behind head on master.

❗ Current head 8b53c55 differs from pull request most recent head b72607c. Consider uploading reports for the commit b72607c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6100      +/-   ##
==========================================
+ Coverage   66.73%   66.75%   +0.01%     
==========================================
  Files         540      540              
  Lines       64180    64217      +37     
  Branches     5241     5241              
==========================================
+ Hits        42832    42869      +37     
  Misses      21348    21348              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -2380,6 +2380,10 @@ const upsertElement = async (context, user, element, type, basePatch, opts = {})
if (type === ENTITY_TYPE_INDICATOR) {
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 });
updatePatch.x_opencti_score = element.x_opencti_score; // don't change the score
// don't reset valid_from & valid_until
updatePatch.valid_from = element.valid_from;
Copy link
Member Author

Choose a reason for hiding this comment

The 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

const labelledHistoryList: LabelledDecayHistory[] = [];
decayHistory.forEach((history) => (
labelledHistoryList.push(getDisplayFor(history))
const currentScoreIndex = decayHistory.findLastIndex((history) => history.score === indicator.x_opencti_score);
Copy link
Member Author

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)

@SouadHadjiat SouadHadjiat marked this pull request as ready for review February 26, 2024 17:13
@Kedae Kedae added the filigran team use to identify PR from the Filigran team label Feb 27, 2024
@richard-julien richard-julien merged commit 9151d48 into master Feb 27, 2024
5 of 6 checks passed
@richard-julien richard-julien deleted the issue/2859-fix-upsert-score branch February 27, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants