From fbdeffb48fcc6c23ded1e84e62d3f33dc84de23d Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 16 Feb 2023 16:35:09 +0100 Subject: [PATCH] Fix eslint rule for restricting certain lodash imports (#151023) Fixes #110422 TL;DR: The `lodash.set` function is unsafe and shouldn't be called. Cause of error: If you specify multiple `no-restricted-imports` paths for the same module, only the last path is used. Instead you need to combine them into a single path as I've done in this PR. This regression was introduced in #100277 --- .eslintrc.js | 151 +++++++++--------- .../src/lib/utils/dedot.ts | 2 +- .../kbn-apm-synthtrace-client/tsconfig.json | 1 + .../build_filters/phrase_filter.test.ts | 2 +- packages/kbn-es-query/tsconfig.json | 1 + .../src/common/lib/ast/to_expression.test.js | 3 +- packages/kbn-interpreter/tsconfig.json | 1 + packages/kbn-safer-lodash-set/README.md | 2 +- .../control_group/control_group_telemetry.ts | 2 +- src/plugins/controls/tsconfig.json | 1 + .../common/data_views/data_views.test.ts | 3 +- src/plugins/data_views/tsconfig.json | 1 + .../es/content_stream/content_stream.test.ts | 2 +- src/plugins/files/tsconfig.json | 1 + .../create_action_event_log_record_object.ts | 3 +- x-pack/plugins/actions/tsconfig.json | 3 +- .../server/lib/rule_run_metrics_store.ts | 2 +- .../common/apply_bulk_edit_operation.ts | 3 +- .../fleet/get_package_policy_decorators.ts | 3 +- x-pack/plugins/apm/tsconfig.json | 1 + .../partition_labels/extended_template.tsx | 2 +- .../partition_labels/simple_template.tsx | 2 +- x-pack/plugins/cases/public/api/utils.ts | 3 +- .../cases/public/common/mock/connectors.ts | 2 +- .../cases/public/containers/api.test.tsx | 3 +- .../migrations/user_actions/alerts.test.ts | 3 +- .../crawl_details_preview.test.tsx | 3 +- .../suggested_documents_callout.test.tsx | 3 +- .../curations/views/curations.test.tsx | 3 +- .../views/curations_overview.test.tsx | 3 +- .../suggested_curations_callout.test.tsx | 3 +- .../crawl_details_preview.test.tsx | 3 +- .../plugins/enterprise_search/tsconfig.json | 1 + x-pack/plugins/lens/public/utils.ts | 3 +- x-pack/plugins/lens/tsconfig.json | 1 + .../server/lib/logstash/get_node_info.test.ts | 3 +- ...managed_policy_create_import_extension.tsx | 3 +- .../osquery/server/lib/update_global_packs.ts | 3 +- .../server/routes/pack/create_pack_route.ts | 3 +- .../server/routes/pack/update_pack_route.ts | 15 +- .../routes/status/create_status_route.ts | 3 +- x-pack/plugins/osquery/tsconfig.json | 1 + .../server/lib/content_stream.test.ts | 2 +- .../server/routes/lib/jobs_query.test.ts | 2 +- x-pack/plugins/reporting/tsconfig.json | 1 + .../server/config/create_config.ts | 3 +- x-pack/plugins/screenshotting/tsconfig.json | 1 + .../security/public/components/use_form.ts | 4 +- x-pack/plugins/security/tsconfig.json | 1 + .../column_headers/helpers.test.tsx | 3 +- .../components/alerts_table/actions.test.tsx | 2 +- .../public/explore/network/store/reducer.ts | 3 +- .../public/explore/users/store/reducer.ts | 2 +- .../services/action_responder.ts | 2 +- .../enrichment_by_type/host_risk.ts | 3 +- .../enrichment_by_type/user_risk.ts | 3 +- .../enrichments/utils/transforms.test.ts | 2 +- .../server/lib/telemetry/helpers.test.ts | 3 +- .../opsgenie/render_template_variables.ts | 3 +- .../connector_types/tines/render.test.ts | 2 +- .../server/connector_types/tines/render.ts | 2 +- x-pack/plugins/stack_connectors/tsconfig.json | 1 + .../lib/requests/get_monitor_duration.test.ts | 2 +- .../lib/requests/get_pings.test.ts | 2 +- .../requests/search/find_potential_matches.ts | 2 +- x-pack/plugins/synthetics/tsconfig.json | 1 + .../application/lib/value_validators.ts | 3 +- .../plugins/triggers_actions_ui/tsconfig.json | 1 + 68 files changed, 172 insertions(+), 141 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c011bbe6636c0..221453e382802 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -183,50 +183,49 @@ const DEV_PATTERNS = [ const RESTRICTED_IMPORTS = [ { name: 'lodash', - importNames: ['set', 'setWith'], - message: 'Please use @kbn/safer-lodash-set instead', + importNames: ['set', 'setWith', 'template'], + message: + 'lodash.set/setWith: Please use @kbn/safer-lodash-set instead.\n' + + 'lodash.template: Function is unsafe, and not compatible with our content security policy.', }, { name: 'lodash.set', - message: 'Please use @kbn/safer-lodash-set instead', + message: 'Please use @kbn/safer-lodash-set/set instead', }, { name: 'lodash.setwith', - message: 'Please use @kbn/safer-lodash-set instead', + message: 'Please use @kbn/safer-lodash-set/setWith instead', }, { name: 'lodash/set', - message: 'Please use @kbn/safer-lodash-set instead', + message: 'Please use @kbn/safer-lodash-set/set instead', }, { name: 'lodash/setWith', - message: 'Please use @kbn/safer-lodash-set instead', + message: 'Please use @kbn/safer-lodash-set/setWith instead', }, { name: 'lodash/fp', - importNames: ['set', 'setWith', 'assoc', 'assocPath'], - message: 'Please use @kbn/safer-lodash-set instead', + importNames: ['set', 'setWith', 'assoc', 'assocPath', 'template'], + message: + 'lodash.set/setWith/assoc/assocPath: Please use @kbn/safer-lodash-set/fp instead\n' + + 'lodash.template: Function is unsafe, and not compatible with our content security policy.', }, { name: 'lodash/fp/set', - message: 'Please use @kbn/safer-lodash-set instead', + message: 'Please use @kbn/safer-lodash-set/fp/set instead', }, { name: 'lodash/fp/setWith', - message: 'Please use @kbn/safer-lodash-set instead', + message: 'Please use @kbn/safer-lodash-set/fp/setWith instead', }, { name: 'lodash/fp/assoc', - message: 'Please use @kbn/safer-lodash-set instead', + message: 'Please use @kbn/safer-lodash-set/fp/assoc instead', }, { name: 'lodash/fp/assocPath', - message: 'Please use @kbn/safer-lodash-set instead', - }, - { - name: 'lodash', - importNames: ['template'], - message: 'lodash.template is unsafe, and not compatible with our content security policy.', + message: 'Please use @kbn/safer-lodash-set/fp/assocPath instead', }, { name: 'lodash.template', @@ -236,11 +235,6 @@ const RESTRICTED_IMPORTS = [ name: 'lodash/template', message: 'lodash.template is unsafe, and not compatible with our content security policy.', }, - { - name: 'lodash/fp', - importNames: ['template'], - message: 'lodash.template is unsafe, and not compatible with our content security policy.', - }, { name: 'lodash/fp/template', message: 'lodash.template is unsafe, and not compatible with our content security policy.', @@ -744,47 +738,54 @@ module.exports = { { files: ['**/*.{js,mjs,ts,tsx}'], rules: { - 'no-restricted-imports': [ - 2, + 'no-restricted-imports': ['error', ...RESTRICTED_IMPORTS], + 'no-restricted-modules': [ + 'error', { - paths: RESTRICTED_IMPORTS, + name: 'lodash.set', + message: 'Please use @kbn/safer-lodash-set instead', }, - ], - 'no-restricted-modules': [ - 2, { - paths: [ - { - name: 'lodash.set', - message: 'Please use @kbn/safer-lodash-set instead', - }, - { - name: 'lodash.setwith', - message: 'Please use @kbn/safer-lodash-set instead', - }, - { - name: 'lodash.template', - message: - 'lodash.template is unsafe, and not compatible with our content security policy.', - }, - { - name: 'lodash/set', - message: 'Please use @kbn/safer-lodash-set instead', - }, - { - name: 'lodash/setWith', - message: 'Please use @kbn/safer-lodash-set instead', - }, - { - name: 'lodash/template', - message: - 'lodash.template is unsafe, and not compatible with our content security policy.', - }, - ], + name: 'lodash.setwith', + message: 'Please use @kbn/safer-lodash-set instead', + }, + { + name: 'lodash.template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, + { + name: 'lodash/set', + message: 'Please use @kbn/safer-lodash-set/set instead', + }, + { + name: 'lodash/setWith', + message: 'Please use @kbn/safer-lodash-set/setWith instead', + }, + { + name: 'lodash/fp/set', + message: 'Please use @kbn/safer-lodash-set/fp/set instead', + }, + { + name: 'lodash/fp/setWith', + message: 'Please use @kbn/safer-lodash-set/fp/setWith instead', + }, + { + name: 'lodash/fp/assoc', + message: 'Please use @kbn/safer-lodash-set/fp/assoc instead', + }, + { + name: 'lodash/fp/assocPath', + message: 'Please use @kbn/safer-lodash-set/fp/assocPath instead', + }, + { + name: 'lodash/template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', }, ], 'no-restricted-properties': [ - 2, + 'error', { object: 'lodash', property: 'set', @@ -795,18 +796,6 @@ module.exports = { property: 'set', message: 'Please use @kbn/safer-lodash-set instead', }, - { - object: 'lodash', - property: 'template', - message: - 'lodash.template is unsafe, and not compatible with our content security policy.', - }, - { - object: '_', - property: 'template', - message: - 'lodash.template is unsafe, and not compatible with our content security policy.', - }, { object: 'lodash', property: 'setWith', @@ -837,6 +826,18 @@ module.exports = { property: 'assocPath', message: 'Please use @kbn/safer-lodash-set instead', }, + { + object: 'lodash', + property: 'template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, + { + object: '_', + property: 'template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, ], }, }, @@ -844,15 +845,11 @@ module.exports = { files: ['**/common/**/*.{js,mjs,ts,tsx}', '**/public/**/*.{js,mjs,ts,tsx}'], rules: { 'no-restricted-imports': [ - 2, + 'error', + ...RESTRICTED_IMPORTS, { - paths: [ - ...RESTRICTED_IMPORTS, - { - name: 'semver', - message: 'Please use "semver/*/{function}" instead', - }, - ], + name: 'semver', + message: 'Please use "semver/*/{function}" instead', }, ], }, diff --git a/packages/kbn-apm-synthtrace-client/src/lib/utils/dedot.ts b/packages/kbn-apm-synthtrace-client/src/lib/utils/dedot.ts index 5d0f57fb5840b..3c0d3974d6759 100644 --- a/packages/kbn-apm-synthtrace-client/src/lib/utils/dedot.ts +++ b/packages/kbn-apm-synthtrace-client/src/lib/utils/dedot.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; export function dedot(source: Record, target: Record) { // eslint-disable-next-line guard-for-in diff --git a/packages/kbn-apm-synthtrace-client/tsconfig.json b/packages/kbn-apm-synthtrace-client/tsconfig.json index 8286fda7455b0..5e9a9c6cc2bca 100644 --- a/packages/kbn-apm-synthtrace-client/tsconfig.json +++ b/packages/kbn-apm-synthtrace-client/tsconfig.json @@ -14,5 +14,6 @@ ], "kbn_references": [ "@kbn/datemath", + "@kbn/safer-lodash-set", ] } diff --git a/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts index f2fc685b2e180..aca38ba285b27 100644 --- a/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts +++ b/packages/kbn-es-query/src/filters/build_filters/phrase_filter.test.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { buildInlineScriptForPhraseFilter, buildPhraseFilter, diff --git a/packages/kbn-es-query/tsconfig.json b/packages/kbn-es-query/tsconfig.json index 07000887f13f8..9dda3fcbcc2cf 100644 --- a/packages/kbn-es-query/tsconfig.json +++ b/packages/kbn-es-query/tsconfig.json @@ -15,6 +15,7 @@ "kbn_references": [ "@kbn/utility-types", "@kbn/i18n", + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*", diff --git a/packages/kbn-interpreter/src/common/lib/ast/to_expression.test.js b/packages/kbn-interpreter/src/common/lib/ast/to_expression.test.js index 98d2cfa1153f2..e97d64abc640c 100644 --- a/packages/kbn-interpreter/src/common/lib/ast/to_expression.test.js +++ b/packages/kbn-interpreter/src/common/lib/ast/to_expression.test.js @@ -7,7 +7,8 @@ */ import { toExpression } from './to_expression'; -import { cloneDeep, set, unset } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep, unset } from 'lodash'; describe('toExpression', () => { describe('single expression', () => { diff --git a/packages/kbn-interpreter/tsconfig.json b/packages/kbn-interpreter/tsconfig.json index 8af1ae01dce1b..dc10af2e6fba6 100644 --- a/packages/kbn-interpreter/tsconfig.json +++ b/packages/kbn-interpreter/tsconfig.json @@ -13,6 +13,7 @@ "**/*.js" ], "kbn_references": [ + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*", diff --git a/packages/kbn-safer-lodash-set/README.md b/packages/kbn-safer-lodash-set/README.md index 08df12ff01ec3..823b1acff3b01 100644 --- a/packages/kbn-safer-lodash-set/README.md +++ b/packages/kbn-safer-lodash-set/README.md @@ -7,7 +7,7 @@ Lodash v4.x. ## Example Usage ```js -const { set } = require('@elastic/safer-loadsh-set'); +const { set } = require('@kbn/safer-lodash-set'); const object = { a: [{ b: { c: 3 } }] }; diff --git a/src/plugins/controls/server/control_group/control_group_telemetry.ts b/src/plugins/controls/server/control_group/control_group_telemetry.ts index 83e363e081241..141fb6808b5ee 100644 --- a/src/plugins/controls/server/control_group/control_group_telemetry.ts +++ b/src/plugins/controls/server/control_group/control_group_telemetry.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { PersistableStateService } from '@kbn/kibana-utils-plugin/common'; import { ControlGroupTelemetry, diff --git a/src/plugins/controls/tsconfig.json b/src/plugins/controls/tsconfig.json index 9acd44b5c2f7e..5029897be467b 100644 --- a/src/plugins/controls/tsconfig.json +++ b/src/plugins/controls/tsconfig.json @@ -33,6 +33,7 @@ "@kbn/config-schema", "@kbn/storybook", "@kbn/ui-theme", + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*", diff --git a/src/plugins/data_views/common/data_views/data_views.test.ts b/src/plugins/data_views/common/data_views/data_views.test.ts index b382827d5d37a..01e2b9b1d95f3 100644 --- a/src/plugins/data_views/common/data_views/data_views.test.ts +++ b/src/plugins/data_views/common/data_views/data_views.test.ts @@ -6,7 +6,8 @@ * Side Public License, v 1. */ -import { defaults, get, set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { defaults, get } from 'lodash'; import { DataViewsService, DataView } from '.'; import { fieldFormatsMock } from '@kbn/field-formats-plugin/common/mocks'; diff --git a/src/plugins/data_views/tsconfig.json b/src/plugins/data_views/tsconfig.json index 614b1beda1115..ae13beea68d45 100644 --- a/src/plugins/data_views/tsconfig.json +++ b/src/plugins/data_views/tsconfig.json @@ -26,6 +26,7 @@ "@kbn/core-test-helpers-http-setup-browser", "@kbn/config-schema", "@kbn/utility-types-jest", + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*", diff --git a/src/plugins/files/server/blob_storage_service/adapters/es/content_stream/content_stream.test.ts b/src/plugins/files/server/blob_storage_service/adapters/es/content_stream/content_stream.test.ts index 48410081da3ff..5c4ba047d107c 100644 --- a/src/plugins/files/server/blob_storage_service/adapters/es/content_stream/content_stream.test.ts +++ b/src/plugins/files/server/blob_storage_service/adapters/es/content_stream/content_stream.test.ts @@ -7,7 +7,7 @@ */ import type { Logger } from '@kbn/core/server'; -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { Readable } from 'stream'; import { encode } from 'cbor-x'; import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks'; diff --git a/src/plugins/files/tsconfig.json b/src/plugins/files/tsconfig.json index 02b5acc39ff80..8a14fd5ef06bc 100644 --- a/src/plugins/files/tsconfig.json +++ b/src/plugins/files/tsconfig.json @@ -27,6 +27,7 @@ "@kbn/core-saved-objects-api-server", "@kbn/core-logging-server-mocks", "@kbn/ecs", + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/actions/server/lib/create_action_event_log_record_object.ts b/x-pack/plugins/actions/server/lib/create_action_event_log_record_object.ts index d3ad7c1ae3006..95a6101d684f5 100644 --- a/x-pack/plugins/actions/server/lib/create_action_event_log_record_object.ts +++ b/x-pack/plugins/actions/server/lib/create_action_event_log_record_object.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { isEmpty, set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { isEmpty } from 'lodash'; import { IEvent, SAVED_OBJECT_REL_PRIMARY } from '@kbn/event-log-plugin/server'; import { RelatedSavedObjects } from './related_saved_objects'; diff --git a/x-pack/plugins/actions/tsconfig.json b/x-pack/plugins/actions/tsconfig.json index e65c7725c8eaf..72ba9c7c92e09 100644 --- a/x-pack/plugins/actions/tsconfig.json +++ b/x-pack/plugins/actions/tsconfig.json @@ -31,7 +31,8 @@ "@kbn/std", "@kbn/logging", "@kbn/logging-mocks", - "@kbn/core-elasticsearch-client-server-mocks" + "@kbn/core-elasticsearch-client-server-mocks", + "@kbn/safer-lodash-set" ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/alerting/server/lib/rule_run_metrics_store.ts b/x-pack/plugins/alerting/server/lib/rule_run_metrics_store.ts index 6bd4ec53bc6a6..db83aeb7a63d6 100644 --- a/x-pack/plugins/alerting/server/lib/rule_run_metrics_store.ts +++ b/x-pack/plugins/alerting/server/lib/rule_run_metrics_store.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { ActionsCompletion } from '../types'; import { ActionsConfigMap } from './get_actions_config_map'; import { SearchMetrics } from './types'; diff --git a/x-pack/plugins/alerting/server/rules_client/common/apply_bulk_edit_operation.ts b/x-pack/plugins/alerting/server/rules_client/common/apply_bulk_edit_operation.ts index b5ca53642496e..e20624c77b2c5 100644 --- a/x-pack/plugins/alerting/server/rules_client/common/apply_bulk_edit_operation.ts +++ b/x-pack/plugins/alerting/server/rules_client/common/apply_bulk_edit_operation.ts @@ -4,7 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { set, get, isEqual } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { get, isEqual } from 'lodash'; import type { BulkEditOperation, BulkEditFields } from '../types'; // defining an union type that will passed directly to generic function as a workaround for the issue similar to diff --git a/x-pack/plugins/apm/server/routes/fleet/get_package_policy_decorators.ts b/x-pack/plugins/apm/server/routes/fleet/get_package_policy_decorators.ts index 577d83dc765ca..39d02e95b6109 100644 --- a/x-pack/plugins/apm/server/routes/fleet/get_package_policy_decorators.ts +++ b/x-pack/plugins/apm/server/routes/fleet/get_package_policy_decorators.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { cloneDeep, get, set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep, get } from 'lodash'; import { NewPackagePolicy } from '@kbn/fleet-plugin/common'; import { AgentConfiguration } from '../../../common/agent_configuration/configuration_types'; import { AGENT_NAME } from '../../../common/es_fields/apm'; diff --git a/x-pack/plugins/apm/tsconfig.json b/x-pack/plugins/apm/tsconfig.json index b1bb6362af1a9..4fc45adafd44d 100644 --- a/x-pack/plugins/apm/tsconfig.json +++ b/x-pack/plugins/apm/tsconfig.json @@ -78,6 +78,7 @@ "@kbn/core-elasticsearch-server", "@kbn/shared-ux-prompt-not-found", "@kbn/core-saved-objects-api-server", + "@kbn/safer-lodash-set", "@kbn/shared-ux-router", ], "exclude": [ diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/partition_labels/extended_template.tsx b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/partition_labels/extended_template.tsx index af74acc622789..2e7007e8d2551 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/partition_labels/extended_template.tsx +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/partition_labels/extended_template.tsx @@ -25,7 +25,7 @@ import { EuiText, } from '@elastic/eui'; import { ExpressionAstExpression } from '@kbn/expressions-plugin/common'; -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { defaultExpression } from './default_expression'; import { Fields } from './types'; import { getFieldPath, getFieldValue } from './utils'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/partition_labels/simple_template.tsx b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/partition_labels/simple_template.tsx index 53d9b3e2d4146..08e27fbcd0988 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/partition_labels/simple_template.tsx +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/partition_labels/simple_template.tsx @@ -9,7 +9,7 @@ import React, { FunctionComponent, useCallback, useEffect } from 'react'; import PropTypes from 'prop-types'; import { EuiSwitch, EuiSwitchEvent } from '@elastic/eui'; import { ExpressionAstExpression } from '@kbn/expressions-plugin/common'; -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { defaultExpression } from './default_expression'; import { getFieldPath, getFieldValue } from './utils'; diff --git a/x-pack/plugins/cases/public/api/utils.ts b/x-pack/plugins/cases/public/api/utils.ts index 87b48a0df9c58..f7ce3bf0817d2 100644 --- a/x-pack/plugins/cases/public/api/utils.ts +++ b/x-pack/plugins/cases/public/api/utils.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { isArray, set, camelCase, isObject, omit, get } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { isArray, camelCase, isObject, omit, get } from 'lodash'; import { isCommentRequestTypeExternalReference, isCommentRequestTypePersistableState, diff --git a/x-pack/plugins/cases/public/common/mock/connectors.ts b/x-pack/plugins/cases/public/common/mock/connectors.ts index a036b5a6b8981..4d733c4e660a8 100644 --- a/x-pack/plugins/cases/public/common/mock/connectors.ts +++ b/x-pack/plugins/cases/public/common/mock/connectors.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import type { ActionConnector, ActionTypeConnector } from '../../../common/api'; import { basicPush } from '../../containers/mock'; import type { CaseConnectors } from '../../containers/types'; diff --git a/x-pack/plugins/cases/public/containers/api.test.tsx b/x-pack/plugins/cases/public/containers/api.test.tsx index 2f0c8645b3317..546fcb921b270 100644 --- a/x-pack/plugins/cases/public/containers/api.test.tsx +++ b/x-pack/plugins/cases/public/containers/api.test.tsx @@ -62,7 +62,8 @@ import { import { DEFAULT_FILTER_OPTIONS, DEFAULT_QUERY_PARAMS } from './use_get_cases'; import { getCasesStatus } from '../api'; import { getCaseConnectorsMockResponse } from '../common/mock/connectors'; -import { cloneDeep, set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep } from 'lodash'; const abortCtrl = new AbortController(); const mockKibanaServices = KibanaServices.get as jest.Mock; diff --git a/x-pack/plugins/cases/server/saved_object_types/migrations/user_actions/alerts.test.ts b/x-pack/plugins/cases/server/saved_object_types/migrations/user_actions/alerts.test.ts index 70cf329675126..a9c329d4e85b9 100644 --- a/x-pack/plugins/cases/server/saved_object_types/migrations/user_actions/alerts.test.ts +++ b/x-pack/plugins/cases/server/saved_object_types/migrations/user_actions/alerts.test.ts @@ -10,7 +10,8 @@ import type { SavedObjectMigrationContext, SavedObjectsMigrationLogger, } from '@kbn/core/server'; -import { cloneDeep, omit, set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep, omit } from 'lodash'; import { migrationMocks } from '@kbn/core/server/mocks'; import { removeRuleInformation } from './alerts'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawl_details_flyout/crawl_details_preview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawl_details_flyout/crawl_details_preview.test.tsx index b941b8d497850..07871fe7dd7ec 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawl_details_flyout/crawl_details_preview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/crawler/components/crawl_details_flyout/crawl_details_preview.test.tsx @@ -9,7 +9,8 @@ import { setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; -import { set } from 'lodash/fp'; + +import { set } from '@kbn/safer-lodash-set/fp'; import { AccordionList } from '../../../../../shared/accordion_list/accordion_list'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/suggested_documents_callout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/suggested_documents_callout.test.tsx index 4fdce0bcd0299..ef1077e4dc9a3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/suggested_documents_callout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/curation/suggested_documents_callout.test.tsx @@ -11,7 +11,8 @@ import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; import { shallow } from 'enzyme'; -import { set } from 'lodash/fp'; + +import { set } from '@kbn/safer-lodash-set/fp'; import { SuggestionsCallout } from '../components/suggestions_callout'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations.test.tsx index 3de39f21e1de0..8bc5e33263da0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations.test.tsx @@ -14,9 +14,8 @@ import React from 'react'; import { shallow } from 'enzyme'; -import { set } from 'lodash/fp'; - import { EuiTab } from '@elastic/eui'; +import { set } from '@kbn/safer-lodash-set/fp'; import { getPageHeaderTabs, getPageTitle } from '../../../../test_helpers'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_overview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_overview.test.tsx index b7da6d64b6a8a..ba8ec782a4afd 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_overview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/curations/views/curations_overview.test.tsx @@ -12,7 +12,8 @@ import '../../../__mocks__/engine_logic.mock'; import React from 'react'; import { shallow } from 'enzyme'; -import { set } from 'lodash/fp'; + +import { set } from '@kbn/safer-lodash-set/fp'; import { CurationsTable, EmptyState } from '../components'; diff --git a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/suggested_curations_callout.test.tsx b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/suggested_curations_callout.test.tsx index 2fb9bb255110d..f539adda4ccf3 100644 --- a/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/suggested_curations_callout.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/app_search/components/engine_overview/components/suggested_curations_callout.test.tsx @@ -11,7 +11,8 @@ import { setMockValues } from '../../../../__mocks__/kea_logic'; import React from 'react'; import { shallow } from 'enzyme'; -import { set } from 'lodash/fp'; + +import { set } from '@kbn/safer-lodash-set/fp'; import { SuggestionsCallout } from '../../curations/components/suggestions_callout'; diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/crawler/crawl_details_flyout/crawl_details_preview.test.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/crawler/crawl_details_flyout/crawl_details_preview.test.tsx index 590989db59d02..58a593ebdd037 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/crawler/crawl_details_flyout/crawl_details_preview.test.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/search_index/crawler/crawl_details_flyout/crawl_details_preview.test.tsx @@ -9,7 +9,8 @@ import { setMockValues } from '../../../../../__mocks__/kea_logic'; import React from 'react'; import { shallow, ShallowWrapper } from 'enzyme'; -import { set } from 'lodash/fp'; + +import { set } from '@kbn/safer-lodash-set/fp'; import { AccordionList } from '../../../../../shared/accordion_list/accordion_list'; diff --git a/x-pack/plugins/enterprise_search/tsconfig.json b/x-pack/plugins/enterprise_search/tsconfig.json index 8b9eef8ce1864..3d027fd53e0f7 100644 --- a/x-pack/plugins/enterprise_search/tsconfig.json +++ b/x-pack/plugins/enterprise_search/tsconfig.json @@ -47,6 +47,7 @@ "@kbn/cypress-config", "@kbn/discover-plugin", "@kbn/guided-onboarding", + "@kbn/safer-lodash-set", "@kbn/shared-ux-router", "@kbn/core-http-browser", ] diff --git a/x-pack/plugins/lens/public/utils.ts b/x-pack/plugins/lens/public/utils.ts index 5a50e9068d67b..4592bf5bfddcd 100644 --- a/x-pack/plugins/lens/public/utils.ts +++ b/x-pack/plugins/lens/public/utils.ts @@ -4,7 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { set, uniq, cloneDeep } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { uniq, cloneDeep } from 'lodash'; import { i18n } from '@kbn/i18n'; import moment from 'moment-timezone'; import type { Serializable } from '@kbn/utility-types'; diff --git a/x-pack/plugins/lens/tsconfig.json b/x-pack/plugins/lens/tsconfig.json index 3732371c9fd21..b80f702125d3c 100644 --- a/x-pack/plugins/lens/tsconfig.json +++ b/x-pack/plugins/lens/tsconfig.json @@ -63,6 +63,7 @@ "@kbn/core-saved-objects-common", "@kbn/core-ui-settings-browser", "@kbn/core-saved-objects-server", + "@kbn/safer-lodash-set", "@kbn/shared-ux-router", ], "exclude": [ diff --git a/x-pack/plugins/monitoring/server/lib/logstash/get_node_info.test.ts b/x-pack/plugins/monitoring/server/lib/logstash/get_node_info.test.ts index 50410f4ef0ea5..356dbfaa29d41 100644 --- a/x-pack/plugins/monitoring/server/lib/logstash/get_node_info.test.ts +++ b/x-pack/plugins/monitoring/server/lib/logstash/get_node_info.test.ts @@ -6,7 +6,8 @@ */ import moment from 'moment'; -import { set, unset } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { unset } from 'lodash'; import { STANDALONE_CLUSTER_CLUSTER_UUID } from '../../../common/constants'; import { handleResponse, getNodeInfo } from './get_node_info'; import { LegacyRequest } from '../../types'; diff --git a/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx b/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx index cf736d4fe2f57..34090e8e966d2 100644 --- a/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx +++ b/x-pack/plugins/osquery/public/fleet_integration/osquery_managed_policy_create_import_extension.tsx @@ -5,7 +5,8 @@ * 2.0. */ -import { pickBy, get, isEmpty, isString, unset, set, intersection } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { pickBy, get, isEmpty, isString, unset, intersection } from 'lodash'; import satisfies from 'semver/functions/satisfies'; import { EuiFlexGroup, diff --git a/x-pack/plugins/osquery/server/lib/update_global_packs.ts b/x-pack/plugins/osquery/server/lib/update_global_packs.ts index 523e79443fbdb..1f806c06f7977 100644 --- a/x-pack/plugins/osquery/server/lib/update_global_packs.ts +++ b/x-pack/plugins/osquery/server/lib/update_global_packs.ts @@ -6,7 +6,8 @@ */ import type { SavedObjectsClient, SavedObjectsFindResponse } from '@kbn/core/server'; -import { has, map, mapKeys, set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { has, map, mapKeys } from 'lodash'; import type { NewPackagePolicy } from '@kbn/fleet-plugin/common'; import { AGENT_POLICY_SAVED_OBJECT_TYPE } from '@kbn/fleet-plugin/common'; import produce from 'immer'; diff --git a/x-pack/plugins/osquery/server/routes/pack/create_pack_route.ts b/x-pack/plugins/osquery/server/routes/pack/create_pack_route.ts index 37d61b908f150..ff4ffe5b28287 100644 --- a/x-pack/plugins/osquery/server/routes/pack/create_pack_route.ts +++ b/x-pack/plugins/osquery/server/routes/pack/create_pack_route.ts @@ -6,7 +6,8 @@ */ import moment from 'moment-timezone'; -import { has, set, unset, find, some, mapKeys } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { has, unset, find, some, mapKeys } from 'lodash'; import { schema } from '@kbn/config-schema'; import { produce } from 'immer'; import type { PackagePolicy } from '@kbn/fleet-plugin/common'; diff --git a/x-pack/plugins/osquery/server/routes/pack/update_pack_route.ts b/x-pack/plugins/osquery/server/routes/pack/update_pack_route.ts index c8d053d8d92da..485ecffce3cd3 100644 --- a/x-pack/plugins/osquery/server/routes/pack/update_pack_route.ts +++ b/x-pack/plugins/osquery/server/routes/pack/update_pack_route.ts @@ -6,19 +6,8 @@ */ import moment from 'moment-timezone'; -import { - set, - unset, - has, - difference, - filter, - find, - map, - mapKeys, - uniq, - some, - isEmpty, -} from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { unset, has, difference, filter, find, map, mapKeys, uniq, some, isEmpty } from 'lodash'; import { schema } from '@kbn/config-schema'; import { produce } from 'immer'; import type { PackagePolicy } from '@kbn/fleet-plugin/common'; diff --git a/x-pack/plugins/osquery/server/routes/status/create_status_route.ts b/x-pack/plugins/osquery/server/routes/status/create_status_route.ts index 700ea77f22445..785b9540e173f 100644 --- a/x-pack/plugins/osquery/server/routes/status/create_status_route.ts +++ b/x-pack/plugins/osquery/server/routes/status/create_status_route.ts @@ -7,7 +7,8 @@ import { produce } from 'immer'; import { satisfies } from 'semver'; -import { filter, reduce, mapKeys, each, set, unset, uniq, map, has } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { filter, reduce, mapKeys, each, unset, uniq, map, has } from 'lodash'; import type { PackagePolicyInputStream } from '@kbn/fleet-plugin/common'; import { PACKAGE_POLICY_SAVED_OBJECT_TYPE, diff --git a/x-pack/plugins/osquery/tsconfig.json b/x-pack/plugins/osquery/tsconfig.json index 678f4900134cf..226519bb10711 100644 --- a/x-pack/plugins/osquery/tsconfig.json +++ b/x-pack/plugins/osquery/tsconfig.json @@ -68,6 +68,7 @@ "@kbn/core-elasticsearch-server", "@kbn/core-saved-objects-api-server", "@kbn/logging", + "@kbn/safer-lodash-set", "@kbn/shared-ux-router", ] } diff --git a/x-pack/plugins/reporting/server/lib/content_stream.test.ts b/x-pack/plugins/reporting/server/lib/content_stream.test.ts index aa0d5c85acedf..288d528c722bf 100644 --- a/x-pack/plugins/reporting/server/lib/content_stream.test.ts +++ b/x-pack/plugins/reporting/server/lib/content_stream.test.ts @@ -6,7 +6,7 @@ */ import type { Logger } from '@kbn/core/server'; -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { elasticsearchServiceMock, loggingSystemMock } from '@kbn/core/server/mocks'; import { ContentStream } from './content_stream'; diff --git a/x-pack/plugins/reporting/server/routes/lib/jobs_query.test.ts b/x-pack/plugins/reporting/server/routes/lib/jobs_query.test.ts index 0f72863ee03dd..202fa55049b3d 100644 --- a/x-pack/plugins/reporting/server/routes/lib/jobs_query.test.ts +++ b/x-pack/plugins/reporting/server/routes/lib/jobs_query.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { ElasticsearchClient } from '@kbn/core/server'; import { elasticsearchServiceMock } from '@kbn/core/server/mocks'; import { statuses } from '../../lib'; diff --git a/x-pack/plugins/reporting/tsconfig.json b/x-pack/plugins/reporting/tsconfig.json index 48b2f20a3c1e0..254c115322fd0 100644 --- a/x-pack/plugins/reporting/tsconfig.json +++ b/x-pack/plugins/reporting/tsconfig.json @@ -36,6 +36,7 @@ "@kbn/core-http-server", "@kbn/core-test-helpers-test-utils", "@kbn/expressions-plugin", + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/screenshotting/server/config/create_config.ts b/x-pack/plugins/screenshotting/server/config/create_config.ts index 1b7076d05e478..c2ab86b5de76e 100644 --- a/x-pack/plugins/screenshotting/server/config/create_config.ts +++ b/x-pack/plugins/screenshotting/server/config/create_config.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { cloneDeep, set, upperFirst } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep, upperFirst } from 'lodash'; import type { Logger } from '@kbn/core/server'; import { getDefaultChromiumSandboxDisabled } from './default_chromium_sandbox_disabled'; import { ConfigType } from './schema'; diff --git a/x-pack/plugins/screenshotting/tsconfig.json b/x-pack/plugins/screenshotting/tsconfig.json index 71bbdc7de7396..b2e1fd6ed184f 100644 --- a/x-pack/plugins/screenshotting/tsconfig.json +++ b/x-pack/plugins/screenshotting/tsconfig.json @@ -21,6 +21,7 @@ "@kbn/std", "@kbn/i18n", "@kbn/utils", + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/security/public/components/use_form.ts b/x-pack/plugins/security/public/components/use_form.ts index 2b42fda5ba561..b943cfd507249 100644 --- a/x-pack/plugins/security/public/components/use_form.ts +++ b/x-pack/plugins/security/public/components/use_form.ts @@ -5,11 +5,13 @@ * 2.0. */ -import { cloneDeep, cloneDeepWith, get, set } from 'lodash'; +import { cloneDeep, cloneDeepWith, get } from 'lodash'; import type { ChangeEventHandler, FocusEventHandler, ReactEventHandler } from 'react'; import { useState } from 'react'; import useAsyncFn from 'react-use/lib/useAsyncFn'; +import { set } from '@kbn/safer-lodash-set'; + export type FormReturnTuple = [FormState, FormProps]; export interface FormProps { diff --git a/x-pack/plugins/security/tsconfig.json b/x-pack/plugins/security/tsconfig.json index 6106c3e34792b..7278e39b18249 100644 --- a/x-pack/plugins/security/tsconfig.json +++ b/x-pack/plugins/security/tsconfig.json @@ -56,6 +56,7 @@ "@kbn/core-custom-branding-common", "@kbn/core-custom-branding-server-mocks", "@kbn/ecs", + "@kbn/safer-lodash-set", "@kbn/shared-ux-router", ], "exclude": [ diff --git a/x-pack/plugins/security_solution/public/common/components/data_table/column_headers/helpers.test.tsx b/x-pack/plugins/security_solution/public/common/components/data_table/column_headers/helpers.test.tsx index 9320a0270f5aa..34f3320513b47 100644 --- a/x-pack/plugins/security_solution/public/common/components/data_table/column_headers/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/data_table/column_headers/helpers.test.tsx @@ -5,7 +5,8 @@ * 2.0. */ import { mount } from 'enzyme'; -import { omit, set } from 'lodash/fp'; +import { set } from '@kbn/safer-lodash-set/fp'; +import { omit } from 'lodash/fp'; import React from 'react'; import type { BUILT_IN_SCHEMA } from './helpers'; diff --git a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx index dab1bf3b68285..5ad96cfc322d6 100644 --- a/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/alerts_table/actions.test.tsx @@ -7,7 +7,7 @@ import sinon from 'sinon'; import moment from 'moment'; -import set from 'lodash/set'; +import set from '@kbn/safer-lodash-set/set'; import cloneDeep from 'lodash/cloneDeep'; import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; diff --git a/x-pack/plugins/security_solution/public/explore/network/store/reducer.ts b/x-pack/plugins/security_solution/public/explore/network/store/reducer.ts index b55774ef90197..263f0b990280d 100644 --- a/x-pack/plugins/security_solution/public/explore/network/store/reducer.ts +++ b/x-pack/plugins/security_solution/public/explore/network/store/reducer.ts @@ -6,7 +6,8 @@ */ import { reducerWithInitialState } from 'typescript-fsa-reducers'; -import { get, set } from 'lodash/fp'; +import { set } from '@kbn/safer-lodash-set/fp'; +import { get } from 'lodash/fp'; import { Direction, FlowTarget, diff --git a/x-pack/plugins/security_solution/public/explore/users/store/reducer.ts b/x-pack/plugins/security_solution/public/explore/users/store/reducer.ts index 5bb7615ff198a..9ac2fdce4c20d 100644 --- a/x-pack/plugins/security_solution/public/explore/users/store/reducer.ts +++ b/x-pack/plugins/security_solution/public/explore/users/store/reducer.ts @@ -6,7 +6,7 @@ */ import { reducerWithInitialState } from 'typescript-fsa-reducers'; -import { set } from 'lodash/fp'; +import { set } from '@kbn/safer-lodash-set/fp'; import { DEFAULT_TABLE_ACTIVE_PAGE, DEFAULT_TABLE_LIMIT } from '../../../common/store/constants'; import { diff --git a/x-pack/plugins/security_solution/scripts/endpoint/agent_emulator/services/action_responder.ts b/x-pack/plugins/security_solution/scripts/endpoint/agent_emulator/services/action_responder.ts index 93816e06bb7fb..c451198a27208 100644 --- a/x-pack/plugins/security_solution/scripts/endpoint/agent_emulator/services/action_responder.ts +++ b/x-pack/plugins/security_solution/scripts/endpoint/agent_emulator/services/action_responder.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import type { Client } from '@elastic/elasticsearch'; import type { ToolingLog } from '@kbn/tooling-log'; import type { KbnClient } from '@kbn/test'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/enrichment_by_type/host_risk.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/enrichment_by_type/host_risk.ts index c621c83f49ecd..fb061d06ce1e2 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/enrichment_by_type/host_risk.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/enrichment_by_type/host_risk.ts @@ -4,7 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { set, cloneDeep } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep } from 'lodash'; import { getHostRiskIndex } from '../../../../../../common/search_strategy/security_solution/risk_score/common'; import { RiskScoreFields } from '../../../../../../common/search_strategy/security_solution/risk_score/all'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/enrichment_by_type/user_risk.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/enrichment_by_type/user_risk.ts index d6499e9977d54..db959a7671546 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/enrichment_by_type/user_risk.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/enrichment_by_type/user_risk.ts @@ -4,7 +4,8 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { set, cloneDeep } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep } from 'lodash'; import { getUserRiskIndex } from '../../../../../../common/search_strategy/security_solution/risk_score/common'; import { RiskScoreFields } from '../../../../../../common/search_strategy/security_solution/risk_score/all'; import { createSingleFieldMatchEnrichment } from '../create_single_field_match_enrichment'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/utils/transforms.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/utils/transforms.test.ts index 088916ef45598..0e6de54014c3c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/utils/transforms.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/enrichments/utils/transforms.test.ts @@ -9,7 +9,7 @@ import { applyEnrichmentsToEvents, mergeEnrichments } from './transforms'; import { ruleExecutionLogMock } from '../../../rule_monitoring/mocks'; import { createAlert } from '../__mocks__/alerts'; import type { EnrichmentFunction } from '../types'; -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; const createEnrichment = (field: string, value: string): EnrichmentFunction => diff --git a/x-pack/plugins/security_solution/server/lib/telemetry/helpers.test.ts b/x-pack/plugins/security_solution/server/lib/telemetry/helpers.test.ts index 29a4158a77d00..4e3db8c657e04 100644 --- a/x-pack/plugins/security_solution/server/lib/telemetry/helpers.test.ts +++ b/x-pack/plugins/security_solution/server/lib/telemetry/helpers.test.ts @@ -28,7 +28,8 @@ import { } from './helpers'; import type { ESClusterInfo, ESLicense, ExceptionListItem } from './types'; import type { PolicyConfig, PolicyData } from '../../../common/endpoint/types'; -import { cloneDeep, set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep } from 'lodash'; import { loggingSystemMock } from '@kbn/core/server/mocks'; describe('test diagnostic telemetry scheduled task timing helper', () => { diff --git a/x-pack/plugins/stack_connectors/server/connector_types/opsgenie/render_template_variables.ts b/x-pack/plugins/stack_connectors/server/connector_types/opsgenie/render_template_variables.ts index eb84d6c2b0d8f..14670fe162ca6 100644 --- a/x-pack/plugins/stack_connectors/server/connector_types/opsgenie/render_template_variables.ts +++ b/x-pack/plugins/stack_connectors/server/connector_types/opsgenie/render_template_variables.ts @@ -8,7 +8,8 @@ import { renderMustacheObject } from '@kbn/actions-plugin/server/lib/mustache_renderer'; import { ExecutorParams } from '@kbn/actions-plugin/server/sub_action_framework/types'; import { RenderParameterTemplates } from '@kbn/actions-plugin/server/types'; -import { set, cloneDeep, get, isString } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { cloneDeep, get, isString } from 'lodash'; import { RULE_TAGS_TEMPLATE } from '../../../common/opsgenie'; import { OpsgenieSubActions } from '../../../common'; import { CreateAlertSubActionParams } from './types'; diff --git a/x-pack/plugins/stack_connectors/server/connector_types/tines/render.test.ts b/x-pack/plugins/stack_connectors/server/connector_types/tines/render.test.ts index 6abed325bbc45..0c89017088af9 100644 --- a/x-pack/plugins/stack_connectors/server/connector_types/tines/render.test.ts +++ b/x-pack/plugins/stack_connectors/server/connector_types/tines/render.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { set } from 'lodash/fp'; +import { set } from '@kbn/safer-lodash-set/fp'; import { renderParameterTemplates } from './render'; const params = { diff --git a/x-pack/plugins/stack_connectors/server/connector_types/tines/render.ts b/x-pack/plugins/stack_connectors/server/connector_types/tines/render.ts index 2ba3f120e316d..ca3fdf7de5b6c 100644 --- a/x-pack/plugins/stack_connectors/server/connector_types/tines/render.ts +++ b/x-pack/plugins/stack_connectors/server/connector_types/tines/render.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { set } from 'lodash/fp'; +import { set } from '@kbn/safer-lodash-set/fp'; import { ExecutorParams } from '@kbn/actions-plugin/server/sub_action_framework/types'; import { RenderParameterTemplates } from '@kbn/actions-plugin/server/types'; import { SUB_ACTION } from '../../../common/tines/constants'; diff --git a/x-pack/plugins/stack_connectors/tsconfig.json b/x-pack/plugins/stack_connectors/tsconfig.json index cb7b2687aea88..f95d55265cebf 100644 --- a/x-pack/plugins/stack_connectors/tsconfig.json +++ b/x-pack/plugins/stack_connectors/tsconfig.json @@ -26,6 +26,7 @@ "@kbn/kibana-react-plugin", "@kbn/test-jest-helpers", "@kbn/securitysolution-io-ts-utils", + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/get_monitor_duration.test.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/get_monitor_duration.test.ts index 06d5fae6f5663..16dd761180ae0 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/get_monitor_duration.test.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/get_monitor_duration.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import mockChartsData from './__fixtures__/monitor_charts_mock.json'; import { getMonitorDurationChart } from './get_monitor_duration'; import { getUptimeESMockClient } from './test_helpers'; diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/get_pings.test.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/get_pings.test.ts index faf66d4aa8bd8..b035ae778576b 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/get_pings.test.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/get_pings.test.ts @@ -6,7 +6,7 @@ */ import { getPings } from './get_pings'; -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../common/constants'; import { getUptimeESMockClient } from './test_helpers'; diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/find_potential_matches.ts b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/find_potential_matches.ts index d73b9863bec6a..2649205d3b473 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/find_potential_matches.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/lib/requests/search/find_potential_matches.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; import { getQueryStringFilter } from './get_query_string_filter'; import { QueryContext } from './query_context'; import { diff --git a/x-pack/plugins/synthetics/tsconfig.json b/x-pack/plugins/synthetics/tsconfig.json index 93f1026bf13e5..730a1f381d142 100644 --- a/x-pack/plugins/synthetics/tsconfig.json +++ b/x-pack/plugins/synthetics/tsconfig.json @@ -72,6 +72,7 @@ "@kbn/core-saved-objects-api-server-mocks", "@kbn/core-saved-objects-server", "@kbn/shared-ux-prompt-not-found", + "@kbn/safer-lodash-set", "@kbn/shared-ux-router", ], "exclude": [ diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/value_validators.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/value_validators.ts index e4e27291f972a..e7b799519e1d0 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/value_validators.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/value_validators.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { constant, get, set } from 'lodash'; +import { set } from '@kbn/safer-lodash-set'; +import { constant, get } from 'lodash'; import { UserConfiguredActionConnector, IErrorObject, Rule } from '../../types'; export function throwIfAbsent(message: string) { diff --git a/x-pack/plugins/triggers_actions_ui/tsconfig.json b/x-pack/plugins/triggers_actions_ui/tsconfig.json index 2468cb5b30fd2..96a7c05c91a01 100644 --- a/x-pack/plugins/triggers_actions_ui/tsconfig.json +++ b/x-pack/plugins/triggers_actions_ui/tsconfig.json @@ -46,6 +46,7 @@ "@kbn/core-capabilities-common", "@kbn/shared-ux-router", "@kbn/alerts-ui-shared", + "@kbn/safer-lodash-set", ], "exclude": [ "target/**/*",