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] Decay rules settings (#2859) #5641

Merged
merged 12 commits into from
Feb 13, 2024

Conversation

SouadHadjiat
Copy link
Member

@SouadHadjiat SouadHadjiat commented Jan 22, 2024

Proposed changes

  • Create a new module for decay rules
  • Initialize built-in decay rules (3 decay rules saved at init => update counters in tests + 3)
  • Save decay rules in cache
  • Apply saved decay rules (from cache) on indicators
  • List and display decay rules in settings
  • Add a form to create decay rules
  • generic tsx use for both chart (on settings and on indicator overview)
  • View and edit decay rule => + chart to visualize decay rule
  • Delete decay rules from settings
  • Reset decay computations when an indicator has an upsert on score or a score update (except if score = base score).
  • Add a simple visualization in graph for past decay data (when decay has been reset because of upsert or update).
  • Remove feature flag

image

image

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

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Copy link

codecov bot commented Jan 22, 2024

Codecov Report

Attention: 100 lines in your changes are missing coverage. Please review.

Comparison is base (87cf4bb) 64.99% compared to head (21cd376) 65.41%.

Files Patch % Lines
...-graphql/src/modules/indicator/indicator-domain.ts 75.47% 26 Missing ⚠️
...-graphql/src/modules/decayRule/decayRule-domain.ts 93.92% 24 Missing ⚠️
...aphql/src/modules/decayRule/decayRule-converter.ts 28.00% 18 Missing ⚠️
opencti-platform/opencti-graphql/src/managers.js 0.00% 12 Missing ⚠️
...tform/opencti-graphql/src/manager/managerModule.ts 22.22% 7 Missing ⚠️
...tform/opencti-graphql/src/domain/internalObject.ts 37.50% 5 Missing ⚠️
...pencti-graphql/src/database/data-initialization.js 0.00% 2 Missing ⚠️
...latform/opencti-graphql/src/database/middleware.js 85.71% 2 Missing ⚠️
...cti-platform/opencti-graphql/src/initialization.js 0.00% 2 Missing ⚠️
...opencti-graphql/src/modules/decayRule/decayRule.ts 94.73% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5641      +/-   ##
==========================================
+ Coverage   64.99%   65.41%   +0.41%     
==========================================
  Files         528      532       +4     
  Lines       62005    62501     +496     
  Branches     4967     5029      +62     
==========================================
+ Hits        40302    40886     +584     
+ Misses      21703    21615      -88     

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

@richard-julien richard-julien added the filigran team use to identify PR from the Filigran team label Jan 22, 2024
@SouadHadjiat SouadHadjiat force-pushed the issue/2859-chunk4-decay-rule-config branch 4 times, most recently from 4e7aef0 to 096a934 Compare January 29, 2024 18:17
@SouadHadjiat SouadHadjiat changed the title [DRAFT] [backend] starting new module DecayRule [backend] Decay rules settings Jan 30, 2024
@SouadHadjiat SouadHadjiat changed the title [backend] Decay rules settings [backend] Decay rules settings (#2859) Jan 30, 2024
@SouadHadjiat SouadHadjiat force-pushed the issue/2859-chunk4-decay-rule-config branch 5 times, most recently from 344d60b to 105a84a Compare February 2, 2024 08:40
@aHenryJard aHenryJard force-pushed the issue/2859-chunk4-decay-rule-config branch from 9813d1a to ee55c6d Compare February 5, 2024 08:45
@SouadHadjiat SouadHadjiat force-pushed the issue/2859-chunk4-decay-rule-config branch from ad95c5f to 7005877 Compare February 6, 2024 10:17
@aHenryJard aHenryJard force-pushed the issue/2859-chunk4-decay-rule-config branch from 641c80e to dce8430 Compare February 8, 2024 06:34
@aHenryJard aHenryJard force-pushed the issue/2859-chunk4-decay-rule-config branch from dce8430 to 57632fa Compare February 8, 2024 09:15
@aHenryJard aHenryJard force-pushed the issue/2859-chunk4-decay-rule-config branch from 48099b7 to 594c352 Compare February 9, 2024 07:24
"To use this feature, your platform administrator must enable the subscription manager in the config.": "To use this feature, your platform administrator must enable the subscription manager in the config.",
"To use this feature, your platform administrator must enable the according manager in the config.": "To use this feature, your platform administrator must enable the according manager in the config.",
"To use this feature, your platform administrator must enable the subscription manager in the config.": "To use this feature, your platform administrator must enable the subscription manager in configuration.",
"To use this feature, your platform administrator must enable the according manager in the config.": "To use this feature, your platform administrator must enable the according manager in configuration.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all other language "configuration" seems to be whole word.

@@ -23,13 +23,13 @@ describe('Raw streams tests', () => {
expect(createEventsByTypes.label.length).toBe(15);
expect(createEventsByTypes.identity.length).toBe(30);
expect(createEventsByTypes.relationship.length).toBe(126);
expect(createEventsByTypes.indicator.length).toBe(31);
expect(createEventsByTypes.indicator.length).toBe(33);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DecayRule integration test creates 2 indicators, so this is legit to me (same for others +2).

@aHenryJard aHenryJard marked this pull request as ready for review February 9, 2024 08:14
@aHenryJard aHenryJard force-pushed the issue/2859-chunk4-decay-rule-config branch from 50c9965 to e506e82 Compare February 12, 2024 12:41
@aHenryJard aHenryJard force-pushed the issue/2859-chunk4-decay-rule-config branch 2 times, most recently from c200f23 to 64d3164 Compare February 12, 2024 13:39
};

const decayFullHistory: LabelledDecayHistory[] = [];
const labelledHistoryList: LabelledDecayHistory[] = [];
decayHistory.map((history) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const labelledHistoryList = [...decayHistory, ...decayLivePoints].map(history => getDisplayFor(history))

import CustomizationMenu from '../CustomizationMenu';
import { DecayRule_decayRule$key } from './__generated__/DecayRule_decayRule.graphql';

const useStyles = makeStyles(() => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeStyles is deprecated. Try to put style directly in JSX using style={{...}} for html elements or sx={{...}} for MUI elements

import { handleErrorInForm } from '../../../../relay/environment';
import { DecayRulesLinesPaginationQuery$variables } from './__generated__/DecayRulesLinesPaginationQuery.graphql';

const useStyles = makeStyles<Theme>((theme) => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeStyles is deprecated. Try to put style directly in JSX using style={{...}} for html elements or sx={{...}} for MUI elements

import { handleError } from '../../../../relay/environment';
import { DecayRule_decayRule$data } from './__generated__/DecayRule_decayRule.graphql';

const useStyles = makeStyles<Theme>((theme) => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeStyles is deprecated. Try to put style directly in JSX using style={{...}} for html elements or sx={{...}} for MUI elements

import { useFormatter } from '../../../../components/i18n';
import { handleError } from '../../../../relay/environment';

const useStyles = makeStyles(() => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeStyles is deprecated. Try to put style directly in JSX using style={{...}} for html elements or sx={{...}} for MUI elements


const LOCAL_STORAGE_KEY = 'view-decay-rules';

const useStyles = makeStyles<Theme>(() => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeStyles is deprecated. Try to put style directly in JSX using style={{...}} for html elements or sx={{...}} for MUI elements

import type { Theme } from '../../../../components/Theme';
import { DecayRulesLine_node$key } from './__generated__/DecayRulesLine_node.graphql';

const useStyles = makeStyles<Theme>((theme) => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeStyles is deprecated. Try to put style directly in JSX using style={{...}} for html elements or sx={{...}} for MUI elements

marginTop: '-13px',
},
title: {
float: 'left',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if we really need to use float css property

@aHenryJard aHenryJard force-pushed the issue/2859-chunk4-decay-rule-config branch from a02b776 to 96f5603 Compare February 13, 2024 09:18
@SouadHadjiat SouadHadjiat force-pushed the issue/2859-chunk4-decay-rule-config branch from 96f5603 to a295948 Compare February 13, 2024 09:33
@SouadHadjiat SouadHadjiat merged commit 1c2b82f into master Feb 13, 2024
8 checks passed
@SouadHadjiat SouadHadjiat deleted the issue/2859-chunk4-decay-rule-config branch February 13, 2024 13:03
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

5 participants