Skip to content

Commit

Permalink
[backend] remove Decay feature flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
aHenryJard committed Feb 8, 2024
1 parent 57632fa commit 6a7aaeb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { type ManagerDefinition, registerManager } from './managerModule';
import conf, { booleanConf, isFeatureEnabled, logApp } from '../config/conf';
import conf, { booleanConf, logApp } from '../config/conf';
import { executionContext, SYSTEM_USER } from '../utils/access';
import { findIndicatorsForDecay, updateIndicatorDecayScore } from '../modules/indicator/indicator-domain';
import { INDICATOR_DECAY_FEATURE_FLAG } from '../modules/indicator/indicator-types';

const INDICATOR_DECAY_MANAGER_ENABLED = booleanConf('indicator_decay_manager:enabled', false);
const INDICATOR_DECAY_MANAGER_KEY = conf.get('indicator_decay_manager:lock_key') || 'indicator_decay_manager_lock';
Expand All @@ -21,7 +20,6 @@ export const indicatorDecayHandler = async () => {
for (let i = 0; i < indicatorsToUpdate.length; i += 1) {
try {
const indicator = indicatorsToUpdate[i];
logApp.warn(`[ANGIE] Processing Decay for ${indicator}.`);
await updateIndicatorDecayScore(context, SYSTEM_USER, indicator);
} catch (e: any) {
logApp.warn(`[OPENCTI-MODULE] Error when processing decay for ${indicatorsToUpdate[i].id}, skipping.`);
Expand Down Expand Up @@ -53,6 +51,4 @@ const INDICATOR_DECAY_MANAGER_DEFINITION: ManagerDefinition = {
}
};

if (isFeatureEnabled(INDICATOR_DECAY_FEATURE_FLAG)) {
registerManager(INDICATOR_DECAY_MANAGER_DEFINITION);
}
registerManager(INDICATOR_DECAY_MANAGER_DEFINITION);
112 changes: 54 additions & 58 deletions opencti-platform/opencti-graphql/src/modules/indicator/indicator.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { type ModuleDefinition, registerDefinition } from '../../schema/module';
import { ABSTRACT_STIX_DOMAIN_OBJECT } from '../../schema/general';
import { ENTITY_TYPE_INDICATOR, INDICATOR_DECAY_FEATURE_FLAG, type StixIndicator, type StoreEntityIndicator } from './indicator-types';
import { ENTITY_TYPE_INDICATOR, type StixIndicator, type StoreEntityIndicator } from './indicator-types';
import convertIndicatorToStix from './indicator-converter';
import { killChainPhases, objectOrganization } from '../../schema/stixRefRelationship';
import { isFeatureEnabled } from '../../config/conf';
import type { AttributeDefinition } from '../../schema/attribute-definition';

const INDICATOR_DEFINITION: ModuleDefinition<StoreEntityIndicator, StixIndicator> = {
type: {
Expand Down Expand Up @@ -32,61 +30,59 @@ const INDICATOR_DEFINITION: ModuleDefinition<StoreEntityIndicator, StixIndicator
{ name: 'x_opencti_detection', label: 'Detection', type: 'boolean', mandatoryType: 'no', editDefault: false, multiple: false, upsert: true, isFilterable: true },
{ name: 'x_opencti_main_observable_type', label: 'Main observable type', type: 'string', format: 'short', mandatoryType: 'external', editDefault: true, multiple: false, upsert: true, isFilterable: true },
{ name: 'x_mitre_platforms', label: 'Platforms', type: 'string', format: 'short', mandatoryType: 'customizable', editDefault: true, multiple: true, upsert: true, isFilterable: true },
...(isFeatureEnabled(INDICATOR_DECAY_FEATURE_FLAG) ? [
{
name: 'decay_next_reaction_date',
type: 'date',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: true,
label: 'Decay next reaction date',
isFilterable: false
},
{
name: 'decay_base_score',
type: 'numeric',
mandatoryType: 'no',
editDefault: true,
multiple: false,
upsert: true,
label: 'Decay base score',
isFilterable: true,
precision: 'integer',
},
{
name: 'decay_base_score_date',
type: 'date',
mandatoryType: 'no',
editDefault: true,
multiple: false,
upsert: true,
label: 'Decay base score date',
isFilterable: false,
},
{
name: 'decay_history',
type: 'object',
mandatoryType: 'no',
editDefault: false,
multiple: true,
upsert: true,
label: 'Decay history',
isFilterable: false,
format: 'flat'
},
{
name: 'decay_applied_rule',
type: 'object',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: true,
label: 'Decay applied rule',
isFilterable: false,
format: 'flat'
}
] as AttributeDefinition[] : []),
{
name: 'decay_next_reaction_date',
type: 'date',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: true,
label: 'Decay next reaction date',
isFilterable: false
},
{
name: 'decay_base_score',
type: 'numeric',
mandatoryType: 'no',
editDefault: true,
multiple: false,
upsert: true,
label: 'Decay base score',
isFilterable: true,
precision: 'integer',
},
{
name: 'decay_base_score_date',
type: 'date',
mandatoryType: 'no',
editDefault: true,
multiple: false,
upsert: true,
label: 'Decay base score date',
isFilterable: false,
},
{
name: 'decay_history',
type: 'object',
mandatoryType: 'no',
editDefault: false,
multiple: true,
upsert: true,
label: 'Decay history',
isFilterable: false,
format: 'flat'
},
{
name: 'decay_applied_rule',
type: 'object',
mandatoryType: 'no',
editDefault: false,
multiple: false,
upsert: true,
label: 'Decay applied rule',
isFilterable: false,
format: 'flat'
}
],
relations: [],
relationsRefs: [objectOrganization, killChainPhases],
Expand Down

0 comments on commit 6a7aaeb

Please sign in to comment.