Skip to content

Commit 7f45d6f

Browse files
committed
Ignore saved_id for Threat match and threshold rules
1 parent 8135adc commit 7f45d6f

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

x-pack/plugins/security_solution/server/lib/detection_engine/signals/get_filter.test.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,52 @@ describe('get_filter', () => {
137137
});
138138
});
139139

140+
test('return query for threat_match rule, despite saved_id is specify', async () => {
141+
const filter = await getFilter({
142+
type: 'threat_match',
143+
filters: undefined,
144+
language: 'kuery',
145+
query: 'host.name: siem',
146+
savedId: 'some-id',
147+
services: servicesMock,
148+
index: ['auditbeat-*'],
149+
lists: [],
150+
});
151+
expect(filter).toEqual({
152+
bool: {
153+
filter: [
154+
{ bool: { minimum_should_match: 1, should: [{ match: { 'host.name': 'siem' } }] } },
155+
],
156+
must: [],
157+
must_not: [],
158+
should: [],
159+
},
160+
});
161+
});
162+
163+
test('return query for threshold rule, despite saved_id is specify', async () => {
164+
const filter = await getFilter({
165+
type: 'threat_match',
166+
filters: undefined,
167+
language: 'kuery',
168+
query: 'host.name: siem',
169+
savedId: 'some-id',
170+
services: servicesMock,
171+
index: ['auditbeat-*'],
172+
lists: [],
173+
});
174+
expect(filter).toEqual({
175+
bool: {
176+
filter: [
177+
{ bool: { minimum_should_match: 1, should: [{ match: { 'host.name': 'siem' } }] } },
178+
],
179+
must: [],
180+
must_not: [],
181+
should: [],
182+
},
183+
});
184+
});
185+
140186
test('throws on saved query if saved_id is undefined', async () => {
141187
await expect(
142188
getFilter({

x-pack/plugins/security_solution/server/lib/detection_engine/signals/get_filter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ export const getFilter = async ({
9494

9595
switch (type) {
9696
case 'threat_match':
97-
case 'threshold': {
98-
return savedId != null ? savedQueryFilter() : queryFilter();
99-
}
97+
case 'threshold':
10098
case 'query': {
10199
return queryFilter();
102100
}

0 commit comments

Comments
 (0)