Skip to content

Commit 4aac0de

Browse files
committed
Replace magic strings with our constant ENDPOINT_LIST_ID
Also replaced a few unintentional uses of this string with the non-reserved 'endpoint_list_id'.
1 parent 4f4f621 commit 4aac0de

File tree

7 files changed

+15
-9
lines changed

7 files changed

+15
-9
lines changed

x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const getExceptionListItemSchemaMock = (): ExceptionListItemSchema => ({
1616
entries: ENTRIES,
1717
id: '1',
1818
item_id: 'endpoint_list_item',
19-
list_id: 'endpoint_list',
19+
list_id: 'endpoint_list_id',
2020
meta: {},
2121
name: 'Sample Endpoint Exception List',
2222
namespace_type: 'single',

x-pack/plugins/lists/common/schemas/response/exception_list_schema.mock.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { ENDPOINT_LIST_ID } from '../..';
8+
79
import { ExceptionListSchema } from './exception_list_schema';
810

911
export const getExceptionListSchemaMock = (): ExceptionListSchema => ({
@@ -12,10 +14,10 @@ export const getExceptionListSchemaMock = (): ExceptionListSchema => ({
1214
created_by: 'user_name',
1315
description: 'This is a sample endpoint type exception',
1416
id: '1',
15-
list_id: 'endpoint_list',
17+
list_id: ENDPOINT_LIST_ID,
1618
meta: {},
1719
name: 'Sample Endpoint Exception List',
18-
namespace_type: 'single',
20+
namespace_type: 'agnostic',
1921
tags: ['user added string for a tag', 'malware'],
2022
tie_breaker_id: '77fd1909-6786-428a-a671-30229a719c1f',
2123
type: 'endpoint',

x-pack/plugins/lists/public/exceptions/api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ describe('Exceptions Lists API', () => {
508508
test('it returns expected format when call succeeds', async () => {
509509
const exceptionResponse = await fetchExceptionListItemsByListId({
510510
http: mockKibanaHttpService(),
511-
listId: 'endpoint_list',
511+
listId: 'endpoint_list_id',
512512
namespaceType: 'single',
513513
pagination: {
514514
page: 1,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { NOTIFICATION_THROTTLE_NO_ACTIONS } from '../../../../../../common/const
1212
import { transformAlertToRuleAction } from '../../../../../../common/detection_engine/transform_actions';
1313
import { RuleType } from '../../../../../../common/detection_engine/types';
1414
import { isMlRule } from '../../../../../../common/machine_learning/helpers';
15+
import { ENDPOINT_LIST_ID } from '../../../../../shared_imports';
1516
import { NewRule } from '../../../../containers/detection_engine/rules';
1617

1718
import {
@@ -167,7 +168,7 @@ export const formatAboutStepData = (aboutStepData: AboutStepRule): AboutStepRule
167168
...(isAssociatedToEndpointList
168169
? {
169170
exceptions_list: [
170-
{ id: 'endpoint_list', namespace_type: 'agnostic', type: 'endpoint' },
171+
{ id: ENDPOINT_LIST_ID, namespace_type: 'agnostic', type: 'endpoint' },
171172
] as AboutStepRuleJson['exceptions_list'],
172173
}
173174
: {}),

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { RuleAlertAction, RuleType } from '../../../../../common/detection_engin
1313
import { isMlRule } from '../../../../../common/machine_learning/helpers';
1414
import { transformRuleToAlertAction } from '../../../../../common/detection_engine/transform_actions';
1515
import { Filter } from '../../../../../../../../src/plugins/data/public';
16+
import { ENDPOINT_LIST_ID } from '../../../../shared_imports';
1617
import { Rule } from '../../../containers/detection_engine/rules';
1718
import {
1819
AboutStepRule,
@@ -137,7 +138,7 @@ export const getAboutStepsData = (rule: Rule, detailsView: boolean): AboutStepRu
137138
return {
138139
isNew: false,
139140
author,
140-
isAssociatedToEndpointList: exceptionsList?.some(({ id }) => id === 'endpoint_list') ?? false,
141+
isAssociatedToEndpointList: exceptionsList?.some(({ id }) => id === ENDPOINT_LIST_ID) ?? false,
141142
isBuildingBlock: buildingBlockType !== undefined,
142143
license: license ?? '',
143144
ruleNameOverride: ruleNameOverride ?? '',

x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { validate } from '../../../../common/validate';
1212
import { Entry, EntryNested } from '../../../../../lists/common/schemas/types/entries';
1313
import { FoundExceptionListItemSchema } from '../../../../../lists/common/schemas/response/found_exception_list_item_schema';
1414
import { ExceptionListClient } from '../../../../../lists/server';
15+
import { ENDPOINT_LIST_ID } from '../../../../common/shared_imports';
1516
import {
1617
InternalArtifactSchema,
1718
TranslatedEntry,
@@ -60,7 +61,7 @@ export async function getFullEndpointExceptionList(
6061

6162
do {
6263
const response = await eClient.findExceptionListItem({
63-
listId: 'endpoint_list',
64+
listId: ENDPOINT_LIST_ID,
6465
namespaceType: 'agnostic',
6566
filter: `exception-list-agnostic.attributes._tags:\"os:${os}\"`,
6667
perPage: 100,

x-pack/test/api_integration/apis/lists/create_exception_list_item.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import expect from '@kbn/expect/expect.js';
88
import { FtrProviderContext } from '../../ftr_provider_context';
9+
import { ENDPOINT_LIST_ID } from '../../../../plugins/lists/common';
910

1011
export default function ({ getService }: FtrProviderContext) {
1112
const esArchiver = getService('esArchiver');
@@ -20,7 +21,7 @@ export default function ({ getService }: FtrProviderContext) {
2021
namespace_type: 'agnostic',
2122
description: 'bad endpoint item for testing',
2223
name: 'bad endpoint item',
23-
list_id: 'endpoint_list',
24+
list_id: ENDPOINT_LIST_ID,
2425
type: 'simple',
2526
entries: [
2627
{
@@ -50,7 +51,7 @@ export default function ({ getService }: FtrProviderContext) {
5051
namespace_type: 'agnostic',
5152
description: 'bad endpoint item for testing',
5253
name: 'bad endpoint item',
53-
list_id: 'endpoint_list',
54+
list_id: ENDPOINT_LIST_ID,
5455
type: 'simple',
5556
entries: [
5657
{

0 commit comments

Comments
 (0)