Skip to content

Commit 8a0d582

Browse files
committed
Revert Saved query and saved_id removing
This reverts commit 3f9d3f0 2fb24e9. 2ad42e7 04cceaa
1 parent 4865e7b commit 8a0d582

File tree

8 files changed

+32
-11
lines changed

8 files changed

+32
-11
lines changed

x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ describe('helpers', () => {
176176
);
177177
});
178178

179-
test('returns empty array of ListItems when "savedId" exists', () => {
179+
test('returns expected array of ListItems when "savedId" exists', () => {
180180
const mockQueryBarWithSavedId = {
181181
...mockQueryBar,
182182
query: '',
@@ -189,7 +189,8 @@ describe('helpers', () => {
189189
query: mockQueryBarWithSavedId.query,
190190
savedId: mockQueryBarWithSavedId.saved_id,
191191
});
192-
expect(result.length).toEqual(0);
192+
expect(result[0].title).toEqual(<>{i18n.SAVED_ID_LABEL} </>);
193+
expect(result[0].description).toEqual(<>{mockQueryBarWithSavedId.saved_id} </>);
193194
});
194195
});
195196

x-pack/plugins/security_solution/public/detections/components/rules/description_step/helpers.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const buildQueryBarDescription = ({
6565
filters,
6666
filterManager,
6767
query,
68+
savedId,
6869
indexPatterns,
6970
queryLabel,
7071
}: BuildQueryBarDescription): ListItems[] => {
@@ -105,7 +106,15 @@ export const buildQueryBarDescription = ({
105106
},
106107
];
107108
}
108-
109+
if (!isEmpty(savedId)) {
110+
items = [
111+
...items,
112+
{
113+
title: <>{i18n.SAVED_ID_LABEL} </>,
114+
description: <>{savedId} </>,
115+
},
116+
];
117+
}
109118
return items;
110119
};
111120

x-pack/plugins/security_solution/public/detections/components/rules/description_step/translations.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export const THREAT_QUERY_LABEL = i18n.translate(
2828
}
2929
);
3030

31+
export const SAVED_ID_LABEL = i18n.translate(
32+
'xpack.securitySolution.detectionEngine.createRule.savedIdLabel',
33+
{
34+
defaultMessage: 'Saved query name',
35+
}
36+
);
37+
3138
export const ML_TYPE_DESCRIPTION = i18n.translate(
3239
'xpack.securitySolution.detectionEngine.createRule.mlRuleTypeDescription',
3340
{

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/create/helpers.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('helpers', () => {
120120
query: 'test query',
121121
saved_id: 'test123',
122122
index: ['filebeat-'],
123-
type: 'query',
123+
type: 'saved_query',
124124
timeline_id: '86aa74d0-2136-11ea-9864-ebc8cc1cb8c2',
125125
timeline_title: 'Titled timeline',
126126
};
@@ -166,7 +166,7 @@ describe('helpers', () => {
166166
query: 'test query',
167167
index: ['filebeat-'],
168168
saved_id: 'test123',
169-
type: 'query',
169+
type: 'saved_query',
170170
};
171171

172172
expect(result).toEqual(expected);
@@ -188,7 +188,7 @@ describe('helpers', () => {
188188
query: 'test query',
189189
index: ['filebeat-'],
190190
saved_id: 'test123',
191-
type: 'query',
191+
type: 'saved_query',
192192
timeline_id: '',
193193
timeline_title: 'Titled timeline',
194194
};
@@ -214,7 +214,7 @@ describe('helpers', () => {
214214
query: 'test query',
215215
index: ['filebeat-'],
216216
saved_id: 'test123',
217-
type: 'query',
217+
type: 'saved_query',
218218
};
219219

220220
expect(result).toEqual(expected);
@@ -236,7 +236,7 @@ describe('helpers', () => {
236236
query: 'test query',
237237
index: ['filebeat-'],
238238
saved_id: 'test123',
239-
type: 'query',
239+
type: 'saved_query',
240240
timeline_id: '86aa74d0-2136-11ea-9864-ebc8cc1cb8c2',
241241
timeline_title: '',
242242
};
@@ -828,10 +828,10 @@ describe('helpers', () => {
828828
mockActions = mockActionsStepRule();
829829
});
830830

831-
test('returns rule with type of query when saved_id exists', () => {
831+
test('returns rule with type of saved_query when saved_id exists', () => {
832832
const result = formatRule<Rule>(mockDefine, mockAbout, mockSchedule, mockActions);
833833

834-
expect(result.type).toEqual('query');
834+
expect(result.type).toEqual('saved_query');
835835
});
836836

837837
test('returns rule with type of query when saved_id does not exist', () => {

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/create/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ export const formatDefineStepData = (defineStepData: DefineStepRule): DefineStep
256256
language: ruleFields.queryBar?.query?.language,
257257
query: ruleFields.queryBar?.query?.query as string,
258258
saved_id: ruleFields.queryBar?.saved_id,
259+
...(ruleType === 'query' &&
260+
ruleFields.queryBar?.saved_id && { type: 'saved_query' as Type }),
259261
};
260262

261263
return {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { BadRequestError } from '@kbn/securitysolution-es-utils';
9-
import { Type, LanguageOrUndefined } from '@kbn/securitysolution-io-ts-alerting-types';
9+
import { Type, LanguageOrUndefined, Language } from '@kbn/securitysolution-io-ts-alerting-types';
1010
import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
1111
import { assertUnreachable } from '../../../../common/utility_types';
1212
import { getQueryFilter } from '../../../../common/detection_engine/get_query_filter';

x-pack/plugins/translations/translations/ja-JP.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20123,6 +20123,7 @@
2012320123
"xpack.securitySolution.detectionEngine.createRule.QueryLabel": "カスタムクエリ",
2012420124
"xpack.securitySolution.detectionEngine.createRule.queryRuleTypeDescription": "クエリ",
2012520125
"xpack.securitySolution.detectionEngine.createRule.ruleActionsField.ruleActionsFormErrorsTitle": "次の一覧の問題を解決してください",
20126+
"xpack.securitySolution.detectionEngine.createRule.savedIdLabel": "保存されたクエリ名",
2012620127
"xpack.securitySolution.detectionEngine.createRule.stepAboutRule.descriptionFieldRequiredError": "説明が必要です。",
2012720128
"xpack.securitySolution.detectionEngine.createRule.stepAboutRule.fiedIndexPatternsLabel": "インデックスパターン",
2012820129
"xpack.securitySolution.detectionEngine.createRule.stepAboutRule.fieldAssociatedToEndpointListLabel": "既存のエンドポイント例外をルールに追加",

x-pack/plugins/translations/translations/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20589,6 +20589,7 @@
2058920589
"xpack.securitySolution.detectionEngine.createRule.QueryLabel": "定制查询",
2059020590
"xpack.securitySolution.detectionEngine.createRule.queryRuleTypeDescription": "查询",
2059120591
"xpack.securitySolution.detectionEngine.createRule.ruleActionsField.ruleActionsFormErrorsTitle": "请修复下面所列的问题",
20592+
"xpack.securitySolution.detectionEngine.createRule.savedIdLabel": "已保存查询名称",
2059220593
"xpack.securitySolution.detectionEngine.createRule.stepAboutRule.descriptionFieldRequiredError": "描述必填。",
2059320594
"xpack.securitySolution.detectionEngine.createRule.stepAboutRule.fiedIndexPatternsLabel": "索引模式",
2059420595
"xpack.securitySolution.detectionEngine.createRule.stepAboutRule.fieldAssociatedToEndpointListLabel": "将现有的终端例外添加到规则",

0 commit comments

Comments
 (0)