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

[SIEM] Removes prebuilt rules number dependency #65128

Merged
merged 5 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { newRule, totalNumberOfPrebuiltRules } from '../objects/rule';
import { newRule, totalNumberOfPrebuiltRulesInEsArchive } from '../objects/rule';

import {
ABOUT_FALSE_POSITIVES,
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('Signal detection rules, custom', () => {
changeToThreeHundredRowsPerPage();
waitForRulesToBeLoaded();

const expectedNumberOfRules = totalNumberOfPrebuiltRules + 1;
const expectedNumberOfRules = totalNumberOfPrebuiltRulesInEsArchive + 1;
cy.get(RULES_TABLE).then($table => {
cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { machineLearningRule, totalNumberOfPrebuiltRules } from '../objects/rule';
import { machineLearningRule, totalNumberOfPrebuiltRulesInEsArchive } from '../objects/rule';

import {
ABOUT_FALSE_POSITIVES,
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('Signal detection rules, machine learning', () => {
changeToThreeHundredRowsPerPage();
waitForRulesToBeLoaded();

const expectedNumberOfRules = totalNumberOfPrebuiltRules + 1;
const expectedNumberOfRules = totalNumberOfPrebuiltRulesInEsArchive + 1;
cy.get(RULES_TABLE).then($table => {
cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ import {
waitForSignalsIndexToBeCreated,
waitForSignalsPanelToBeLoaded,
} from '../tasks/detections';
import {
esArchiverLoad,
esArchiverLoadEmptyKibana,
esArchiverUnloadEmptyKibana,
esArchiverUnload,
} from '../tasks/es_archiver';
import { esArchiverLoadEmptyKibana, esArchiverUnloadEmptyKibana } from '../tasks/es_archiver';
import { loginAndWaitForPageWithoutDateRange } from '../tasks/login';

import { DETECTIONS } from '../urls/navigation';
Expand Down Expand Up @@ -76,15 +71,32 @@ describe('Signal detection rules, prebuilt rules', () => {

describe('Deleting prebuilt rules', () => {
beforeEach(() => {
esArchiverLoad('prebuilt_rules_loaded');
const expectedNumberOfRules = totalNumberOfPrebuiltRules;
const expectedElasticRulesBtnText = `Elastic rules (${expectedNumberOfRules})`;

esArchiverLoadEmptyKibana();
loginAndWaitForPageWithoutDateRange(DETECTIONS);
waitForSignalsPanelToBeLoaded();
waitForSignalsIndexToBeCreated();
goToManageSignalDetectionRules();
waitForLoadElasticPrebuiltDetectionRulesTableToBeLoaded();
loadPrebuiltDetectionRules();
waitForPrebuiltDetectionRulesToBeLoaded();

cy.get(ELASTIC_RULES_BTN)
.invoke('text')
.should('eql', expectedElasticRulesBtnText);

changeToThreeHundredRowsPerPage();
waitForRulesToBeLoaded();

cy.get(RULES_TABLE).then($table => {
cy.wrap($table.find(RULES_ROW).length).should('eql', expectedNumberOfRules);
});
});

afterEach(() => {
esArchiverUnload('prebuilt_rules_loaded');
esArchiverUnloadEmptyKibana();
});

it('Does not allow to delete one rule when more than one is selected', () => {
Expand Down
7 changes: 6 additions & 1 deletion x-pack/plugins/siem/cypress/objects/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const totalNumberOfPrebuiltRules = 127;
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { rawRules } from '../../server/lib/detection_engine/rules/prepackaged_rules/index';

export const totalNumberOfPrebuiltRules = rawRules.length;

export const totalNumberOfPrebuiltRulesInEsArchive = 127;

interface Mitre {
tactic: string;
Expand Down
7 changes: 4 additions & 3 deletions x-pack/plugins/siem/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"types": [
"cypress",
"node"
]
}
}
],
"resolveJsonModule": true,
},
}