Skip to content

Commit

Permalink
fixing rule edit rule format
Browse files Browse the repository at this point in the history
  • Loading branch information
yctercero committed Feb 25, 2021
1 parent 91d03f0 commit f9bb686
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,17 @@ describe('Custom detection rules deletion and edition', () => {
goToAboutStepTab();
cy.get(TAGS_CLEAR_BUTTON).click({ force: true });
fillAboutRule(editedRule);

cy.intercept('GET', '/api/detection_engine/rules?id').as('getRule');

saveEditedRule();

cy.wait('@getRule').then(({ response }) => {
cy.wrap(response!.statusCode).should('eql', 200);
// ensure that editing rule does not modify
cy.wrap(response!.body.max_signals).should('eql', existingRule.maxSignals);
});

cy.get(RULE_NAME_HEADER).should('have.text', `${editedRule.name}`);
cy.get(ABOUT_RULE_DESCRIPTION).should('have.text', editedRule.description);
cy.get(ABOUT_DETAILS).within(() => {
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/security_solution/cypress/objects/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface CustomRule {
runsEvery: Interval;
lookBack: Interval;
timeline: CompleteTimeline;
maxSignals: number;
}

export interface ThresholdRule extends CustomRule {
Expand Down Expand Up @@ -174,6 +175,7 @@ export const newRule: CustomRule = {
runsEvery,
lookBack,
timeline,
maxSignals: 100,
};

export const existingRule: CustomRule = {
Expand All @@ -192,6 +194,7 @@ export const existingRule: CustomRule = {
runsEvery,
lookBack,
timeline,
maxSignals: 500,
};

export const newOverrideRule: OverrideRule = {
Expand All @@ -213,6 +216,7 @@ export const newOverrideRule: OverrideRule = {
runsEvery,
lookBack,
timeline,
maxSignals: 100,
};

export const newThresholdRule: ThresholdRule = {
Expand All @@ -232,6 +236,7 @@ export const newThresholdRule: ThresholdRule = {
runsEvery,
lookBack,
timeline,
maxSignals: 100,
};

export const machineLearningRule: MachineLearningRule = {
Expand Down Expand Up @@ -265,6 +270,7 @@ export const eqlRule: CustomRule = {
runsEvery,
lookBack,
timeline,
maxSignals: 100,
};

export const eqlSequenceRule: CustomRule = {
Expand All @@ -285,6 +291,7 @@ export const eqlSequenceRule: CustomRule = {
runsEvery,
lookBack,
timeline,
maxSignals: 100,
};

export const newThreatIndicatorRule: ThreatIndicatorRule = {
Expand All @@ -304,6 +311,7 @@ export const newThreatIndicatorRule: ThreatIndicatorRule = {
indicatorMapping: 'agent.id',
indicatorIndexField: 'agent.threat',
timeline,
maxSignals: 100,
};

export const severitiesOverride = ['Low', 'Medium', 'High', 'Critical'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const createCustomRuleActivated = (rule: CustomRule, ruleId = '1') =>
language: 'kuery',
enabled: true,
tags: ['rule1'],
max_signals: 500,
},
headers: { 'kbn-xsrf': 'cypress-creds' },
failOnStatusCode: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React, { FC, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useParams, useHistory } from 'react-router-dom';

import { DEFAULT_MAX_SIGNALS } from '../../../../../common/constants';
import { UpdateRulesSchema } from '../../../../../../common/detection_engine/schemas/request';
import { useRule, useUpdateRule } from '../../../../containers/detection_engine/rules';
import { useListsConfig } from '../../../../containers/detection_engine/lists/use_lists_config';
Expand Down Expand Up @@ -251,6 +252,7 @@ const EditRulePageComponent: FC = () => {
rule
),
...(ruleId ? { id: ruleId } : {}),
...(rule != null ? rule.max_signals : DEFAULT_MAX_SIGNALS),
});
}
}, [
Expand Down

0 comments on commit f9bb686

Please sign in to comment.