Skip to content

Commit

Permalink
Ignore saved_id for Threat match and threshold rules
Browse files Browse the repository at this point in the history
  • Loading branch information
nkhristinin committed Sep 1, 2021
1 parent 8135adc commit 7f45d6f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,52 @@ describe('get_filter', () => {
});
});

test('return query for threat_match rule, despite saved_id is specify', async () => {
const filter = await getFilter({
type: 'threat_match',
filters: undefined,
language: 'kuery',
query: 'host.name: siem',
savedId: 'some-id',
services: servicesMock,
index: ['auditbeat-*'],
lists: [],
});
expect(filter).toEqual({
bool: {
filter: [
{ bool: { minimum_should_match: 1, should: [{ match: { 'host.name': 'siem' } }] } },
],
must: [],
must_not: [],
should: [],
},
});
});

test('return query for threshold rule, despite saved_id is specify', async () => {
const filter = await getFilter({
type: 'threat_match',
filters: undefined,
language: 'kuery',
query: 'host.name: siem',
savedId: 'some-id',
services: servicesMock,
index: ['auditbeat-*'],
lists: [],
});
expect(filter).toEqual({
bool: {
filter: [
{ bool: { minimum_should_match: 1, should: [{ match: { 'host.name': 'siem' } }] } },
],
must: [],
must_not: [],
should: [],
},
});
});

test('throws on saved query if saved_id is undefined', async () => {
await expect(
getFilter({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ export const getFilter = async ({

switch (type) {
case 'threat_match':
case 'threshold': {
return savedId != null ? savedQueryFilter() : queryFilter();
}
case 'threshold':
case 'query': {
return queryFilter();
}
Expand Down

0 comments on commit 7f45d6f

Please sign in to comment.