Skip to content

Commit

Permalink
Fixed import issue where you could flip the flags on import
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHassanabad committed Jan 24, 2020
1 parent db1e93c commit 771579a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ describe('import rules schema', () => {
);
});

test('You can optionally set the immutable to be true', () => {
test('You can optionally set the immutable to be false', () => {
expect(
importRulesSchema.validate<Partial<ImportRuleAlertRest>>({
rule_id: 'rule-1',
Expand All @@ -866,7 +866,7 @@ describe('import rules schema', () => {
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
immutable: false,
index: ['index-1'],
name: 'some-name',
severity: 'low',
Expand All @@ -880,6 +880,29 @@ describe('import rules schema', () => {
).toBeFalsy();
});

test('You cannnot set immutable to be true', () => {
expect(
importRulesSchema.validate<Partial<ImportRuleAlertRest>>({
rule_id: 'rule-1',
output_index: '.siem-signals',
risk_score: 50,
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
index: ['index-1'],
name: 'some-name',
severity: 'low',
interval: '5m',
type: 'query',
references: ['index-1'],
query: 'some query',
language: 'kuery',
max_signals: 1,
}).error.message
).toEqual('child "immutable" fails because ["immutable" must be one of [false]]');
});

test('You cannot set the immutable to be a number', () => {
expect(
importRulesSchema.validate<
Expand Down Expand Up @@ -914,7 +937,7 @@ describe('import rules schema', () => {
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
immutable: false,
index: ['index-1'],
name: 'some-name',
severity: 'low',
Expand All @@ -937,7 +960,7 @@ describe('import rules schema', () => {
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
immutable: false,
index: ['index-1'],
name: 'some-name',
severity: 'low',
Expand All @@ -960,7 +983,7 @@ describe('import rules schema', () => {
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
immutable: false,
index: ['index-1'],
name: 'some-name',
severity: 'low',
Expand All @@ -983,7 +1006,7 @@ describe('import rules schema', () => {
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
immutable: false,
index: ['index-1'],
name: 'some-name',
severity: 'low',
Expand All @@ -1006,7 +1029,7 @@ describe('import rules schema', () => {
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
immutable: false,
index: ['index-1'],
name: 'some-name',
severity: 'low',
Expand All @@ -1032,7 +1055,7 @@ describe('import rules schema', () => {
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
immutable: false,
index: ['index-1'],
name: 'some-name',
severity: 'low',
Expand All @@ -1056,7 +1079,7 @@ describe('import rules schema', () => {
description: 'some description',
from: 'now-5m',
to: 'now',
immutable: true,
immutable: false,
index: ['index-1'],
name: 'some-name',
severity: 'low',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const importRulesSchema = Joi.object({
filters,
from: from.default('now-6m'),
rule_id: rule_id.required(),
immutable: immutable.default(false),
immutable: immutable.default(false).valid(false),
index,
interval: interval.default('5m'),
query: query.allow('').default(''),
Expand Down

0 comments on commit 771579a

Please sign in to comment.