From fc5bc6b6a2770903148f35e083cb75b52d467118 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Wed, 15 Jul 2020 10:29:57 +0200 Subject: [PATCH] Add @elastic/safer-lodash-set as an alternative to lodash.set (#67452) --- .eslintrc.js | 231 +++++++++- package.json | 1 + packages/elastic-safer-lodash-set/.gitignore | 2 + packages/elastic-safer-lodash-set/.npmignore | 3 + packages/elastic-safer-lodash-set/LICENSE | 34 ++ packages/elastic-safer-lodash-set/README.md | 113 +++++ .../elastic-safer-lodash-set/fp/assoc.d.ts | 9 + packages/elastic-safer-lodash-set/fp/assoc.js | 8 + .../fp/assocPath.d.ts | 9 + .../elastic-safer-lodash-set/fp/assocPath.js | 8 + .../elastic-safer-lodash-set/fp/index.d.ts | 225 ++++++++++ packages/elastic-safer-lodash-set/fp/index.js | 9 + packages/elastic-safer-lodash-set/fp/set.d.ts | 9 + packages/elastic-safer-lodash-set/fp/set.js | 13 + .../elastic-safer-lodash-set/fp/setWith.d.ts | 9 + .../elastic-safer-lodash-set/fp/setWith.js | 13 + packages/elastic-safer-lodash-set/index.d.ts | 64 +++ packages/elastic-safer-lodash-set/index.js | 9 + .../lodash/_baseSet.js | 61 +++ .../elastic-safer-lodash-set/lodash/set.js | 44 ++ .../lodash/setWith.js | 41 ++ .../elastic-safer-lodash-set/package.json | 49 +++ .../scripts/_get_lodash.sh | 15 + .../scripts/license-header.txt | 7 + .../scripts/patches/_baseSet.js.patch | 31 ++ .../scripts/save_state.sh | 18 + .../elastic-safer-lodash-set/scripts/tsd.sh | 17 + .../scripts/update.sh | 37 ++ packages/elastic-safer-lodash-set/set.d.ts | 9 + packages/elastic-safer-lodash-set/set.js | 8 + .../elastic-safer-lodash-set/setWith.d.ts | 9 + packages/elastic-safer-lodash-set/setWith.js | 8 + .../test/fp.test-d.ts | 85 ++++ .../test/fp_assoc.test-d.ts | 25 ++ .../test/fp_assocPath.test-d.ts | 25 ++ .../test/fp_patch_test.js | 290 +++++++++++++ .../test/fp_set.test-d.ts | 25 ++ .../test/fp_setWith.test-d.ts | 40 ++ .../test/index.test-d.ts | 37 ++ .../test/patch_test.js | 174 ++++++++ .../test/set.test-d.ts | 14 + .../test/setWith.test-d.ts | 32 ++ .../elastic-safer-lodash-set/tsconfig.json | 9 + .../tools/check_collector__integrity.test.ts | 12 +- .../src/tools/check_collector_integrity.ts | 6 +- .../src/tools/tasks/generate_schemas_task.ts | 1 - .../kbn-telemetry-tools/src/tools/utils.ts | 29 +- src/cli/command.js | 3 +- src/cli/serve/read_keystore.js | 2 +- src/cli/serve/serve.js | 3 +- .../saved_objects/simple_saved_object.ts | 3 +- .../config/deprecation/deprecation_factory.ts | 3 +- .../server/config/object_to_config_adapter.ts | 3 +- src/core/server/config/read_config.ts | 3 +- .../legacy/config/get_unused_config_keys.ts | 3 +- .../migrations/core/document_migrator.test.ts | 9 +- .../migrations/core/document_migrator.ts | 3 +- .../migrations/core/migrate_raw_docs.test.ts | 5 +- .../saved_objects/service/lib/filter_utils.ts | 3 +- src/dev/file.ts | 4 +- src/dev/precommit_hook/casing_check_config.js | 3 + src/fixtures/mock_ui_state.js | 5 +- src/legacy/deprecation/deprecations/rename.js | 3 +- src/legacy/server/config/config.js | 5 +- .../state_management/state_monitor_factory.ts | 3 +- .../build_tabular_inspector_data.ts | 2 +- .../search/search_source/search_source.ts | 14 +- .../context/api/context.predecessors.test.js | 14 +- .../context/api/context.successors.test.js | 14 +- .../lexer_rules/x_json_highlight_rules.ts | 4 +- .../static/forms/hook_form_lib/lib/utils.ts | 2 +- .../public/angular/angular_config.tsx | 3 +- .../object_view/components/form.tsx | 3 +- .../components/lib/convert_series_to_vars.js | 5 +- .../lib/vis_data/helpers/bucket_transform.js | 3 +- .../public/vislib/lib/axis/axis_config.js | 3 +- .../public/vislib/lib/chart_grid.js | 3 +- .../public/vislib/lib/vis_config.js | 3 +- .../public/legacy/vis_update_state.js | 5 +- .../public/persisted_state/persisted_state.ts | 13 +- tasks/config/run.js | 6 + tasks/jenkins.js | 1 + .../apis/saved_objects/migrations.js | 23 +- .../lib/check_license/check_license.test.js | 2 +- .../__tests__/is_es_error_factory.js | 2 +- .../legacy/server/lib/parse_kibana_state.js | 3 +- x-pack/package.json | 1 + .../aggregate-latency-metrics/index.ts | 3 +- .../public/lib/configuration_blocks.ts | 3 +- .../functions/common/plot/index.ts | 3 +- .../public/components/asset_manager/index.ts | 3 +- .../public/expression_types/arg_types/font.js | 3 +- .../event_log/scripts/create_schemas.js | 5 +- ...ith_metrics_explorer_options_url_state.tsx | 3 +- .../components/helpers/create_tsvb_link.ts | 2 +- .../routes/metadata/lib/get_node_info.ts | 3 +- .../metrics_explorer/lib/get_groupings.ts | 3 +- .../server/utils/create_afterkey_handler.ts | 2 +- .../public/components/table/storage.js | 3 +- .../public/lib/calculate_shard_stats.js | 3 +- .../server/lib/__tests__/create_query.js | 2 +- .../cluster/__tests__/get_clusters_state.js | 2 +- .../lib/cluster/flag_supported_clusters.js | 3 +- .../lib/cluster/get_clusters_from_request.js | 3 +- .../elasticsearch/__tests__/get_ml_jobs.js | 2 +- .../nodes/__tests__/calculate_node_type.js | 2 +- .../telemetry_collection/create_query.test.ts | 2 +- .../telemetry_collection/get_all_stats.ts | 3 +- .../server/browsers/network_policy.ts | 4 +- .../export_types/common/validate_urls.ts | 4 +- .../generate_csv/check_cells_for_formulas.ts | 8 +- .../server/routes/lib/get_document_payload.ts | 6 +- .../public/cases/containers/utils.ts | 3 +- .../components/event_details/json_view.tsx | 2 +- .../common/components/search_bar/index.tsx | 3 +- .../common/components/toasters/index.test.tsx | 3 +- .../public/common/containers/source/index.tsx | 3 +- .../components/flyout/index.test.tsx | 2 +- .../components/open_timeline/helpers.ts | 3 +- .../timelines/store/timeline/reducer.test.ts | 3 +- .../server/lib/hosts/elasticsearch_adapter.ts | 3 +- .../lib/timeline/routes/utils/common.ts | 2 +- .../server/test/helpers/router_mock.ts | 2 +- .../public/application/components/tabs.tsx | 3 +- .../checkup/deprecations/reindex/button.tsx | 2 +- .../__tests__/get_monitor_charts.test.ts | 2 +- .../lib/requests/__tests__/get_pings.test.ts | 2 +- .../requests/search/find_potential_matches.ts | 3 +- .../serialization_helpers/build_input.js | 2 +- .../lib/serialization/serialize_json_watch.js | 2 +- .../watcher/common/models/action/action.js | 2 +- .../application/models/action/action.js | 3 +- .../public/application/models/watch/watch.js | 3 +- .../__tests__/fetch_all_from_scroll.js | 2 +- .../watcher/server/models/watch/watch.js | 2 +- x-pack/test/functional/apps/maps/joins.js | 6 +- yarn.lock | 406 +++++++++++++++++- 137 files changed, 2475 insertions(+), 196 deletions(-) create mode 100644 packages/elastic-safer-lodash-set/.gitignore create mode 100644 packages/elastic-safer-lodash-set/.npmignore create mode 100644 packages/elastic-safer-lodash-set/LICENSE create mode 100644 packages/elastic-safer-lodash-set/README.md create mode 100644 packages/elastic-safer-lodash-set/fp/assoc.d.ts create mode 100644 packages/elastic-safer-lodash-set/fp/assoc.js create mode 100644 packages/elastic-safer-lodash-set/fp/assocPath.d.ts create mode 100644 packages/elastic-safer-lodash-set/fp/assocPath.js create mode 100644 packages/elastic-safer-lodash-set/fp/index.d.ts create mode 100644 packages/elastic-safer-lodash-set/fp/index.js create mode 100644 packages/elastic-safer-lodash-set/fp/set.d.ts create mode 100644 packages/elastic-safer-lodash-set/fp/set.js create mode 100644 packages/elastic-safer-lodash-set/fp/setWith.d.ts create mode 100644 packages/elastic-safer-lodash-set/fp/setWith.js create mode 100644 packages/elastic-safer-lodash-set/index.d.ts create mode 100644 packages/elastic-safer-lodash-set/index.js create mode 100644 packages/elastic-safer-lodash-set/lodash/_baseSet.js create mode 100644 packages/elastic-safer-lodash-set/lodash/set.js create mode 100644 packages/elastic-safer-lodash-set/lodash/setWith.js create mode 100644 packages/elastic-safer-lodash-set/package.json create mode 100755 packages/elastic-safer-lodash-set/scripts/_get_lodash.sh create mode 100644 packages/elastic-safer-lodash-set/scripts/license-header.txt create mode 100644 packages/elastic-safer-lodash-set/scripts/patches/_baseSet.js.patch create mode 100755 packages/elastic-safer-lodash-set/scripts/save_state.sh create mode 100755 packages/elastic-safer-lodash-set/scripts/tsd.sh create mode 100755 packages/elastic-safer-lodash-set/scripts/update.sh create mode 100644 packages/elastic-safer-lodash-set/set.d.ts create mode 100644 packages/elastic-safer-lodash-set/set.js create mode 100644 packages/elastic-safer-lodash-set/setWith.d.ts create mode 100644 packages/elastic-safer-lodash-set/setWith.js create mode 100644 packages/elastic-safer-lodash-set/test/fp.test-d.ts create mode 100644 packages/elastic-safer-lodash-set/test/fp_assoc.test-d.ts create mode 100644 packages/elastic-safer-lodash-set/test/fp_assocPath.test-d.ts create mode 100644 packages/elastic-safer-lodash-set/test/fp_patch_test.js create mode 100644 packages/elastic-safer-lodash-set/test/fp_set.test-d.ts create mode 100644 packages/elastic-safer-lodash-set/test/fp_setWith.test-d.ts create mode 100644 packages/elastic-safer-lodash-set/test/index.test-d.ts create mode 100644 packages/elastic-safer-lodash-set/test/patch_test.js create mode 100644 packages/elastic-safer-lodash-set/test/set.test-d.ts create mode 100644 packages/elastic-safer-lodash-set/test/setWith.test-d.ts create mode 100644 packages/elastic-safer-lodash-set/tsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js index 4425ad3a12659d..a9ffe2850aa726 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -49,6 +49,31 @@ const ELASTIC_LICENSE_HEADER = ` */ `; +const SAFER_LODASH_SET_HEADER = ` +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See \`packages/elastic-safer-lodash-set/LICENSE\` for more information. + */ +`; + +const SAFER_LODASH_SET_LODASH_HEADER = ` +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See \`packages/elastic-safer-lodash-set/LICENSE\` for more information. + */ +`; + +const SAFER_LODASH_SET_DEFINITELYTYPED_HEADER = ` +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See \`packages/elastic-safer-lodash-set/LICENSE\` for more information. + */ +`; + const allMochaRulesOff = {}; Object.keys(require('eslint-plugin-mocha').rules).forEach((k) => { allMochaRulesOff['mocha/' + k] = 'off'; @@ -143,7 +168,12 @@ module.exports = { '@kbn/eslint/disallow-license-headers': [ 'error', { - licenses: [ELASTIC_LICENSE_HEADER], + licenses: [ + ELASTIC_LICENSE_HEADER, + SAFER_LODASH_SET_HEADER, + SAFER_LODASH_SET_LODASH_HEADER, + SAFER_LODASH_SET_DEFINITELYTYPED_HEADER, + ], }, ], }, @@ -174,7 +204,82 @@ module.exports = { '@kbn/eslint/disallow-license-headers': [ 'error', { - licenses: [APACHE_2_0_LICENSE_HEADER], + licenses: [ + APACHE_2_0_LICENSE_HEADER, + SAFER_LODASH_SET_HEADER, + SAFER_LODASH_SET_LODASH_HEADER, + SAFER_LODASH_SET_DEFINITELYTYPED_HEADER, + ], + }, + ], + }, + }, + + /** + * safer-lodash-set package requires special license headers + */ + { + files: ['packages/elastic-safer-lodash-set/**/*.{js,mjs,ts,tsx}'], + rules: { + '@kbn/eslint/require-license-header': [ + 'error', + { + license: SAFER_LODASH_SET_LODASH_HEADER, + }, + ], + '@kbn/eslint/disallow-license-headers': [ + 'error', + { + licenses: [ + ELASTIC_LICENSE_HEADER, + APACHE_2_0_LICENSE_HEADER, + SAFER_LODASH_SET_HEADER, + SAFER_LODASH_SET_DEFINITELYTYPED_HEADER, + ], + }, + ], + }, + }, + { + files: ['packages/elastic-safer-lodash-set/test/*.{js,mjs,ts,tsx}'], + rules: { + '@kbn/eslint/require-license-header': [ + 'error', + { + license: SAFER_LODASH_SET_HEADER, + }, + ], + '@kbn/eslint/disallow-license-headers': [ + 'error', + { + licenses: [ + ELASTIC_LICENSE_HEADER, + APACHE_2_0_LICENSE_HEADER, + SAFER_LODASH_SET_LODASH_HEADER, + SAFER_LODASH_SET_DEFINITELYTYPED_HEADER, + ], + }, + ], + }, + }, + { + files: ['packages/elastic-safer-lodash-set/**/*.d.ts'], + rules: { + '@kbn/eslint/require-license-header': [ + 'error', + { + license: SAFER_LODASH_SET_DEFINITELYTYPED_HEADER, + }, + ], + '@kbn/eslint/disallow-license-headers': [ + 'error', + { + licenses: [ + ELASTIC_LICENSE_HEADER, + APACHE_2_0_LICENSE_HEADER, + SAFER_LODASH_SET_HEADER, + SAFER_LODASH_SET_LODASH_HEADER, + ], }, ], }, @@ -541,9 +646,129 @@ module.exports = { * Harden specific rules */ { - files: ['test/harden/*.js'], + files: ['test/harden/*.js', 'packages/elastic-safer-lodash-set/test/*.js'], rules: allMochaRulesOff, }, + { + files: ['**/*.{js,mjs,ts,tsx}'], + rules: { + 'no-restricted-imports': [ + 2, + { + paths: [ + { + name: 'lodash', + importNames: ['set', 'setWith'], + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash.set', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash.setwith', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/set', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/setWith', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/fp', + importNames: ['set', 'setWith', 'assoc', 'assocPath'], + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/fp/set', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/fp/setWith', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/fp/assoc', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/fp/assocPath', + message: 'Please use @elastic/safer-lodash-set instead', + }, + ], + }, + ], + 'no-restricted-modules': [ + 2, + { + paths: [ + { + name: 'lodash.set', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash.setwith', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/set', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + name: 'lodash/setWith', + message: 'Please use @elastic/safer-lodash-set instead', + }, + ], + }, + ], + 'no-restricted-properties': [ + 2, + { + object: 'lodash', + property: 'set', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + object: '_', + property: 'set', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + object: 'lodash', + property: 'setWith', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + object: '_', + property: 'setWith', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + object: 'lodash', + property: 'assoc', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + object: '_', + property: 'assoc', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + object: 'lodash', + property: 'assocPath', + message: 'Please use @elastic/safer-lodash-set instead', + }, + { + object: '_', + property: 'assocPath', + message: 'Please use @elastic/safer-lodash-set instead', + }, + ], + }, + }, /** * APM overrides diff --git a/package.json b/package.json index 55a099b4e5c0c2..190eb6d7d94b43 100644 --- a/package.json +++ b/package.json @@ -132,6 +132,7 @@ "@elastic/good": "8.1.1-kibana2", "@elastic/numeral": "^2.5.0", "@elastic/request-crypto": "1.1.4", + "@elastic/safer-lodash-set": "0.0.0", "@elastic/ui-ace": "0.2.3", "@hapi/good-squeeze": "5.2.1", "@hapi/wreck": "^15.0.2", diff --git a/packages/elastic-safer-lodash-set/.gitignore b/packages/elastic-safer-lodash-set/.gitignore new file mode 100644 index 00000000000000..b152df746bf260 --- /dev/null +++ b/packages/elastic-safer-lodash-set/.gitignore @@ -0,0 +1,2 @@ +.tmp +node_modules diff --git a/packages/elastic-safer-lodash-set/.npmignore b/packages/elastic-safer-lodash-set/.npmignore new file mode 100644 index 00000000000000..c2c910c637c015 --- /dev/null +++ b/packages/elastic-safer-lodash-set/.npmignore @@ -0,0 +1,3 @@ +tsconfig.json +scripts +test diff --git a/packages/elastic-safer-lodash-set/LICENSE b/packages/elastic-safer-lodash-set/LICENSE new file mode 100644 index 00000000000000..049225c0b6647c --- /dev/null +++ b/packages/elastic-safer-lodash-set/LICENSE @@ -0,0 +1,34 @@ +The MIT License (MIT) + +Copyright (c) Elasticsearch BV +Copyright (c) Brian Zengel , Ilya Mochalov +Copyright (c) JS Foundation and other contributors + +Lodash is based on Underscore.js, copyright Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at the following locations: + - https://github.com/lodash/lodash + - https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lodash + - https://github.com/elastic/kibana/tree/master/packages/elastic-safer-lodash-set + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/elastic-safer-lodash-set/README.md b/packages/elastic-safer-lodash-set/README.md new file mode 100644 index 00000000000000..aae17b35ac1306 --- /dev/null +++ b/packages/elastic-safer-lodash-set/README.md @@ -0,0 +1,113 @@ +# @elastic/safer-lodash-set + +This module adds protection against prototype pollution to the [`set`] +and [`setWith`] functions from [Lodash] and are API compatible with +Lodash v4.x. + +## Example Usage + +```js +const { set } = require('@elastic/safer-loadsh-set'); + +const object = { a: [{ b: { c: 3 } }] }; + +set(object, 'a[0].b.c', 4); +console.log(object.a[0].b.c); // => 4 + +set(object, ['x', '0', 'y', 'z'], 5); +console.log(object.x[0].y.z); // => 5 +``` + +## API + +The main module exposes two functions, `set` and `setWith`: + +```js +const { set, setWith } = require('@elastic/safer-lodash-set'); +``` + +Besides the main module, it's also possible to require each function +individually: + +```js +const set = require('@elastic/safer-lodash-set/set'); +const setWith = require('@elastic/safer-lodash-set/setWith'); +``` + +The APIs of these functions are identical to the equivalent Lodash +[`set`] and [`setWith`] functions. Please refer to the Lodash +documentation for the respective functions for details. + +### Functional Programming support (fp) + +This module also supports the `lodash/fp` api and hence exposes the +following fp compatible functions: + +```js +const { set, setWith } = require('@elastic/safer-lodash-set/fp'); +``` + +Besides the main fp module, it's also possible to require each function +individually: + +```js +const set = require('@elastic/safer-lodash-set/fp/set'); +const setWith = require('@elastic/safer-lodash-set/fp/setWith'); +``` + +## Limitations + +The safety improvements in this module is achieved by adding the +following limitations to the algorithm used to walk the `path` given as +the 2nd argument to the `set` and `setWith` functions: + +### Only own properties are followed when walking the `path` + +```js +const parent = { foo: 1 }; +const child = { bar: 2 }; + +Object.setPrototypeOf(child, parent); + +// Now `child` can access `foo` through prototype inheritance +console.log(child.foo); // 1 + +set(child, 'foo', 3); + +// A different `foo` property has now been added directly to the `child` +// object and the `parent` object has not been modified: +console.log(child.foo); // 3 +console.log(parent.foo); // 1 +console.log(Object.prototype.hasOwnProperty.call(child, 'foo')); // true +``` + +### The `path` must not access function prototypes + +```js +const object = { + fn1: function () {}, + fn2: () => {}, +}; + +// Attempting to access any function prototype will result in an +// exception being thrown: +assert.throws(() => { + // Throws: Illegal access of function prototype + set(object, 'fn1.prototype.toString', 'bang!'); +}); + +// This also goes for arrow functions even though they don't have a +// prototype property. This is just to keep things consistent: +assert.throws(() => { + // Throws: Illegal access of function prototype + set(object, 'fn2.prototype.toString', 'bang!'); +}); +``` + +## License + +[MIT](LICENSE) + +[`set`]: https://lodash.com/docs/4.17.15#set +[`setwith`]: https://lodash.com/docs/4.17.15#setWith +[lodash]: https://lodash.com/ diff --git a/packages/elastic-safer-lodash-set/fp/assoc.d.ts b/packages/elastic-safer-lodash-set/fp/assoc.d.ts new file mode 100644 index 00000000000000..57fe84d0b07f2a --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/assoc.d.ts @@ -0,0 +1,9 @@ +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { assoc } from './index'; +export = assoc; diff --git a/packages/elastic-safer-lodash-set/fp/assoc.js b/packages/elastic-safer-lodash-set/fp/assoc.js new file mode 100644 index 00000000000000..851e11690ea35d --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/assoc.js @@ -0,0 +1,8 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +module.exports = require('./set'); diff --git a/packages/elastic-safer-lodash-set/fp/assocPath.d.ts b/packages/elastic-safer-lodash-set/fp/assocPath.d.ts new file mode 100644 index 00000000000000..76df38e98ff284 --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/assocPath.d.ts @@ -0,0 +1,9 @@ +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { assocPath } from './index'; +export = assocPath; diff --git a/packages/elastic-safer-lodash-set/fp/assocPath.js b/packages/elastic-safer-lodash-set/fp/assocPath.js new file mode 100644 index 00000000000000..851e11690ea35d --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/assocPath.js @@ -0,0 +1,8 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +module.exports = require('./set'); diff --git a/packages/elastic-safer-lodash-set/fp/index.d.ts b/packages/elastic-safer-lodash-set/fp/index.d.ts new file mode 100644 index 00000000000000..fcd7ff01e3cc88 --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/index.d.ts @@ -0,0 +1,225 @@ +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import lodash = require('lodash'); + +export = SaferLodashSet; +export as namespace SaferLodashSet; + +declare const SaferLodashSet: SaferLodashSet.SaferLoDashStaticFp; +declare namespace SaferLodashSet { + interface LodashSet { + (path: lodash.PropertyPath): LodashSet1x1; + (path: lodash.__, value: any): LodashSet1x2; + (path: lodash.PropertyPath, value: any): LodashSet1x3; + (path: lodash.__, value: lodash.__, object: T): LodashSet1x4; + (path: lodash.PropertyPath, value: lodash.__, object: T): LodashSet1x5; + (path: lodash.__, value: any, object: T): LodashSet1x6; + (path: lodash.PropertyPath, value: any, object: T): T; + (path: lodash.__, value: lodash.__, object: object): LodashSet2x4; + (path: lodash.PropertyPath, value: lodash.__, object: object): LodashSet2x5; + (path: lodash.__, value: any, object: object): LodashSet2x6; + (path: lodash.PropertyPath, value: any, object: object): TResult; + } + interface LodashSet1x1 { + (value: any): LodashSet1x3; + (value: lodash.__, object: T): LodashSet1x5; + (value: any, object: T): T; + (value: lodash.__, object: object): LodashSet2x5; + (value: any, object: object): TResult; + } + interface LodashSet1x2 { + (path: lodash.PropertyPath): LodashSet1x3; + (path: lodash.__, object: T): LodashSet1x6; + (path: lodash.PropertyPath, object: T): T; + (path: lodash.__, object: object): LodashSet2x6; + (path: lodash.PropertyPath, object: object): TResult; + } + interface LodashSet1x3 { + (object: T): T; + (object: object): TResult; + } + interface LodashSet1x4 { + (path: lodash.PropertyPath): LodashSet1x5; + (path: lodash.__, value: any): LodashSet1x6; + (path: lodash.PropertyPath, value: any): T; + } + type LodashSet1x5 = (value: any) => T; + type LodashSet1x6 = (path: lodash.PropertyPath) => T; + interface LodashSet2x4 { + (path: lodash.PropertyPath): LodashSet2x5; + (path: lodash.__, value: any): LodashSet2x6; + (path: lodash.PropertyPath, value: any): TResult; + } + type LodashSet2x5 = (value: any) => TResult; + type LodashSet2x6 = (path: lodash.PropertyPath) => TResult; + + interface LodashSetWith { + (customizer: lodash.SetWithCustomizer): LodashSetWith1x1; + (customizer: lodash.__, path: lodash.PropertyPath): LodashSetWith1x2; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.PropertyPath + ): LodashSetWith1x3; + (customizer: lodash.__, path: lodash.__, value: any): LodashSetWith1x4; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.__, + value: any + ): LodashSetWith1x5; + (customizer: lodash.__, path: lodash.PropertyPath, value: any): LodashSetWith1x6; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.PropertyPath, + value: any + ): LodashSetWith1x7; + ( + customizer: lodash.__, + path: lodash.__, + value: lodash.__, + object: T + ): LodashSetWith1x8; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.__, + value: lodash.__, + object: T + ): LodashSetWith1x9; + ( + customizer: lodash.__, + path: lodash.PropertyPath, + value: lodash.__, + object: T + ): LodashSetWith1x10; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.PropertyPath, + value: lodash.__, + object: T + ): LodashSetWith1x11; + ( + customizer: lodash.__, + path: lodash.__, + value: any, + object: T + ): LodashSetWith1x12; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.__, + value: any, + object: T + ): LodashSetWith1x13; + ( + customizer: lodash.__, + path: lodash.PropertyPath, + value: any, + object: T + ): LodashSetWith1x14; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.PropertyPath, + value: any, + object: T + ): T; + } + interface LodashSetWith1x1 { + (path: lodash.PropertyPath): LodashSetWith1x3; + (path: lodash.__, value: any): LodashSetWith1x5; + (path: lodash.PropertyPath, value: any): LodashSetWith1x7; + (path: lodash.__, value: lodash.__, object: T): LodashSetWith1x9; + (path: lodash.PropertyPath, value: lodash.__, object: T): LodashSetWith1x11; + (path: lodash.__, value: any, object: T): LodashSetWith1x13; + (path: lodash.PropertyPath, value: any, object: T): T; + } + interface LodashSetWith1x2 { + (customizer: lodash.SetWithCustomizer): LodashSetWith1x3; + (customizer: lodash.__, value: any): LodashSetWith1x6; + (customizer: lodash.SetWithCustomizer, value: any): LodashSetWith1x7; + (customizer: lodash.__, value: lodash.__, object: T): LodashSetWith1x10; + ( + customizer: lodash.SetWithCustomizer, + value: lodash.__, + object: T + ): LodashSetWith1x11; + (customizer: lodash.__, value: any, object: T): LodashSetWith1x14; + (customizer: lodash.SetWithCustomizer, value: any, object: T): T; + } + interface LodashSetWith1x3 { + (value: any): LodashSetWith1x7; + (value: lodash.__, object: T): LodashSetWith1x11; + (value: any, object: T): T; + } + interface LodashSetWith1x4 { + (customizer: lodash.SetWithCustomizer): LodashSetWith1x5; + (customizer: lodash.__, path: lodash.PropertyPath): LodashSetWith1x6; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.PropertyPath + ): LodashSetWith1x7; + (customizer: lodash.__, path: lodash.__, object: T): LodashSetWith1x12; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.__, + object: T + ): LodashSetWith1x13; + ( + customizer: lodash.__, + path: lodash.PropertyPath, + object: T + ): LodashSetWith1x14; + ( + customizer: lodash.SetWithCustomizer, + path: lodash.PropertyPath, + object: T + ): T; + } + interface LodashSetWith1x5 { + (path: lodash.PropertyPath): LodashSetWith1x7; + (path: lodash.__, object: T): LodashSetWith1x13; + (path: lodash.PropertyPath, object: T): T; + } + interface LodashSetWith1x6 { + (customizer: lodash.SetWithCustomizer): LodashSetWith1x7; + (customizer: lodash.__, object: T): LodashSetWith1x14; + (customizer: lodash.SetWithCustomizer, object: T): T; + } + type LodashSetWith1x7 = (object: T) => T; + interface LodashSetWith1x8 { + (customizer: lodash.SetWithCustomizer): LodashSetWith1x9; + (customizer: lodash.__, path: lodash.PropertyPath): LodashSetWith1x10; + (customizer: lodash.SetWithCustomizer, path: lodash.PropertyPath): LodashSetWith1x11; + (customizer: lodash.__, path: lodash.__, value: any): LodashSetWith1x12; + (customizer: lodash.SetWithCustomizer, path: lodash.__, value: any): LodashSetWith1x13; + (customizer: lodash.__, path: lodash.PropertyPath, value: any): LodashSetWith1x14; + (customizer: lodash.SetWithCustomizer, path: lodash.PropertyPath, value: any): T; + } + interface LodashSetWith1x9 { + (path: lodash.PropertyPath): LodashSetWith1x11; + (path: lodash.__, value: any): LodashSetWith1x13; + (path: lodash.PropertyPath, value: any): T; + } + interface LodashSetWith1x10 { + (customizer: lodash.SetWithCustomizer): LodashSetWith1x11; + (customizer: lodash.__, value: any): LodashSetWith1x14; + (customizer: lodash.SetWithCustomizer, value: any): T; + } + type LodashSetWith1x11 = (value: any) => T; + interface LodashSetWith1x12 { + (customizer: lodash.SetWithCustomizer): LodashSetWith1x13; + (customizer: lodash.__, path: lodash.PropertyPath): LodashSetWith1x14; + (customizer: lodash.SetWithCustomizer, path: lodash.PropertyPath): T; + } + type LodashSetWith1x13 = (path: lodash.PropertyPath) => T; + type LodashSetWith1x14 = (customizer: lodash.SetWithCustomizer) => T; + + interface SaferLoDashStaticFp { + assoc: LodashSet; + assocPath: LodashSet; + set: LodashSet; + setWith: LodashSetWith; + } +} diff --git a/packages/elastic-safer-lodash-set/fp/index.js b/packages/elastic-safer-lodash-set/fp/index.js new file mode 100644 index 00000000000000..7d9cdb099dfd76 --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/index.js @@ -0,0 +1,9 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +exports.set = exports.assoc = exports.assocPath = require('./set'); +exports.setWith = require('./setWith'); diff --git a/packages/elastic-safer-lodash-set/fp/set.d.ts b/packages/elastic-safer-lodash-set/fp/set.d.ts new file mode 100644 index 00000000000000..16bc98658bdcd5 --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/set.d.ts @@ -0,0 +1,9 @@ +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { set } from './index'; +export = set; diff --git a/packages/elastic-safer-lodash-set/fp/set.js b/packages/elastic-safer-lodash-set/fp/set.js new file mode 100644 index 00000000000000..0fb48694d736df --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/set.js @@ -0,0 +1,13 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +/*eslint no-var:0 */ +var convert = require('lodash/fp/convert'); +var func = convert('set', require('../set')); + +func.placeholder = require('lodash/fp/placeholder'); +module.exports = func; diff --git a/packages/elastic-safer-lodash-set/fp/setWith.d.ts b/packages/elastic-safer-lodash-set/fp/setWith.d.ts new file mode 100644 index 00000000000000..556e702f59f0f0 --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/setWith.d.ts @@ -0,0 +1,9 @@ +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { setWith } from './index'; +export = setWith; diff --git a/packages/elastic-safer-lodash-set/fp/setWith.js b/packages/elastic-safer-lodash-set/fp/setWith.js new file mode 100644 index 00000000000000..e477d4b4bc7bab --- /dev/null +++ b/packages/elastic-safer-lodash-set/fp/setWith.js @@ -0,0 +1,13 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +/*eslint no-var:0 */ +var convert = require('lodash/fp/convert'); +var func = convert('setWith', require('../setWith')); + +func.placeholder = require('lodash/fp/placeholder'); +module.exports = func; diff --git a/packages/elastic-safer-lodash-set/index.d.ts b/packages/elastic-safer-lodash-set/index.d.ts new file mode 100644 index 00000000000000..aaff01f11a7af9 --- /dev/null +++ b/packages/elastic-safer-lodash-set/index.d.ts @@ -0,0 +1,64 @@ +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +export = SaferLodashSet; +export as namespace SaferLodashSet; + +type Many = T | readonly T[]; +type PropertyName = string | number | symbol; +type PropertyPath = Many; +type SetWithCustomizer = (nsValue: any, key: string, nsObject: T) => any; + +declare const SaferLodashSet: SaferLodashSet.SaferLoDashStatic; +declare namespace SaferLodashSet { + interface SaferLoDashStatic { + /** + * Sets the value at path of object. If a portion of path doesn’t exist it’s + * created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use SaferLodashSet.setWith + * to customize path creation. + * + * @param object The object to modify. + * @param path The path of the property to set. + * @param value The value to set. + * @return Returns object. + */ + set(object: T, path: PropertyPath, value: any): T; + /** + * @see SaferLodashSet.set + */ + set(object: object, path: PropertyPath, value: any): TResult; + + /** + * This method is like SaferLodashSet.set except that it accepts customizer + * which is invoked to produce the objects of path. If customizer returns + * undefined path creation is handled by the method instead. The customizer + * is invoked with three arguments: (nsValue, key, nsObject). + * + * @param object The object to modify. + * @param path The path of the property to set. + * @param value The value to set. + * @param customizer The function to customize assigned values. + * @return Returns object. + */ + setWith( + object: T, + path: PropertyPath, + value: any, + customizer?: SetWithCustomizer + ): T; + /** + * @see SaferLodashSet.setWith + */ + setWith( + object: T, + path: PropertyPath, + value: any, + customizer?: SetWithCustomizer + ): TResult; + } +} diff --git a/packages/elastic-safer-lodash-set/index.js b/packages/elastic-safer-lodash-set/index.js new file mode 100644 index 00000000000000..d9edb25476c126 --- /dev/null +++ b/packages/elastic-safer-lodash-set/index.js @@ -0,0 +1,9 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +exports.set = require('./lodash/set'); +exports.setWith = require('./lodash/setWith'); diff --git a/packages/elastic-safer-lodash-set/lodash/_baseSet.js b/packages/elastic-safer-lodash-set/lodash/_baseSet.js new file mode 100644 index 00000000000000..9cbf19808edd70 --- /dev/null +++ b/packages/elastic-safer-lodash-set/lodash/_baseSet.js @@ -0,0 +1,61 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +/* eslint-disable */ + +var assignValue = require('lodash/_assignValue'), + castPath = require('lodash/_castPath'), + isFunction = require('lodash/isFunction'), + isIndex = require('lodash/_isIndex'), + isObject = require('lodash/isObject'), + toKey = require('lodash/_toKey'); + +/** + * The base implementation of `_.set`. + * + * @private + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize path creation. + * @returns {Object} Returns `object`. + */ +function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } + path = castPath(path, object); + + var index = -1, + length = path.length, + lastIndex = length - 1, + nested = object; + + while (nested != null && ++index < length) { + var key = toKey(path[index]), + newValue = value; + + if (key == 'prototype' && isFunction(nested)) { + throw new Error('Illegal access of function prototype') + } + + if (index != lastIndex) { + var objValue = hasOwnProperty.call(nested, key) ? nested[key] : undefined + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); + } + } + assignValue(nested, key, newValue); + nested = nested[key]; + } + return object; +} + +module.exports = baseSet; diff --git a/packages/elastic-safer-lodash-set/lodash/set.js b/packages/elastic-safer-lodash-set/lodash/set.js new file mode 100644 index 00000000000000..740f7c926ee408 --- /dev/null +++ b/packages/elastic-safer-lodash-set/lodash/set.js @@ -0,0 +1,44 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +/* eslint-disable */ + +var baseSet = require('./_baseSet'); + +/** + * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, + * it's created. Arrays are created for missing index properties while objects + * are created for all other missing properties. Use `_.setWith` to customize + * `path` creation. + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @returns {Object} Returns `object`. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.set(object, 'a[0].b.c', 4); + * console.log(object.a[0].b.c); + * // => 4 + * + * _.set(object, ['x', '0', 'y', 'z'], 5); + * console.log(object.x[0].y.z); + * // => 5 + */ +function set(object, path, value) { + return object == null ? object : baseSet(object, path, value); +} + +module.exports = set; diff --git a/packages/elastic-safer-lodash-set/lodash/setWith.js b/packages/elastic-safer-lodash-set/lodash/setWith.js new file mode 100644 index 00000000000000..0ac4f4c9cf39f0 --- /dev/null +++ b/packages/elastic-safer-lodash-set/lodash/setWith.js @@ -0,0 +1,41 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +/* eslint-disable */ + +var baseSet = require('./_baseSet'); + +/** + * This method is like `_.set` except that it accepts `customizer` which is + * invoked to produce the objects of `path`. If `customizer` returns `undefined` + * path creation is handled by the method instead. The `customizer` is invoked + * with three arguments: (nsValue, key, nsObject). + * + * **Note:** This method mutates `object`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to modify. + * @param {Array|string} path The path of the property to set. + * @param {*} value The value to set. + * @param {Function} [customizer] The function to customize assigned values. + * @returns {Object} Returns `object`. + * @example + * + * var object = {}; + * + * _.setWith(object, '[0][1]', 'a', Object); + * // => { '0': { '1': 'a' } } + */ +function setWith(object, path, value, customizer) { + customizer = typeof customizer == 'function' ? customizer : undefined; + return object == null ? object : baseSet(object, path, value, customizer); +} + +module.exports = setWith; diff --git a/packages/elastic-safer-lodash-set/package.json b/packages/elastic-safer-lodash-set/package.json new file mode 100644 index 00000000000000..f0f425661f605a --- /dev/null +++ b/packages/elastic-safer-lodash-set/package.json @@ -0,0 +1,49 @@ +{ + "name": "@elastic/safer-lodash-set", + "version": "0.0.0", + "description": "A safer version of the lodash set and setWith functions", + "main": "index.js", + "types": "index.d.ts", + "dependencies": {}, + "devDependencies": { + "dependency-check": "^4.1.0", + "tape": "^5.0.1", + "tsd": "^0.13.1" + }, + "peerDependencies": { + "lodash": "4.x" + }, + "scripts": { + "lint": "dependency-check --no-dev package.json set.js setWith.js fp/*.js", + "test": "npm run lint && tape test/*.js && npm run test:types", + "test:types": "./scripts/tsd.sh", + "update": "./scripts/update.sh", + "save_state": "./scripts/save_state.sh" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/elastic/kibana.git" + }, + "keywords": [ + "lodash", + "security", + "set", + "setWith", + "prototype", + "pollution" + ], + "author": "Thomas Watson (https://twitter.com/wa7son)", + "license": "MIT", + "bugs": { + "url": "https://github.com/elastic/kibana/issues" + }, + "homepage": "https://github.com/elastic/kibana/tree/master/packages/safer-lodash-set#readme", + "standard": { + "ignore": [ + "/lodash/" + ] + }, + "tsd": { + "directory": "test" + } +} diff --git a/packages/elastic-safer-lodash-set/scripts/_get_lodash.sh b/packages/elastic-safer-lodash-set/scripts/_get_lodash.sh new file mode 100755 index 00000000000000..50d3edaf347170 --- /dev/null +++ b/packages/elastic-safer-lodash-set/scripts/_get_lodash.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Elasticsearch B.V licenses this file to you under the MIT License. +# See `packages/elastic-safer-lodash-set/LICENSE` for more information. + +clean_up () { + exit_code=$? + rm -fr .tmp + exit $exit_code +} +trap clean_up EXIT + +# Get a temporary copy of the latest v4 lodash +rm -fr .tmp +npm install --no-fund --ignore-scripts --no-audit --loglevel error --prefix ./.tmp lodash@4 > /dev/null diff --git a/packages/elastic-safer-lodash-set/scripts/license-header.txt b/packages/elastic-safer-lodash-set/scripts/license-header.txt new file mode 100644 index 00000000000000..4d0aedf74bb0ff --- /dev/null +++ b/packages/elastic-safer-lodash-set/scripts/license-header.txt @@ -0,0 +1,7 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + diff --git a/packages/elastic-safer-lodash-set/scripts/patches/_baseSet.js.patch b/packages/elastic-safer-lodash-set/scripts/patches/_baseSet.js.patch new file mode 100644 index 00000000000000..c7cf2041355d07 --- /dev/null +++ b/packages/elastic-safer-lodash-set/scripts/patches/_baseSet.js.patch @@ -0,0 +1,31 @@ +1,5c1,15 +< var assignValue = require('./_assignValue'), +< castPath = require('./_castPath'), +< isIndex = require('./_isIndex'), +< isObject = require('./isObject'), +< toKey = require('./_toKey'); +--- +> /* +> * This file is forked from the lodash project (https://lodash.com/), +> * and may include modifications made by Elasticsearch B.V. +> * Elasticsearch B.V. licenses this file to you under the MIT License. +> * See `packages/elastic-safer-lodash-set/LICENSE` for more information. +> */ +> +> /* eslint-disable */ +> +> var assignValue = require('lodash/_assignValue'), +> castPath = require('lodash/_castPath'), +> isFunction = require('lodash/isFunction'), +> isIndex = require('lodash/_isIndex'), +> isObject = require('lodash/isObject'), +> toKey = require('lodash/_toKey'); +31a42,45 +> if (key == 'prototype' && isFunction(nested)) { +> throw new Error('Illegal access of function prototype') +> } +> +33c47 +< var objValue = nested[key]; +--- +> var objValue = hasOwnProperty.call(nested, key) ? nested[key] : undefined diff --git a/packages/elastic-safer-lodash-set/scripts/save_state.sh b/packages/elastic-safer-lodash-set/scripts/save_state.sh new file mode 100755 index 00000000000000..ead99c3d1de48f --- /dev/null +++ b/packages/elastic-safer-lodash-set/scripts/save_state.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Elasticsearch B.V licenses this file to you under the MIT License. +# See `packages/elastic-safer-lodash-set/LICENSE` for more information. + +set -e + +source ./scripts/_get_lodash.sh + +modified_lodash_files=(_baseSet.js) + +# Create fresh patch files for each of the modified files +for file in "${modified_lodash_files[@]}" +do + diff ".tmp/node_modules/lodash/$file" "lodash/$file" > "scripts/patches/$file.patch" || true +done + +echo "State updated!" diff --git a/packages/elastic-safer-lodash-set/scripts/tsd.sh b/packages/elastic-safer-lodash-set/scripts/tsd.sh new file mode 100755 index 00000000000000..4572367df415df --- /dev/null +++ b/packages/elastic-safer-lodash-set/scripts/tsd.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Elasticsearch B.V licenses this file to you under the MIT License. +# See `packages/elastic-safer-lodash-set/LICENSE` for more information. + +# tsd will get confused if it finds a tsconfig.json file in the project +# directory and start to scan the entirety of Kibana. We don't want that. +mv tsconfig.json tsconfig.tmp + +clean_up () { + exit_code=$? + mv tsconfig.tmp tsconfig.json + exit $exit_code +} +trap clean_up EXIT + +./node_modules/.bin/tsd diff --git a/packages/elastic-safer-lodash-set/scripts/update.sh b/packages/elastic-safer-lodash-set/scripts/update.sh new file mode 100755 index 00000000000000..58fd89eb43e33c --- /dev/null +++ b/packages/elastic-safer-lodash-set/scripts/update.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Elasticsearch B.V licenses this file to you under the MIT License. +# See `packages/elastic-safer-lodash-set/LICENSE` for more information. + +set -e + +source ./scripts/_get_lodash.sh + +all_files=$(cd lodash && ls) +modified_lodash_files=(_baseSet.js) + +# Get fresh copies of all the files that was originally copied from lodash, +# expect the ones in the whitelist +for file in $all_files +do + if [[ ! "${modified_lodash_files[@]}" =~ "${file}" ]] + then + cat scripts/license-header.txt > "lodash/$file" + printf "/* eslint-disable */\n\n" >> "lodash/$file" + cat ".tmp/node_modules/lodash/$file" >> "lodash/$file" + fi +done + +# Check if there's changes to the patched files +for file in "${modified_lodash_files[@]}" +do + diff ".tmp/node_modules/lodash/$file" "lodash/$file" > ".tmp/$file.patch" || true + if [[ $(diff ".tmp/$file.patch" "scripts/patches/$file.patch") ]]; then + echo "WARNING: The modified file $file have changed in a newer version of lodash, but was not updated:" + echo "------------------------------------------------------------------------" + diff ".tmp/$file.patch" "scripts/patches/$file.patch" || true + echo "------------------------------------------------------------------------" + fi +done + +echo "Update complete!" diff --git a/packages/elastic-safer-lodash-set/set.d.ts b/packages/elastic-safer-lodash-set/set.d.ts new file mode 100644 index 00000000000000..16bc98658bdcd5 --- /dev/null +++ b/packages/elastic-safer-lodash-set/set.d.ts @@ -0,0 +1,9 @@ +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { set } from './index'; +export = set; diff --git a/packages/elastic-safer-lodash-set/set.js b/packages/elastic-safer-lodash-set/set.js new file mode 100644 index 00000000000000..69770629085496 --- /dev/null +++ b/packages/elastic-safer-lodash-set/set.js @@ -0,0 +1,8 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +module.exports = require('./lodash/set'); diff --git a/packages/elastic-safer-lodash-set/setWith.d.ts b/packages/elastic-safer-lodash-set/setWith.d.ts new file mode 100644 index 00000000000000..556e702f59f0f0 --- /dev/null +++ b/packages/elastic-safer-lodash-set/setWith.d.ts @@ -0,0 +1,9 @@ +/* + * This file is forked from the DefinitelyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { setWith } from './index'; +export = setWith; diff --git a/packages/elastic-safer-lodash-set/setWith.js b/packages/elastic-safer-lodash-set/setWith.js new file mode 100644 index 00000000000000..aafa8a4db4be64 --- /dev/null +++ b/packages/elastic-safer-lodash-set/setWith.js @@ -0,0 +1,8 @@ +/* + * This file is forked from the lodash project (https://lodash.com/), + * and may include modifications made by Elasticsearch B.V. + * Elasticsearch B.V. licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +module.exports = require('./lodash/setWith'); diff --git a/packages/elastic-safer-lodash-set/test/fp.test-d.ts b/packages/elastic-safer-lodash-set/test/fp.test-d.ts new file mode 100644 index 00000000000000..7a1d6601b5e263 --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/fp.test-d.ts @@ -0,0 +1,85 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { expectType } from 'tsd'; +import { set, setWith, assoc, assocPath } from '../fp'; + +const someObj: object = {}; +const anyValue: any = 'any value'; + +function customizer(value: any, key: string, obj: object) { + expectType(value); + expectType(key); + expectType(obj); +} + +expectType(set('a.b.c', anyValue, someObj)); +expectType(set('a.b.c')(anyValue, someObj)); +expectType(set('a.b.c')(anyValue)(someObj)); +expectType(set('a.b.c', anyValue)(someObj)); + +expectType(set(['a.b.c'], anyValue, someObj)); +expectType(set(['a.b.c'])(anyValue, someObj)); +expectType(set(['a.b.c'])(anyValue)(someObj)); +expectType(set(['a.b.c'], anyValue)(someObj)); + +expectType(set(['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(set(['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); +expectType(set(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(set(['a.b.c', 2, Symbol('hep')], anyValue)(someObj)); + +expectType(assoc('a.b.c', anyValue, someObj)); +expectType(assoc('a.b.c')(anyValue, someObj)); +expectType(assoc('a.b.c')(anyValue)(someObj)); +expectType(assoc('a.b.c', anyValue)(someObj)); + +expectType(assoc(['a.b.c'], anyValue, someObj)); +expectType(assoc(['a.b.c'])(anyValue, someObj)); +expectType(assoc(['a.b.c'])(anyValue)(someObj)); +expectType(assoc(['a.b.c'], anyValue)(someObj)); + +expectType(assoc(['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(assoc(['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); +expectType(assoc(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(assoc(['a.b.c', 2, Symbol('hep')], anyValue)(someObj)); + +expectType(assocPath('a.b.c', anyValue, someObj)); +expectType(assocPath('a.b.c')(anyValue, someObj)); +expectType(assocPath('a.b.c')(anyValue)(someObj)); +expectType(assocPath('a.b.c', anyValue)(someObj)); + +expectType(assocPath(['a.b.c'], anyValue, someObj)); +expectType(assocPath(['a.b.c'])(anyValue, someObj)); +expectType(assocPath(['a.b.c'])(anyValue)(someObj)); +expectType(assocPath(['a.b.c'], anyValue)(someObj)); + +expectType(assocPath(['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(assocPath(['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); +expectType(assocPath(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(assocPath(['a.b.c', 2, Symbol('hep')], anyValue)(someObj)); + +expectType(setWith(customizer, 'a.b.c', anyValue, someObj)); +expectType(setWith(customizer)('a.b.c', anyValue, someObj)); +expectType(setWith(customizer)('a.b.c')(anyValue, someObj)); +expectType(setWith(customizer)('a.b.c')(anyValue)(someObj)); +expectType(setWith(customizer, 'a.b.c')(anyValue)(someObj)); +expectType(setWith(customizer, 'a.b.c', anyValue)(someObj)); +expectType(setWith(customizer, 'a.b.c')(anyValue, someObj)); + +expectType(setWith(customizer, ['a.b.c'], anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c'])(anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c'], anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c'])(anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c'])(anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c'], anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c'])(anyValue, someObj)); + +expectType(setWith(customizer, ['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c', 2, Symbol('hep')], anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); diff --git a/packages/elastic-safer-lodash-set/test/fp_assoc.test-d.ts b/packages/elastic-safer-lodash-set/test/fp_assoc.test-d.ts new file mode 100644 index 00000000000000..8244458cd11803 --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/fp_assoc.test-d.ts @@ -0,0 +1,25 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { expectType } from 'tsd'; +import assoc from '../fp/assoc'; + +const someObj: object = {}; +const anyValue: any = 'any value'; + +expectType(assoc('a.b.c', anyValue, someObj)); +expectType(assoc('a.b.c')(anyValue, someObj)); +expectType(assoc('a.b.c')(anyValue)(someObj)); +expectType(assoc('a.b.c', anyValue)(someObj)); + +expectType(assoc(['a.b.c'], anyValue, someObj)); +expectType(assoc(['a.b.c'])(anyValue, someObj)); +expectType(assoc(['a.b.c'])(anyValue)(someObj)); +expectType(assoc(['a.b.c'], anyValue)(someObj)); + +expectType(assoc(['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(assoc(['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); +expectType(assoc(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(assoc(['a.b.c', 2, Symbol('hep')], anyValue)(someObj)); diff --git a/packages/elastic-safer-lodash-set/test/fp_assocPath.test-d.ts b/packages/elastic-safer-lodash-set/test/fp_assocPath.test-d.ts new file mode 100644 index 00000000000000..abbfa57eeb9635 --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/fp_assocPath.test-d.ts @@ -0,0 +1,25 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { expectType } from 'tsd'; +import assocPath from '../fp/assocPath'; + +const someObj: object = {}; +const anyValue: any = 'any value'; + +expectType(assocPath('a.b.c', anyValue, someObj)); +expectType(assocPath('a.b.c')(anyValue, someObj)); +expectType(assocPath('a.b.c')(anyValue)(someObj)); +expectType(assocPath('a.b.c', anyValue)(someObj)); + +expectType(assocPath(['a.b.c'], anyValue, someObj)); +expectType(assocPath(['a.b.c'])(anyValue, someObj)); +expectType(assocPath(['a.b.c'])(anyValue)(someObj)); +expectType(assocPath(['a.b.c'], anyValue)(someObj)); + +expectType(assocPath(['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(assocPath(['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); +expectType(assocPath(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(assocPath(['a.b.c', 2, Symbol('hep')], anyValue)(someObj)); diff --git a/packages/elastic-safer-lodash-set/test/fp_patch_test.js b/packages/elastic-safer-lodash-set/test/fp_patch_test.js new file mode 100644 index 00000000000000..362ecf6f9d8660 --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/fp_patch_test.js @@ -0,0 +1,290 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +const test = require('tape'); + +const setFunctions = [ + [testSet, require('../fp').set, 'fp.set'], + [testSet, require('../fp/set'), 'fp/set'], + [testSet, require('../fp').assoc, 'fp.assoc'], + [testSet, require('../fp/assoc'), 'fp/assoc'], + [testSet, require('../fp').assocPath, 'fp.assocPath'], + [testSet, require('../fp/assocPath'), 'fp/assocPath'], + [testSetWithAsSet, require('../fp').setWith, 'fp.setWith'], + [testSetWithAsSet, require('../fp/setWith'), 'fp/setWith'], +]; +const setWithFunctions = [ + [testSetWith, require('../fp').setWith, 'fp.setWith'], + [testSetWith, require('../fp/setWith'), 'fp/setWith'], +]; + +function testSet(fn, args, onCall) { + const [a, b, c] = args; + onCall(fn(b, c, a)); + onCall(fn(b, c)(a)); + onCall(fn(b)(c, a)); + onCall(fn(b)(c)(a)); +} +testSet.assertionCalls = 4; + +function testSetWith(fn, args, onCall) { + const [a, b, c, d] = args; + onCall(fn(d, b, c, a)); + onCall(fn(d)(b, c, a)); + onCall(fn(d)(b)(c, a)); + onCall(fn(d)(b)(c)(a)); + onCall(fn(d, b)(c)(a)); + onCall(fn(d, b, c)(a)); + onCall(fn(d)(b, c)(a)); +} +testSetWith.assertionCalls = 7; + +// use `fp.setWith` with the same API as `fp.set` by injecting a noop function as the first argument +function testSetWithAsSet(fn, args, onCall) { + args.push(() => {}); + testSetWith(fn, args, onCall); +} +testSetWithAsSet.assertionCalls = testSetWith.assertionCalls; + +setFunctions.forEach(([testPermutations, set, testName]) => { + /** + * GENERAL USAGE TESTS + */ + + const isSetWith = testPermutations.name === 'testSetWithAsSet'; + + test(`${testName}: No side-effects`, (t) => { + t.plan(testPermutations.assertionCalls * 5); + const o1 = { + a: { b: 1 }, + c: { d: 2 }, + }; + testPermutations(set, [o1, 'a.b', 3], (o2) => { + t.notStrictEqual(o1, o2); // clone touched paths + t.notStrictEqual(o1.a, o2.a); // clone touched paths + t.deepEqual(o1.c, o2.c); // do not clone untouched paths + t.deepEqual(o1, { a: { b: 1 }, c: { d: 2 } }); + t.deepEqual(o2, { a: { b: 3 }, c: { d: 2 } }); + }); + }); + + test(`${testName}: Non-objects`, (t) => { + const nonObjects = [null, undefined, NaN, 42]; + t.plan(testPermutations.assertionCalls * nonObjects.length * 3); + nonObjects.forEach((nonObject) => { + t.comment(String(nonObject)); + testPermutations(set, [nonObject, 'a.b', 'foo'], (result) => { + if (Number.isNaN(nonObject)) { + t.ok(result instanceof Number); + t.strictEqual(result.toString(), 'NaN'); + t.deepEqual(result, Object.assign(NaN, { a: { b: 'foo' } })); // will produce new object due to cloning + } else if (nonObject === 42) { + t.ok(result instanceof Number); + t.strictEqual(result.toString(), '42'); + t.deepEqual(result, Object.assign(42, { a: { b: 'foo' } })); // will produce new object due to cloning + } else { + t.ok(result instanceof Object); + t.strictEqual(result.toString(), '[object Object]'); + t.deepEqual(result, { a: { b: 'foo' } }); // will produce new object due to cloning + } + }); + }); + }); + + test(`${testName}: Overwrites existing object properties`, (t) => { + t.plan(testPermutations.assertionCalls); + testPermutations(set, [{ a: { b: { c: 3 } } }, 'a.b', 'foo'], (result) => { + t.deepEqual(result, { a: { b: 'foo' } }); + }); + }); + + test(`${testName}: Adds missing properties without touching other areas`, (t) => { + t.plan(testPermutations.assertionCalls); + testPermutations( + set, + [{ a: [{ aa: { aaa: 3, aab: 4 } }, { ab: 2 }], b: 1 }, 'a[0].aa.aaa.aaaa', 'foo'], + (result) => { + t.deepEqual(result, { + a: [{ aa: { aaa: Object.assign(3, { aaaa: 'foo' }), aab: 4 } }, { ab: 2 }], + b: 1, + }); + } + ); + }); + + test(`${testName}: Overwrites existing elements in array`, (t) => { + t.plan(testPermutations.assertionCalls); + testPermutations(set, [{ a: [1, 2, 3] }, 'a[1]', 'foo'], (result) => { + t.deepEqual(result, { a: [1, 'foo', 3] }); + }); + }); + + test(`${testName}: Create new array`, (t) => { + t.plan(testPermutations.assertionCalls); + testPermutations(set, [{}, ['x', '0', 'y', 'z'], 'foo'], (result) => { + t.deepEqual(result, { x: [{ y: { z: 'foo' } }] }); + }); + }); + + /** + * PROTOTYPE POLLUTION PROTECTION TESTS + */ + + const testCases = [ + ['__proto__', { ['__proto__']: 'foo' }], + ['.__proto__', { '': { ['__proto__']: 'foo' } }], + ['o.__proto__', { o: { ['__proto__']: 'foo' } }], + ['a[0].__proto__', { a: [{ ['__proto__']: 'foo' }] }], + + ['constructor', { constructor: 'foo' }], + ['.constructor', { '': { constructor: 'foo' } }], + ['o.constructor', { o: { constructor: 'foo' } }], + ['a[0].constructor', { a: [{ constructor: 'foo' }] }], + + ['constructor.something', { constructor: { something: 'foo' } }], + ['.constructor.something', { '': { constructor: { something: 'foo' } } }], + ['o.constructor.something', { o: { constructor: { something: 'foo' } } }], + ['a[0].constructor.something', { a: [{ constructor: { something: 'foo' } }] }], + + ['prototype', { prototype: 'foo' }], + ['.prototype', { '': { prototype: 'foo' } }], + ['o.prototype', { o: { prototype: 'foo' } }], + ['a[0].prototype', { a: [{ prototype: 'foo' }] }], + + ['constructor.prototype', { constructor: { prototype: 'foo' } }], + ['.constructor.prototype', { '': { constructor: { prototype: 'foo' } } }], + ['o.constructor.prototype', { o: { constructor: { prototype: 'foo' } } }], + ['a[0].constructor.prototype', { a: [{ constructor: { prototype: 'foo' } }] }], + + ['constructor.something.prototype', { constructor: { something: { prototype: 'foo' } } }], + [ + '.constructor.something.prototype', + { '': { constructor: { something: { prototype: 'foo' } } } }, + ], + [ + 'o.constructor.something.prototype', + { o: { constructor: { something: { prototype: 'foo' } } } }, + ], + [ + 'a[0].constructor.something.prototype', + { a: [{ constructor: { something: { prototype: 'foo' } } }] }, + ], + ]; + + testCases.forEach(([path, expected]) => { + test(`${testName}: Object manipulation, ${path}`, (t) => { + t.plan(testPermutations.assertionCalls); + testPermutations(set, [{}, path, 'foo'], (result) => { + t.deepLooseEqual(result, expected); // Use loose check because the prototype of result isn't Object.prototype + }); + }); + }); + + testCases.forEach(([path, expected]) => { + test(`${testName}: Array manipulation, ${path}`, (t) => { + t.plan(testPermutations.assertionCalls * 4); + const arr = []; + testPermutations(set, [arr, path, 'foo'], (result) => { + t.notStrictEqual(arr, result); + t.ok(Array.isArray(result)); + Object.keys(expected).forEach((key) => { + t.ok(Object.prototype.hasOwnProperty.call(result, key)); + t.deepEqual(result[key], expected[key]); + }); + }); + }); + }); + + test(`${testName}: Function manipulation, object containing function`, (t) => { + const funcTestCases = [ + [{ fn: function () {} }, 'fn.prototype'], + [{ fn: () => {} }, 'fn.prototype'], + ]; + const expected = /Illegal access of function prototype/; + t.plan((isSetWith ? 7 : 4) * funcTestCases.length); + funcTestCases.forEach(([obj, path]) => { + if (isSetWith) { + t.throws(() => set(() => {}, path, 'foo', obj), expected); + t.throws(() => set(() => {})(path, 'foo', obj), expected); + t.throws(() => set(() => {})(path)('foo', obj), expected); + t.throws(() => set(() => {})(path)('foo')(obj), expected); + t.throws(() => set(() => {}, path)('foo')(obj), expected); + t.throws(() => set(() => {}, path, 'foo')(obj), expected); + t.throws(() => set(() => {})(path, 'foo')(obj), expected); + } else { + t.throws(() => set(path, 'foo', obj), expected); + t.throws(() => set(path, 'foo')(obj), expected); + t.throws(() => set(path)('foo', obj), expected); + t.throws(() => set(path)('foo')(obj), expected); + } + }); + }); + test(`${testName}: Function manipulation, arrow function`, (t) => { + // This doesn't really make sense to do with the `fp` variant of lodash, as it will return a regular non-function object + t.plan(testPermutations.assertionCalls * 2); + const obj = () => {}; + testPermutations(set, [obj, 'prototype', 'foo'], (result) => { + t.notStrictEqual(result, obj); + t.strictEqual(result.prototype, 'foo'); + }); + }); + test(`${testName}: Function manipulation, regular function`, (t) => { + // This doesn't really make sense to do with the `fp` variant of lodash, as it will return a regular non-function object + t.plan(testPermutations.assertionCalls * 2); + const obj = function () {}; + testPermutations(set, [obj, 'prototype', 'foo'], (result) => { + t.notStrictEqual(result, obj); + t.strictEqual(result.prototype, 'foo'); + }); + }); +}); + +/** + * setWith specific tests + */ +setWithFunctions.forEach(([testPermutations, setWith, testName]) => { + test(`${testName}: Return undefined`, (t) => { + t.plan(testPermutations.assertionCalls); + testPermutations(setWith, [{}, 'a.b', 'foo', () => {}], (result) => { + t.deepEqual(result, { a: { b: 'foo' } }); + }); + }); + + test(`${testName}: Customizer arguments`, (t) => { + let i = 0; + const expectedCustomizerArgs = [ + [{ b: Object(42) }, 'a', { a: { b: Object(42) } }], + [Object(42), 'b', { b: Object(42) }], + ]; + + t.plan(testPermutations.assertionCalls * (expectedCustomizerArgs.length + 1)); + + testPermutations( + setWith, + [ + { a: { b: 42 } }, + 'a.b.c', + 'foo', + (...args) => { + t.deepEqual( + args, + expectedCustomizerArgs[i++ % 2], + 'customizer args should be as expected' + ); + }, + ], + (result) => { + t.deepEqual(result, { a: { b: Object.assign(42, { c: 'foo' }) } }); + } + ); + }); + + test(`${testName}: Return value`, (t) => { + t.plan(testPermutations.assertionCalls); + testSetWith(setWith, [{}, '[0][1]', 'a', Object], (result) => { + t.deepEqual(result, { 0: { 1: 'a' } }); + }); + }); +}); diff --git a/packages/elastic-safer-lodash-set/test/fp_set.test-d.ts b/packages/elastic-safer-lodash-set/test/fp_set.test-d.ts new file mode 100644 index 00000000000000..a5dbb24d33a052 --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/fp_set.test-d.ts @@ -0,0 +1,25 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { expectType } from 'tsd'; +import set from '../fp/set'; + +const someObj: object = {}; +const anyValue: any = 'any value'; + +expectType(set('a.b.c', anyValue, someObj)); +expectType(set('a.b.c')(anyValue, someObj)); +expectType(set('a.b.c')(anyValue)(someObj)); +expectType(set('a.b.c', anyValue)(someObj)); + +expectType(set(['a.b.c'], anyValue, someObj)); +expectType(set(['a.b.c'])(anyValue, someObj)); +expectType(set(['a.b.c'])(anyValue)(someObj)); +expectType(set(['a.b.c'], anyValue)(someObj)); + +expectType(set(['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(set(['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); +expectType(set(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(set(['a.b.c', 2, Symbol('hep')], anyValue)(someObj)); diff --git a/packages/elastic-safer-lodash-set/test/fp_setWith.test-d.ts b/packages/elastic-safer-lodash-set/test/fp_setWith.test-d.ts new file mode 100644 index 00000000000000..70a5197f72176d --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/fp_setWith.test-d.ts @@ -0,0 +1,40 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { expectType } from 'tsd'; +import setWith from '../fp/setWith'; + +const someObj: object = {}; +const anyValue: any = 'any value'; + +function customizer(value: any, key: string, obj: object) { + expectType(value); + expectType(key); + expectType(obj); +} + +expectType(setWith(customizer, 'a.b.c', anyValue, someObj)); +expectType(setWith(customizer)('a.b.c', anyValue, someObj)); +expectType(setWith(customizer)('a.b.c')(anyValue, someObj)); +expectType(setWith(customizer)('a.b.c')(anyValue)(someObj)); +expectType(setWith(customizer, 'a.b.c')(anyValue)(someObj)); +expectType(setWith(customizer, 'a.b.c', anyValue)(someObj)); +expectType(setWith(customizer, 'a.b.c')(anyValue, someObj)); + +expectType(setWith(customizer, ['a.b.c'], anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c'])(anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c'], anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c'])(anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c'])(anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c'], anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c'])(anyValue, someObj)); + +expectType(setWith(customizer, ['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c', 2, Symbol('hep')], anyValue, someObj)); +expectType(setWith(customizer)(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c', 2, Symbol('hep')])(anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c', 2, Symbol('hep')], anyValue)(someObj)); +expectType(setWith(customizer, ['a.b.c', 2, Symbol('hep')])(anyValue, someObj)); diff --git a/packages/elastic-safer-lodash-set/test/index.test-d.ts b/packages/elastic-safer-lodash-set/test/index.test-d.ts new file mode 100644 index 00000000000000..ab29d7de5a03fb --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/index.test-d.ts @@ -0,0 +1,37 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { expectType } from 'tsd'; +import { set, setWith } from '../'; + +const someObj: object = {}; +const anyValue: any = 'any value'; + +expectType(set(someObj, 'a.b.c', anyValue)); +expectType( + setWith(someObj, 'a.b.c', anyValue, (value, key, obj) => { + expectType(value); + expectType(key); + expectType(obj); + }) +); + +expectType(set(someObj, ['a.b.c'], anyValue)); +expectType( + setWith(someObj, ['a.b.c'], anyValue, (value, key, obj) => { + expectType(value); + expectType(key); + expectType(obj); + }) +); + +expectType(set(someObj, ['a.b.c', 2, Symbol('hep')], anyValue)); +expectType( + setWith(someObj, ['a.b.c', 2, Symbol('hep')], anyValue, (value, key, obj) => { + expectType(value); + expectType(key); + expectType(obj); + }) +); diff --git a/packages/elastic-safer-lodash-set/test/patch_test.js b/packages/elastic-safer-lodash-set/test/patch_test.js new file mode 100644 index 00000000000000..03dfe260009e9f --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/patch_test.js @@ -0,0 +1,174 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +const test = require('tape'); + +const setFunctions = [ + [require('../').set, 'module.set'], + [require('../set'), 'module/set'], +]; +const setWithFunctions = [ + [require('../').setWith, 'module.setWith'], + [require('../setWith'), 'module/setWith'], +]; +const setAndSetWithFunctions = [].concat(setFunctions, setWithFunctions); + +setAndSetWithFunctions.forEach(([set, testName]) => { + /** + * GENERAL USAGE TESTS + */ + + test(`${testName}: Returns same object`, (t) => { + const o1 = {}; + const o2 = set(o1, 'foo', 'bar'); + t.strictEqual(o1, o2); + t.end(); + }); + + test(`${testName}: Non-objects`, (t) => { + t.strictEqual(set(null, 'a.b', 'foo'), null); + t.strictEqual(set(undefined, 'a.b', 'foo'), undefined); + t.strictEqual(set(NaN, 'a.b', 'foo'), NaN); + t.strictEqual(set(42, 'a.b', 'foo'), 42); + t.end(); + }); + + test(`${testName}: Overwrites existing object properties`, (t) => { + t.deepEqual(set({ a: { b: { c: 3 } } }, 'a.b', 'foo'), { a: { b: 'foo' } }); + t.end(); + }); + + test(`${testName}: Adds missing properties without touching other areas`, (t) => { + t.deepEqual( + set({ a: [{ aa: { aaa: 3, aab: 4 } }, { ab: 2 }], b: 1 }, 'a[0].aa.aaa.aaaa', 'foo'), + { a: [{ aa: { aaa: { aaaa: 'foo' }, aab: 4 } }, { ab: 2 }], b: 1 } + ); + t.end(); + }); + + test(`${testName}: Overwrites existing elements in array`, (t) => { + t.deepEqual(set({ a: [1, 2, 3] }, 'a[1]', 'foo'), { a: [1, 'foo', 3] }); + t.end(); + }); + + test(`${testName}: Create new array`, (t) => { + t.deepEqual(set({}, ['x', '0', 'y', 'z'], 'foo'), { x: [{ y: { z: 'foo' } }] }); + t.end(); + }); + + /** + * PROTOTYPE POLLUTION PROTECTION TESTS + */ + + const testCases = [ + ['__proto__', { ['__proto__']: 'foo' }], + ['.__proto__', { '': { ['__proto__']: 'foo' } }], + ['o.__proto__', { o: { ['__proto__']: 'foo' } }], + ['a[0].__proto__', { a: [{ ['__proto__']: 'foo' }] }], + + ['constructor', { constructor: 'foo' }], + ['.constructor', { '': { constructor: 'foo' } }], + ['o.constructor', { o: { constructor: 'foo' } }], + ['a[0].constructor', { a: [{ constructor: 'foo' }] }], + + ['constructor.something', { constructor: { something: 'foo' } }], + ['.constructor.something', { '': { constructor: { something: 'foo' } } }], + ['o.constructor.something', { o: { constructor: { something: 'foo' } } }], + ['a[0].constructor.something', { a: [{ constructor: { something: 'foo' } }] }], + + ['prototype', { prototype: 'foo' }], + ['.prototype', { '': { prototype: 'foo' } }], + ['o.prototype', { o: { prototype: 'foo' } }], + ['a[0].prototype', { a: [{ prototype: 'foo' }] }], + + ['constructor.prototype', { constructor: { prototype: 'foo' } }], + ['.constructor.prototype', { '': { constructor: { prototype: 'foo' } } }], + ['o.constructor.prototype', { o: { constructor: { prototype: 'foo' } } }], + ['a[0].constructor.prototype', { a: [{ constructor: { prototype: 'foo' } }] }], + + ['constructor.something.prototype', { constructor: { something: { prototype: 'foo' } } }], + [ + '.constructor.something.prototype', + { '': { constructor: { something: { prototype: 'foo' } } } }, + ], + [ + 'o.constructor.something.prototype', + { o: { constructor: { something: { prototype: 'foo' } } } }, + ], + [ + 'a[0].constructor.something.prototype', + { a: [{ constructor: { something: { prototype: 'foo' } } }] }, + ], + ]; + + testCases.forEach(([path, expected]) => { + test(`${testName}: Object manipulation, ${path}`, (t) => { + t.deepEqual(set({}, path, 'foo'), expected); + t.end(); + }); + }); + + testCases.forEach(([path, expected]) => { + test(`${testName}: Array manipulation, ${path}`, (t) => { + const arr = []; + set(arr, path, 'foo'); + Object.keys(expected).forEach((key) => { + t.ok(Object.prototype.hasOwnProperty.call(arr, key)); + t.deepEqual(arr[key], expected[key]); + }); + t.end(); + }); + }); + + test(`${testName}: Function manipulation`, (t) => { + const funcTestCases = [ + [function () {}, 'prototype'], + [() => {}, 'prototype'], + [{ fn: function () {} }, 'fn.prototype'], + [{ fn: () => {} }, 'fn.prototype'], + ]; + funcTestCases.forEach(([obj, path]) => { + t.throws(() => set(obj, path, 'foo'), /Illegal access of function prototype/); + }); + t.end(); + }); +}); + +/** + * setWith specific tests + */ + +setWithFunctions.forEach(([setWith, testName]) => { + test(`${testName}: Return undefined`, (t) => { + t.deepEqual( + setWith({}, 'a.b', 'foo', () => {}), + { a: { b: 'foo' } } + ); + t.end(); + }); + + test(`${testName}: Customizer arguments`, (t) => { + t.plan(3); + + const expectedCustomizerArgs = [ + [{ b: 42 }, 'a', { a: { b: 42 } }], + [42, 'b', { b: 42 }], + ]; + + t.deepEqual( + setWith({ a: { b: 42 } }, 'a.b.c', 'foo', (...args) => { + t.deepEqual(args, expectedCustomizerArgs.shift()); + }), + { a: { b: { c: 'foo' } } } + ); + + t.end(); + }); + + test(`${testName}: Return value`, (t) => { + t.deepEqual(setWith({}, '[0][1]', 'a', Object), { 0: { 1: 'a' } }); + t.end(); + }); +}); diff --git a/packages/elastic-safer-lodash-set/test/set.test-d.ts b/packages/elastic-safer-lodash-set/test/set.test-d.ts new file mode 100644 index 00000000000000..9829ac3f04ce53 --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/set.test-d.ts @@ -0,0 +1,14 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { expectType } from 'tsd'; +import set from '../set'; + +const someObj: object = {}; +const anyValue: any = 'any value'; + +expectType(set(someObj, 'a.b.c', anyValue)); +expectType(set(someObj, ['a.b.c'], anyValue)); +expectType(set(someObj, ['a.b.c', 2, Symbol('hep')], anyValue)); diff --git a/packages/elastic-safer-lodash-set/test/setWith.test-d.ts b/packages/elastic-safer-lodash-set/test/setWith.test-d.ts new file mode 100644 index 00000000000000..b3ed93443c4fbb --- /dev/null +++ b/packages/elastic-safer-lodash-set/test/setWith.test-d.ts @@ -0,0 +1,32 @@ +/* + * Elasticsearch B.V licenses this file to you under the MIT License. + * See `packages/elastic-safer-lodash-set/LICENSE` for more information. + */ + +import { expectType } from 'tsd'; +import setWith from '../setWith'; + +const someObj: object = {}; +const anyValue: any = 'any value'; + +expectType( + setWith(someObj, 'a.b.c', anyValue, (value, key, obj) => { + expectType(value); + expectType(key); + expectType(obj); + }) +); +expectType( + setWith(someObj, ['a.b.c'], anyValue, (value, key, obj) => { + expectType(value); + expectType(key); + expectType(obj); + }) +); +expectType( + setWith(someObj, ['a.b.c', 2, Symbol('hep')], anyValue, (value, key, obj) => { + expectType(value); + expectType(key); + expectType(obj); + }) +); diff --git a/packages/elastic-safer-lodash-set/tsconfig.json b/packages/elastic-safer-lodash-set/tsconfig.json new file mode 100644 index 00000000000000..bc1d1a3a7e413d --- /dev/null +++ b/packages/elastic-safer-lodash-set/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "include": [ + "**/*" + ], + "exclude": [ + "**/*.test-d.ts" + ] +} diff --git a/packages/kbn-telemetry-tools/src/tools/check_collector__integrity.test.ts b/packages/kbn-telemetry-tools/src/tools/check_collector__integrity.test.ts index 6083593431d9b3..dbdda3f38afd5b 100644 --- a/packages/kbn-telemetry-tools/src/tools/check_collector__integrity.test.ts +++ b/packages/kbn-telemetry-tools/src/tools/check_collector__integrity.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import * as _ from 'lodash'; +import { cloneDeep } from 'lodash'; import * as ts from 'typescript'; import { parsedWorkingCollector } from './__fixture__/parsed_working_collector'; import { checkCompatibleTypeDescriptor, checkMatchingMapping } from './check_collector_integrity'; @@ -42,7 +42,7 @@ describe('checkMatchingMapping', () => { describe('Collector change', () => { it('returns diff on mismatching parsedCollections and stored mapping', async () => { const mockSchema = await parseJsonFile('mock_schema.json'); - const malformedParsedCollector = _.cloneDeep(parsedWorkingCollector); + const malformedParsedCollector = cloneDeep(parsedWorkingCollector); const fieldMapping = { type: 'number' }; malformedParsedCollector[1].schema.value.flat = fieldMapping; @@ -58,7 +58,7 @@ describe('checkMatchingMapping', () => { it('returns diff on unknown parsedCollections', async () => { const mockSchema = await parseJsonFile('mock_schema.json'); - const malformedParsedCollector = _.cloneDeep(parsedWorkingCollector); + const malformedParsedCollector = cloneDeep(parsedWorkingCollector); const collectorName = 'New Collector in town!'; const collectorMapping = { some_usage: { type: 'number' } }; malformedParsedCollector[1].collectorName = collectorName; @@ -84,7 +84,7 @@ describe('checkCompatibleTypeDescriptor', () => { describe('Interface Change', () => { it('returns diff on incompatible type descriptor with mapping', () => { - const malformedParsedCollector = _.cloneDeep(parsedWorkingCollector); + const malformedParsedCollector = cloneDeep(parsedWorkingCollector); malformedParsedCollector[1].fetch.typeDescriptor.flat.kind = ts.SyntaxKind.BooleanKeyword; const incompatibles = checkCompatibleTypeDescriptor([malformedParsedCollector]); expect(incompatibles).toHaveLength(1); @@ -101,14 +101,14 @@ describe('checkCompatibleTypeDescriptor', () => { describe('Mapping change', () => { it('returns no diff when mapping change between text and keyword', () => { - const malformedParsedCollector = _.cloneDeep(parsedWorkingCollector); + const malformedParsedCollector = cloneDeep(parsedWorkingCollector); malformedParsedCollector[1].schema.value.flat.type = 'text'; const incompatibles = checkCompatibleTypeDescriptor([malformedParsedCollector]); expect(incompatibles).toHaveLength(0); }); it('returns diff on incompatible type descriptor with mapping', () => { - const malformedParsedCollector = _.cloneDeep(parsedWorkingCollector); + const malformedParsedCollector = cloneDeep(parsedWorkingCollector); malformedParsedCollector[1].schema.value.flat.type = 'boolean'; const incompatibles = checkCompatibleTypeDescriptor([malformedParsedCollector]); expect(incompatibles).toHaveLength(1); diff --git a/packages/kbn-telemetry-tools/src/tools/check_collector_integrity.ts b/packages/kbn-telemetry-tools/src/tools/check_collector_integrity.ts index 824132b05732ce..3205edb87aa296 100644 --- a/packages/kbn-telemetry-tools/src/tools/check_collector_integrity.ts +++ b/packages/kbn-telemetry-tools/src/tools/check_collector_integrity.ts @@ -17,7 +17,7 @@ * under the License. */ -import * as _ from 'lodash'; +import { reduce } from 'lodash'; import { difference, flattenKeys, pickDeep } from './utils'; import { ParsedUsageCollection } from './ts_parser'; import { generateMapping, compatibleSchemaTypes } from './manage_schema'; @@ -44,7 +44,7 @@ export function checkCompatibleTypeDescriptor( const typeDescriptorTypes = flattenKeys( pickDeep(collectorDetails.fetch.typeDescriptor, 'kind') ); - const typeDescriptorKinds = _.reduce( + const typeDescriptorKinds = reduce( typeDescriptorTypes, (acc: any, type: number, key: string) => { try { @@ -58,7 +58,7 @@ export function checkCompatibleTypeDescriptor( ); const schemaTypes = flattenKeys(pickDeep(collectorDetails.schema.value, 'type')); - const transformedMappingKinds = _.reduce( + const transformedMappingKinds = reduce( schemaTypes, (acc: any, type: string, key: string) => { try { diff --git a/packages/kbn-telemetry-tools/src/tools/tasks/generate_schemas_task.ts b/packages/kbn-telemetry-tools/src/tools/tasks/generate_schemas_task.ts index f6d15c7127d4eb..5ff7d2dd8ef6ea 100644 --- a/packages/kbn-telemetry-tools/src/tools/tasks/generate_schemas_task.ts +++ b/packages/kbn-telemetry-tools/src/tools/tasks/generate_schemas_task.ts @@ -17,7 +17,6 @@ * under the License. */ -import * as _ from 'lodash'; import { TaskContext } from './task_context'; import { generateMapping } from '../manage_schema'; diff --git a/packages/kbn-telemetry-tools/src/tools/utils.ts b/packages/kbn-telemetry-tools/src/tools/utils.ts index f5cf74ae35e456..212b06a4c98954 100644 --- a/packages/kbn-telemetry-tools/src/tools/utils.ts +++ b/packages/kbn-telemetry-tools/src/tools/utils.ts @@ -18,7 +18,7 @@ */ import * as ts from 'typescript'; -import * as _ from 'lodash'; +import { pick, isObject, each, isArray, reduce, isEmpty, merge, transform, isEqual } from 'lodash'; import * as path from 'path'; import glob from 'glob'; import { readFile, writeFile } from 'fs'; @@ -178,17 +178,17 @@ export function getPropertyValue( } export function pickDeep(collection: any, identity: any, thisArg?: any) { - const picked: any = _.pick(collection, identity, thisArg); - const collections = _.pick(collection, _.isObject, thisArg); + const picked: any = pick(collection, identity, thisArg); + const collections = pick(collection, isObject, thisArg); - _.each(collections, function (item, key) { + each(collections, function (item, key) { let object; - if (_.isArray(item)) { - object = _.reduce( + if (isArray(item)) { + object = reduce( item, function (result, value) { const pickedDeep = pickDeep(value, identity, thisArg); - if (!_.isEmpty(pickedDeep)) { + if (!isEmpty(pickedDeep)) { result.push(pickedDeep); } return result; @@ -199,7 +199,7 @@ export function pickDeep(collection: any, identity: any, thisArg?: any) { object = pickDeep(item, identity, thisArg); } - if (!_.isEmpty(object)) { + if (!isEmpty(object)) { picked[key || ''] = object; } }); @@ -208,12 +208,12 @@ export function pickDeep(collection: any, identity: any, thisArg?: any) { } export const flattenKeys = (obj: any, keyPath: any[] = []): any => { - if (_.isObject(obj)) { - return _.reduce( + if (isObject(obj)) { + return reduce( obj, (cum, next, key) => { const keys = [...keyPath, key]; - return _.merge(cum, flattenKeys(next, keys)); + return merge(cum, flattenKeys(next, keys)); }, {} ); @@ -223,10 +223,9 @@ export const flattenKeys = (obj: any, keyPath: any[] = []): any => { export function difference(actual: any, expected: any) { function changes(obj: any, base: any) { - return _.transform(obj, function (result, value, key) { - if (key && !_.isEqual(value, base[key])) { - result[key] = - _.isObject(value) && _.isObject(base[key]) ? changes(value, base[key]) : value; + return transform(obj, function (result, value, key) { + if (key && !isEqual(value, base[key])) { + result[key] = isObject(value) && isObject(base[key]) ? changes(value, base[key]) : value; } }); } diff --git a/src/cli/command.js b/src/cli/command.js index f4781fcab1e20c..671e053b9550e5 100644 --- a/src/cli/command.js +++ b/src/cli/command.js @@ -17,6 +17,7 @@ * under the License. */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import Chalk from 'chalk'; @@ -86,7 +87,7 @@ Command.prototype.collectUnknownOptions = function () { val = opt[1]; } - _.set(opts, opt[0].slice(2), val); + set(opts, opt[0].slice(2), val); } return opts; diff --git a/src/cli/serve/read_keystore.js b/src/cli/serve/read_keystore.js index cfe02735630f22..962c708c0d8df9 100644 --- a/src/cli/serve/read_keystore.js +++ b/src/cli/serve/read_keystore.js @@ -18,7 +18,7 @@ */ import path from 'path'; -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { Keystore } from '../../legacy/server/keystore'; import { getDataPath } from '../../core/server/path'; diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index 8bc65f3da7111e..972bcdba6b4032 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -17,6 +17,7 @@ * under the License. */ +import { set as lodashSet } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import { statSync } from 'fs'; import { resolve } from 'path'; @@ -65,7 +66,7 @@ const pluginDirCollector = pathCollector(); const pluginPathCollector = pathCollector(); function applyConfigOverrides(rawConfig, opts, extraCliOptions) { - const set = _.partial(_.set, rawConfig); + const set = _.partial(lodashSet, rawConfig); const get = _.partial(_.get, rawConfig); const has = _.partial(_.has, rawConfig); const merge = _.partial(_.merge, rawConfig); diff --git a/src/core/public/saved_objects/simple_saved_object.ts b/src/core/public/saved_objects/simple_saved_object.ts index 165ef98be91d41..5bd339fbd7c965 100644 --- a/src/core/public/saved_objects/simple_saved_object.ts +++ b/src/core/public/saved_objects/simple_saved_object.ts @@ -17,7 +17,8 @@ * under the License. */ -import { get, has, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get, has } from 'lodash'; import { SavedObject as SavedObjectType } from '../../server'; import { SavedObjectsClientContract } from './saved_objects_client'; diff --git a/src/core/server/config/deprecation/deprecation_factory.ts b/src/core/server/config/deprecation/deprecation_factory.ts index 0b19a996243119..cbc9984924c5dd 100644 --- a/src/core/server/config/deprecation/deprecation_factory.ts +++ b/src/core/server/config/deprecation/deprecation_factory.ts @@ -17,7 +17,8 @@ * under the License. */ -import { get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get } from 'lodash'; import { ConfigDeprecation, ConfigDeprecationLogger, ConfigDeprecationFactory } from './types'; import { unset } from '../../../utils'; diff --git a/src/core/server/config/object_to_config_adapter.ts b/src/core/server/config/object_to_config_adapter.ts index d4c2f733640609..50b31722dceeb2 100644 --- a/src/core/server/config/object_to_config_adapter.ts +++ b/src/core/server/config/object_to_config_adapter.ts @@ -17,7 +17,8 @@ * under the License. */ -import { cloneDeep, get, has, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { cloneDeep, get, has } from 'lodash'; import { getFlattenedObject } from '../../utils'; import { Config, ConfigPath } from './'; diff --git a/src/core/server/config/read_config.ts b/src/core/server/config/read_config.ts index eac3535c9d4ed6..806366dc3e0623 100644 --- a/src/core/server/config/read_config.ts +++ b/src/core/server/config/read_config.ts @@ -20,7 +20,8 @@ import { readFileSync } from 'fs'; import { safeLoad } from 'js-yaml'; -import { isPlainObject, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { isPlainObject } from 'lodash'; import { ensureDeepObject } from './ensure_deep_object'; const readYaml = (path: string) => safeLoad(readFileSync(path, 'utf8')); diff --git a/src/core/server/legacy/config/get_unused_config_keys.ts b/src/core/server/legacy/config/get_unused_config_keys.ts index 8e53178142180e..354bf9af042cf7 100644 --- a/src/core/server/legacy/config/get_unused_config_keys.ts +++ b/src/core/server/legacy/config/get_unused_config_keys.ts @@ -17,7 +17,8 @@ * under the License. */ -import { difference, get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { difference, get } from 'lodash'; // @ts-expect-error import { getTransform } from '../../../../legacy/deprecation/index'; import { unset } from '../../../../legacy/utils'; diff --git a/src/core/server/saved_objects/migrations/core/document_migrator.test.ts b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts index 6287d47f99f623..4fc94d1992869b 100644 --- a/src/core/server/saved_objects/migrations/core/document_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts @@ -17,6 +17,7 @@ * under the License. */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import { SavedObjectUnsanitizedDoc } from '../../serialization'; import { DocumentMigrator } from './document_migrator'; @@ -132,7 +133,7 @@ describe('DocumentMigrator', () => { name: 'user', migrations: { '1.2.3': (doc) => { - _.set(doc, 'attributes.name', 'Mike'); + set(doc, 'attributes.name', 'Mike'); return doc; }, }, @@ -639,7 +640,7 @@ describe('DocumentMigrator', () => { typeRegistry: createRegistry({ name: 'aaa', migrations: { - '2.3.4': (d) => _.set(d, 'attributes.counter', 42), + '2.3.4': (d) => set(d, 'attributes.counter', 42), }, }), validateDoc: (d) => { @@ -657,12 +658,12 @@ describe('DocumentMigrator', () => { function renameAttr(path: string, newPath: string) { return (doc: SavedObjectUnsanitizedDoc) => - _.omit(_.set(doc, newPath, _.get(doc, path)) as {}, path) as SavedObjectUnsanitizedDoc; + _.omit(set(doc, newPath, _.get(doc, path)) as {}, path) as SavedObjectUnsanitizedDoc; } function setAttr(path: string, value: any) { return (doc: SavedObjectUnsanitizedDoc) => - _.set( + set( doc, path, _.isFunction(value) ? value(_.get(doc, path)) : value diff --git a/src/core/server/saved_objects/migrations/core/document_migrator.ts b/src/core/server/saved_objects/migrations/core/document_migrator.ts index 07675bb0a6819e..c50f755fda9943 100644 --- a/src/core/server/saved_objects/migrations/core/document_migrator.ts +++ b/src/core/server/saved_objects/migrations/core/document_migrator.ts @@ -61,6 +61,7 @@ */ import Boom from 'boom'; +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import Semver from 'semver'; import { Logger } from '../../../logging'; @@ -291,7 +292,7 @@ function markAsUpToDate(doc: SavedObjectUnsanitizedDoc, migrations: ActiveMigrat ...doc, migrationVersion: props(doc).reduce((acc, prop) => { const version = propVersion(migrations, prop); - return version ? _.set(acc, prop, version) : acc; + return version ? set(acc, prop, version) : acc; }, {}), }; } diff --git a/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts index 6e4dd9615d4230..4c9d2e870a7bb3 100644 --- a/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts +++ b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts @@ -17,6 +17,7 @@ * under the License. */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import { SavedObjectTypeRegistry } from '../../saved_objects_type_registry'; import { SavedObjectsSerializer } from '../../serialization'; @@ -25,7 +26,7 @@ import { createSavedObjectsMigrationLoggerMock } from '../../migrations/mocks'; describe('migrateRawDocs', () => { test('converts raw docs to saved objects', async () => { - const transform = jest.fn((doc: any) => _.set(doc, 'attributes.name', 'HOI!')); + const transform = jest.fn((doc: any) => set(doc, 'attributes.name', 'HOI!')); const result = await migrateRawDocs( new SavedObjectsSerializer(new SavedObjectTypeRegistry()), transform, @@ -53,7 +54,7 @@ describe('migrateRawDocs', () => { test('passes invalid docs through untouched and logs error', async () => { const logger = createSavedObjectsMigrationLoggerMock(); const transform = jest.fn((doc: any) => - _.set(_.cloneDeep(doc), 'attributes.name', 'TADA') + set(_.cloneDeep(doc), 'attributes.name', 'TADA') ); const result = await migrateRawDocs( new SavedObjectsSerializer(new SavedObjectTypeRegistry()), diff --git a/src/core/server/saved_objects/service/lib/filter_utils.ts b/src/core/server/saved_objects/service/lib/filter_utils.ts index 4c31f37f63dad7..5fbe62a074b29b 100644 --- a/src/core/server/saved_objects/service/lib/filter_utils.ts +++ b/src/core/server/saved_objects/service/lib/filter_utils.ts @@ -17,7 +17,8 @@ * under the License. */ -import { get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get } from 'lodash'; import { SavedObjectsErrorHelpers } from './errors'; import { IndexMapping } from '../../mappings'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/src/dev/file.ts b/src/dev/file.ts index 29e7cdc9669095..32998d3e776ef5 100644 --- a/src/dev/file.ts +++ b/src/dev/file.ts @@ -55,7 +55,9 @@ export class File { } public isFixture() { - return this.relativePath.split(sep).includes('__fixtures__'); + return ( + this.relativePath.split(sep).includes('__fixtures__') || this.path.endsWith('.test-d.ts') + ); } public getRelativeParentDirs() { diff --git a/src/dev/precommit_hook/casing_check_config.js b/src/dev/precommit_hook/casing_check_config.js index b8eacdd6a38972..6b1f1dfaeabb43 100644 --- a/src/dev/precommit_hook/casing_check_config.js +++ b/src/dev/precommit_hook/casing_check_config.js @@ -61,6 +61,9 @@ export const IGNORE_FILE_GLOBS = [ // filename required by api-extractor 'api-documenter.json', + // filename must match upstream filenames from lodash + 'packages/elastic-safer-lodash-set/**/*', + // TODO fix file names in APM to remove these 'x-pack/plugins/apm/public/**/*', 'x-pack/plugins/apm/scripts/**/*', diff --git a/src/fixtures/mock_ui_state.js b/src/fixtures/mock_ui_state.js index 919274390d4d0a..9252fcf2a7dd84 100644 --- a/src/fixtures/mock_ui_state.js +++ b/src/fixtures/mock_ui_state.js @@ -17,6 +17,7 @@ * under the License. */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; let values = {}; export default { @@ -24,11 +25,11 @@ export default { return _.get(values, path, def); }, set: function (path, val) { - _.set(values, path, val); + set(values, path, val); return val; }, setSilent: function (path, val) { - _.set(values, path, val); + set(values, path, val); return val; }, emit: _.noop, diff --git a/src/legacy/deprecation/deprecations/rename.js b/src/legacy/deprecation/deprecations/rename.js index b47a745519b1e7..c96b9146b4e2c0 100644 --- a/src/legacy/deprecation/deprecations/rename.js +++ b/src/legacy/deprecation/deprecations/rename.js @@ -17,7 +17,8 @@ * under the License. */ -import { get, isUndefined, noop, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get, isUndefined, noop } from 'lodash'; import { unset } from '../../utils'; export function rename(oldKey, newKey) { diff --git a/src/legacy/server/config/config.js b/src/legacy/server/config/config.js index d32ec29e6d701d..7805296258d9f5 100644 --- a/src/legacy/server/config/config.js +++ b/src/legacy/server/config/config.js @@ -18,6 +18,7 @@ */ import Joi from 'joi'; +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import { override } from './override'; import createDefaultSchema from './schema'; @@ -56,7 +57,7 @@ export class Config { throw new Error(`Config schema already has key: ${key}`); } - _.set(this[schemaExts], key, extension); + set(this[schemaExts], key, extension); this[schema] = null; this.set(key, settings); @@ -82,7 +83,7 @@ export class Config { if (_.isPlainObject(key)) { config = override(config, key); } else { - _.set(config, key, value); + set(config, key, value); } // attempt to validate the config value diff --git a/src/legacy/ui/public/state_management/state_monitor_factory.ts b/src/legacy/ui/public/state_management/state_monitor_factory.ts index 454fefd4f8253f..968ececfe3be5d 100644 --- a/src/legacy/ui/public/state_management/state_monitor_factory.ts +++ b/src/legacy/ui/public/state_management/state_monitor_factory.ts @@ -16,7 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { cloneDeep, isEqual, isPlainObject, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { cloneDeep, isEqual, isPlainObject } from 'lodash'; import { State } from './state'; export const stateMonitorFactory = { diff --git a/src/plugins/data/public/search/expressions/build_tabular_inspector_data.ts b/src/plugins/data/public/search/expressions/build_tabular_inspector_data.ts index c4846a98f124fd..75a4464a8e61ee 100644 --- a/src/plugins/data/public/search/expressions/build_tabular_inspector_data.ts +++ b/src/plugins/data/public/search/expressions/build_tabular_inspector_data.ts @@ -17,7 +17,7 @@ * under the License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { FormattedData } from '../../../../../plugins/inspector/public'; import { FormatFactory } from '../../../common/field_formats/utils'; import { TabbedTable } from '../tabify'; diff --git a/src/plugins/data/public/search/search_source/search_source.ts b/src/plugins/data/public/search/search_source/search_source.ts index 6260b92e1c11aa..c97a5d0638a6ac 100644 --- a/src/plugins/data/public/search/search_source/search_source.ts +++ b/src/plugins/data/public/search/search_source/search_source.ts @@ -69,18 +69,8 @@ * `appSearchSource`. */ -import { - uniqueId, - uniq, - extend, - pick, - difference, - omit, - setWith, - isObject, - keys, - isFunction, -} from 'lodash'; +import { setWith } from '@elastic/safer-lodash-set'; +import { uniqueId, uniq, extend, pick, difference, omit, isObject, keys, isFunction } from 'lodash'; import { map } from 'rxjs/operators'; import { CoreStart } from 'kibana/public'; import { normalizeSortRequest } from './normalize_sort_request'; diff --git a/src/plugins/discover/public/application/angular/context/api/context.predecessors.test.js b/src/plugins/discover/public/application/angular/context/api/context.predecessors.test.js index fcde2ade0b2c6d..4987c77f4bf256 100644 --- a/src/plugins/discover/public/application/angular/context/api/context.predecessors.test.js +++ b/src/plugins/discover/public/application/angular/context/api/context.predecessors.test.js @@ -18,7 +18,7 @@ */ import moment from 'moment'; -import * as _ from 'lodash'; +import { get, last } from 'lodash'; import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs'; import { fetchContextProvider } from './context'; import { setServices } from '../../../../kibana_services'; @@ -124,9 +124,7 @@ describe('context app', function () { ).then((hits) => { const intervals = mockSearchSource.setField.args .filter(([property]) => property === 'query') - .map(([, { query }]) => - _.get(query, ['constant_score', 'filter', 'range', '@timestamp']) - ); + .map(([, { query }]) => get(query, ['constant_score', 'filter', 'range', '@timestamp'])); expect( intervals.every(({ gte, lte }) => (gte && lte ? moment(gte).isBefore(lte) : true)) @@ -134,7 +132,7 @@ describe('context app', function () { // should have started at the given time expect(intervals[0].gte).toEqual(moment(MS_PER_DAY * 3000).toISOString()); // should have ended with a half-open interval - expect(Object.keys(_.last(intervals))).toEqual(['format', 'gte']); + expect(Object.keys(last(intervals))).toEqual(['format', 'gte']); expect(intervals.length).toBeGreaterThan(1); expect(hits).toEqual(mockSearchSource._stubHits.slice(0, 3)); @@ -162,14 +160,12 @@ describe('context app', function () { ).then((hits) => { const intervals = mockSearchSource.setField.args .filter(([property]) => property === 'query') - .map(([, { query }]) => - _.get(query, ['constant_score', 'filter', 'range', '@timestamp']) - ); + .map(([, { query }]) => get(query, ['constant_score', 'filter', 'range', '@timestamp'])); // should have started at the given time expect(intervals[0].gte).toEqual(moment(MS_PER_DAY * 1000).toISOString()); // should have stopped before reaching MS_PER_DAY * 1700 - expect(moment(_.last(intervals).lte).valueOf()).toBeLessThan(MS_PER_DAY * 1700); + expect(moment(last(intervals).lte).valueOf()).toBeLessThan(MS_PER_DAY * 1700); expect(intervals.length).toBeGreaterThan(1); expect(hits).toEqual(mockSearchSource._stubHits.slice(-3)); }); diff --git a/src/plugins/discover/public/application/angular/context/api/context.successors.test.js b/src/plugins/discover/public/application/angular/context/api/context.successors.test.js index 0f84aa82a989a6..ebf6e78585962d 100644 --- a/src/plugins/discover/public/application/angular/context/api/context.successors.test.js +++ b/src/plugins/discover/public/application/angular/context/api/context.successors.test.js @@ -18,7 +18,7 @@ */ import moment from 'moment'; -import * as _ from 'lodash'; +import { get, last } from 'lodash'; import { createIndexPatternsStub, createContextSearchSourceStub } from './_stubs'; import { setServices } from '../../../../kibana_services'; @@ -125,9 +125,7 @@ describe('context app', function () { ).then((hits) => { const intervals = mockSearchSource.setField.args .filter(([property]) => property === 'query') - .map(([, { query }]) => - _.get(query, ['constant_score', 'filter', 'range', '@timestamp']) - ); + .map(([, { query }]) => get(query, ['constant_score', 'filter', 'range', '@timestamp'])); expect( intervals.every(({ gte, lte }) => (gte && lte ? moment(gte).isBefore(lte) : true)) @@ -135,7 +133,7 @@ describe('context app', function () { // should have started at the given time expect(intervals[0].lte).toEqual(moment(MS_PER_DAY * 3000).toISOString()); // should have ended with a half-open interval - expect(Object.keys(_.last(intervals))).toEqual(['format', 'lte']); + expect(Object.keys(last(intervals))).toEqual(['format', 'lte']); expect(intervals.length).toBeGreaterThan(1); expect(hits).toEqual(mockSearchSource._stubHits.slice(-3)); @@ -165,14 +163,12 @@ describe('context app', function () { ).then((hits) => { const intervals = mockSearchSource.setField.args .filter(([property]) => property === 'query') - .map(([, { query }]) => - _.get(query, ['constant_score', 'filter', 'range', '@timestamp']) - ); + .map(([, { query }]) => get(query, ['constant_score', 'filter', 'range', '@timestamp'])); // should have started at the given time expect(intervals[0].lte).toEqual(moment(MS_PER_DAY * 3000).toISOString()); // should have stopped before reaching MS_PER_DAY * 2200 - expect(moment(_.last(intervals).gte).valueOf()).toBeGreaterThan(MS_PER_DAY * 2200); + expect(moment(last(intervals).gte).valueOf()).toBeGreaterThan(MS_PER_DAY * 2200); expect(intervals.length).toBeGreaterThan(1); expect(hits).toEqual(mockSearchSource._stubHits.slice(0, 4)); diff --git a/src/plugins/es_ui_shared/public/console_lang/ace/modes/lexer_rules/x_json_highlight_rules.ts b/src/plugins/es_ui_shared/public/console_lang/ace/modes/lexer_rules/x_json_highlight_rules.ts index 951cf5fa279b5b..138284b5fece02 100644 --- a/src/plugins/es_ui_shared/public/console_lang/ace/modes/lexer_rules/x_json_highlight_rules.ts +++ b/src/plugins/es_ui_shared/public/console_lang/ace/modes/lexer_rules/x_json_highlight_rules.ts @@ -17,7 +17,7 @@ * under the License. */ -import * as _ from 'lodash'; +import { defaultsDeep } from 'lodash'; import ace from 'brace'; import 'brace/mode/json'; @@ -176,7 +176,7 @@ export function XJsonHighlightRules(this: any) { oop.inherits(XJsonHighlightRules, JsonHighlightRules); export function addToRules(otherRules: any, embedUnder: any) { - otherRules.$rules = _.defaultsDeep(otherRules.$rules, jsonRules(embedUnder)); + otherRules.$rules = defaultsDeep(otherRules.$rules, jsonRules(embedUnder)); otherRules.embedRules(ScriptHighlightRules, 'script-', [ { token: 'punctuation.end_triple_quote', diff --git a/src/plugins/es_ui_shared/static/forms/hook_form_lib/lib/utils.ts b/src/plugins/es_ui_shared/static/forms/hook_form_lib/lib/utils.ts index 65cd7792a0189e..7d506e28794fd9 100644 --- a/src/plugins/es_ui_shared/static/forms/hook_form_lib/lib/utils.ts +++ b/src/plugins/es_ui_shared/static/forms/hook_form_lib/lib/utils.ts @@ -17,7 +17,7 @@ * under the License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { FieldHook } from '../types'; export const unflattenObject = (object: any) => diff --git a/src/plugins/kibana_legacy/public/angular/angular_config.tsx b/src/plugins/kibana_legacy/public/angular/angular_config.tsx index 25cbb0631a652c..eafcbfda3db003 100644 --- a/src/plugins/kibana_legacy/public/angular/angular_config.tsx +++ b/src/plugins/kibana_legacy/public/angular/angular_config.tsx @@ -26,7 +26,8 @@ import { IRootScopeService, } from 'angular'; import $ from 'jquery'; -import { cloneDeep, forOwn, get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { cloneDeep, forOwn, get } from 'lodash'; import * as Rx from 'rxjs'; import { ChromeBreadcrumb, EnvironmentMode, PackageInfo } from 'kibana/public'; import { History } from 'history'; diff --git a/src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx b/src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx index d273ffb4c1052c..adf54297c3133b 100644 --- a/src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx +++ b/src/plugins/saved_objects_management/public/management_section/object_view/components/form.tsx @@ -26,7 +26,8 @@ import { EuiButtonEmpty, EuiSpacer, } from '@elastic/eui'; -import { cloneDeep, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { cloneDeep } from 'lodash'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { SimpleSavedObject, SavedObjectsClientContract } from '../../../../../../core/public'; diff --git a/src/plugins/vis_type_timeseries/public/application/components/lib/convert_series_to_vars.js b/src/plugins/vis_type_timeseries/public/application/components/lib/convert_series_to_vars.js index 4d48095898b80e..f969778bbc6159 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/lib/convert_series_to_vars.js +++ b/src/plugins/vis_type_timeseries/public/application/components/lib/convert_series_to_vars.js @@ -17,6 +17,7 @@ * under the License. */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import { getLastValue } from '../../../../../../plugins/vis_type_timeseries/common/get_last_value'; import { createTickFormatter } from './tick_formatter'; @@ -51,8 +52,8 @@ export const convertSeriesToVars = (series, model, dateFormat = 'lll', getConfig }), }, }; - _.set(variables, varName, data); - _.set(variables, `${_.snakeCase(row.label)}.label`, row.label); + set(variables, varName, data); + set(variables, `${_.snakeCase(row.label)}.label`, row.label); }); }); return variables; diff --git a/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.js index 0e4d2ce2a926ca..f033a43806312e 100644 --- a/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/bucket_transform.js @@ -19,7 +19,8 @@ import { getBucketsPath } from './get_buckets_path'; import { parseInterval } from './parse_interval'; -import { set, isEmpty } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { isEmpty } from 'lodash'; import { i18n } from '@kbn/i18n'; import { MODEL_SCRIPTS } from './moving_fn_scripts'; diff --git a/src/plugins/vis_type_vislib/public/vislib/lib/axis/axis_config.js b/src/plugins/vis_type_vislib/public/vislib/lib/axis/axis_config.js index faf270877217ba..1861fa621ecd1d 100644 --- a/src/plugins/vis_type_vislib/public/vislib/lib/axis/axis_config.js +++ b/src/plugins/vis_type_vislib/public/vislib/lib/axis/axis_config.js @@ -17,6 +17,7 @@ * under the License. */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import d3 from 'd3'; import { SCALE_MODES } from './scale_modes'; @@ -220,7 +221,7 @@ export class AxisConfig { } set(property, value) { - return _.set(this._values, property, value); + return set(this._values, property, value); } isHorizontal() { diff --git a/src/plugins/vis_type_vislib/public/vislib/lib/chart_grid.js b/src/plugins/vis_type_vislib/public/vislib/lib/chart_grid.js index aac019a98e7907..0cd0c8391995bb 100644 --- a/src/plugins/vis_type_vislib/public/vislib/lib/chart_grid.js +++ b/src/plugins/vis_type_vislib/public/vislib/lib/chart_grid.js @@ -18,6 +18,7 @@ */ import d3 from 'd3'; +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; const defaults = { @@ -102,6 +103,6 @@ export class ChartGrid { } set(property, value) { - return _.set(this._values, property, value); + return set(this._values, property, value); } } diff --git a/src/plugins/vis_type_vislib/public/vislib/lib/vis_config.js b/src/plugins/vis_type_vislib/public/vislib/lib/vis_config.js index 03547247032082..6490dfe252b292 100644 --- a/src/plugins/vis_type_vislib/public/vislib/lib/vis_config.js +++ b/src/plugins/vis_type_vislib/public/vislib/lib/vis_config.js @@ -20,6 +20,7 @@ /** * Provides vislib configuration, throws error if invalid property is accessed without providing defaults */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import { vislibTypesConfig as visTypes } from './types'; import { Data } from './data'; @@ -54,6 +55,6 @@ export class VisConfig { } set(property, value) { - return _.set(this._values, property, value); + return set(this._values, property, value); } } diff --git a/src/plugins/visualizations/public/legacy/vis_update_state.js b/src/plugins/visualizations/public/legacy/vis_update_state.js index edaf388e210606..8d80db4e4be1dc 100644 --- a/src/plugins/visualizations/public/legacy/vis_update_state.js +++ b/src/plugins/visualizations/public/legacy/vis_update_state.js @@ -17,6 +17,7 @@ * under the License. */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; /** @@ -31,7 +32,7 @@ function convertHeatmapLabelColor(visState) { if (visState.type === 'heatmap' && visState.params && !hasOverwriteColorParam) { const showLabels = _.get(visState, 'params.valueAxes[0].labels.show', false); const color = _.get(visState, 'params.valueAxes[0].labels.color', '#555'); - _.set(visState, 'params.valueAxes[0].labels.overwriteColor', showLabels && color !== '#555'); + set(visState, 'params.valueAxes[0].labels.overwriteColor', showLabels && color !== '#555'); } } @@ -167,7 +168,7 @@ export const updateOldState = (visState) => { if (visState.type === 'gauge' && visState.fontSize) { delete newState.fontSize; - _.set(newState, 'gauge.style.fontSize', visState.fontSize); + set(newState, 'gauge.style.fontSize', visState.fontSize); } // update old metric to the new one diff --git a/src/plugins/visualizations/public/persisted_state/persisted_state.ts b/src/plugins/visualizations/public/persisted_state/persisted_state.ts index c926c456da2190..3799a5b03ce461 100644 --- a/src/plugins/visualizations/public/persisted_state/persisted_state.ts +++ b/src/plugins/visualizations/public/persisted_state/persisted_state.ts @@ -19,17 +19,8 @@ import { EventEmitter } from 'events'; -import { - isPlainObject, - cloneDeep, - get, - set, - isEqual, - isString, - merge, - mergeWith, - toPath, -} from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { isPlainObject, cloneDeep, get, isEqual, isString, merge, mergeWith, toPath } from 'lodash'; function prepSetParams(key: PersistedStateKey, value: any, path: PersistedStatePath) { // key must be the value, set the entire state using it diff --git a/tasks/config/run.js b/tasks/config/run.js index 32adf4f1f87c22..98a1226834bc69 100644 --- a/tasks/config/run.js +++ b/tasks/config/run.js @@ -223,6 +223,12 @@ module.exports = function (grunt) { args: ['scripts/test_hardening.js'], }), + test_package_safer_lodash_set: scriptWithGithubChecks({ + title: '@elastic/safer-lodash-set tests', + cmd: YARN, + args: ['--cwd', 'packages/elastic-safer-lodash-set', 'test'], + }), + apiIntegrationTests: scriptWithGithubChecks({ title: 'API integration tests', cmd: NODE, diff --git a/tasks/jenkins.js b/tasks/jenkins.js index b40bb8156098d3..eece5df61a7d10 100644 --- a/tasks/jenkins.js +++ b/tasks/jenkins.js @@ -39,6 +39,7 @@ module.exports = function (grunt) { 'run:test_projects', 'run:test_karma_ci', 'run:test_hardening', + 'run:test_package_safer_lodash_set', 'run:apiIntegrationTests', ]); }; diff --git a/test/api_integration/apis/saved_objects/migrations.js b/test/api_integration/apis/saved_objects/migrations.js index 9ea3cf087be909..ed259ccec0114c 100644 --- a/test/api_integration/apis/saved_objects/migrations.js +++ b/test/api_integration/apis/saved_objects/migrations.js @@ -21,6 +21,7 @@ * Smokescreen tests for core migration logic */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; import { assert } from 'chai'; import { @@ -56,12 +57,12 @@ export default ({ getService }) => { const migrations = { foo: { - '1.0.0': (doc) => _.set(doc, 'attributes.name', doc.attributes.name.toUpperCase()), + '1.0.0': (doc) => set(doc, 'attributes.name', doc.attributes.name.toUpperCase()), }, bar: { - '1.0.0': (doc) => _.set(doc, 'attributes.nomnom', doc.attributes.nomnom + 1), - '1.3.0': (doc) => _.set(doc, 'attributes', { mynum: doc.attributes.nomnom }), - '1.9.0': (doc) => _.set(doc, 'attributes.mynum', doc.attributes.mynum * 2), + '1.0.0': (doc) => set(doc, 'attributes.nomnom', doc.attributes.nomnom + 1), + '1.3.0': (doc) => set(doc, 'attributes', { mynum: doc.attributes.nomnom }), + '1.9.0': (doc) => set(doc, 'attributes.mynum', doc.attributes.mynum * 2), }, }; @@ -172,12 +173,12 @@ export default ({ getService }) => { const migrations = { foo: { - '1.0.0': (doc) => _.set(doc, 'attributes.name', doc.attributes.name.toUpperCase()), + '1.0.0': (doc) => set(doc, 'attributes.name', doc.attributes.name.toUpperCase()), }, bar: { - '1.0.0': (doc) => _.set(doc, 'attributes.nomnom', doc.attributes.nomnom + 1), - '1.3.0': (doc) => _.set(doc, 'attributes', { mynum: doc.attributes.nomnom }), - '1.9.0': (doc) => _.set(doc, 'attributes.mynum', doc.attributes.mynum * 2), + '1.0.0': (doc) => set(doc, 'attributes.nomnom', doc.attributes.nomnom + 1), + '1.3.0': (doc) => set(doc, 'attributes', { mynum: doc.attributes.nomnom }), + '1.9.0': (doc) => set(doc, 'attributes.mynum', doc.attributes.mynum * 2), }, }; @@ -187,8 +188,8 @@ export default ({ getService }) => { await migrateIndex({ callCluster, index, migrations, mappingProperties }); mappingProperties.bar.properties.name = { type: 'keyword' }; - migrations.foo['2.0.1'] = (doc) => _.set(doc, 'attributes.name', `${doc.attributes.name}v2`); - migrations.bar['2.3.4'] = (doc) => _.set(doc, 'attributes.name', `NAME ${doc.id}`); + migrations.foo['2.0.1'] = (doc) => set(doc, 'attributes.name', `${doc.attributes.name}v2`); + migrations.bar['2.3.4'] = (doc) => set(doc, 'attributes.name', `NAME ${doc.id}`); await migrateIndex({ callCluster, index, migrations, mappingProperties }); @@ -267,7 +268,7 @@ export default ({ getService }) => { const migrations = { foo: { - '1.0.0': (doc) => _.set(doc, 'attributes.name', 'LOTR'), + '1.0.0': (doc) => set(doc, 'attributes.name', 'LOTR'), }, }; diff --git a/x-pack/legacy/server/lib/check_license/check_license.test.js b/x-pack/legacy/server/lib/check_license/check_license.test.js index 0545e1a2d16f4c..65b599ed4a5f6c 100644 --- a/x-pack/legacy/server/lib/check_license/check_license.test.js +++ b/x-pack/legacy/server/lib/check_license/check_license.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { checkLicense } from './check_license'; import { LICENSE_STATUS_UNAVAILABLE, diff --git a/x-pack/legacy/server/lib/create_router/is_es_error_factory/__tests__/is_es_error_factory.js b/x-pack/legacy/server/lib/create_router/is_es_error_factory/__tests__/is_es_error_factory.js index 5f2141cce93954..ef6fbaf9c53d03 100644 --- a/x-pack/legacy/server/lib/create_router/is_es_error_factory/__tests__/is_es_error_factory.js +++ b/x-pack/legacy/server/lib/create_router/is_es_error_factory/__tests__/is_es_error_factory.js @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; import { isEsErrorFactory } from '../is_es_error_factory'; -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; class MockAbstractEsError {} diff --git a/x-pack/legacy/server/lib/parse_kibana_state.js b/x-pack/legacy/server/lib/parse_kibana_state.js index 7e81cb2736fc34..a6c9bfbb511c17 100644 --- a/x-pack/legacy/server/lib/parse_kibana_state.js +++ b/x-pack/legacy/server/lib/parse_kibana_state.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { isPlainObject, omit, get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { isPlainObject, omit, get } from 'lodash'; import rison from 'rison-node'; const stateTypeKeys = { diff --git a/x-pack/package.json b/x-pack/package.json index 29264f8920e5d8..6715fa132c1b5f 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -201,6 +201,7 @@ "@elastic/maki": "6.3.0", "@elastic/node-crypto": "1.2.1", "@elastic/numeral": "^2.5.0", + "@elastic/safer-lodash-set": "0.0.0", "@kbn/babel-preset": "1.0.0", "@kbn/config-schema": "1.0.0", "@kbn/i18n": "1.0.0", diff --git a/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts b/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts index 6bc370be903df9..28b095335e93d8 100644 --- a/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts +++ b/x-pack/plugins/apm/scripts/aggregate-latency-metrics/index.ts @@ -9,7 +9,8 @@ import { argv } from 'yargs'; import pLimit from 'p-limit'; import pRetry from 'p-retry'; import { parse, format } from 'url'; -import { unique, without, set, merge, flatten } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { unique, without, merge, flatten } from 'lodash'; import * as histogram from 'hdr-histogram-js'; import { ESSearchResponse } from '../../typings/elasticsearch'; import { diff --git a/x-pack/plugins/beats_management/public/lib/configuration_blocks.ts b/x-pack/plugins/beats_management/public/lib/configuration_blocks.ts index 5579c70e15017f..b486ba82689e81 100644 --- a/x-pack/plugins/beats_management/public/lib/configuration_blocks.ts +++ b/x-pack/plugins/beats_management/public/lib/configuration_blocks.ts @@ -5,7 +5,8 @@ */ import yaml from 'js-yaml'; -import { get, has, omit, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get, has, omit } from 'lodash'; import { ConfigBlockSchema, ConfigurationBlock, diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/index.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/index.ts index 4ffd2ff3e0c968..9dc7ee8da6d73b 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/index.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/index.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { groupBy, get, keyBy, set, map, sortBy } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { groupBy, get, keyBy, map, sortBy } from 'lodash'; import { ExpressionFunctionDefinition, Style } from 'src/plugins/expressions'; // @ts-expect-error untyped local import { getColorsFromPalette } from '../../../../common/lib/get_colors_from_palette'; diff --git a/x-pack/plugins/canvas/public/components/asset_manager/index.ts b/x-pack/plugins/canvas/public/components/asset_manager/index.ts index b07857f13f6c6e..9b4406f607867d 100644 --- a/x-pack/plugins/canvas/public/components/asset_manager/index.ts +++ b/x-pack/plugins/canvas/public/components/asset_manager/index.ts @@ -6,7 +6,8 @@ import { connect } from 'react-redux'; import { compose, withProps } from 'recompose'; -import { set, get } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get } from 'lodash'; import { fromExpression, toExpression } from '@kbn/interpreter/common'; import { getAssets } from '../../state/selectors/assets'; // @ts-expect-error untyped local diff --git a/x-pack/plugins/canvas/public/expression_types/arg_types/font.js b/x-pack/plugins/canvas/public/expression_types/arg_types/font.js index 3e88d60b40d5f5..5d0e6b3dd688e4 100644 --- a/x-pack/plugins/canvas/public/expression_types/arg_types/font.js +++ b/x-pack/plugins/canvas/public/expression_types/arg_types/font.js @@ -6,7 +6,8 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { get, mapValues, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get, mapValues } from 'lodash'; import { openSans } from '../../../common/lib/fonts'; import { templateFromReactComponent } from '../../lib/template_from_react_component'; import { TextStylePicker } from '../../components/text_style_picker'; diff --git a/x-pack/plugins/event_log/scripts/create_schemas.js b/x-pack/plugins/event_log/scripts/create_schemas.js index 2432a27e5c70d2..709096393471f9 100755 --- a/x-pack/plugins/event_log/scripts/create_schemas.js +++ b/x-pack/plugins/event_log/scripts/create_schemas.js @@ -8,6 +8,7 @@ const fs = require('fs'); const path = require('path'); +const { set } = require('@elastic/safer-lodash-set'); const lodash = require('lodash'); const LineWriter = require('./lib/line_writer'); @@ -49,7 +50,7 @@ function getEventLogMappings(ecsSchema, exportedProperties) { // copy the leaf values of the properties for (const prop of leafProperties) { const value = lodash.get(ecsSchema.mappings.properties, prop); - lodash.set(result.mappings.properties, prop, value); + set(result.mappings.properties, prop, value); } // set the non-leaf values as appropriate @@ -118,7 +119,7 @@ function augmentMappings(mappings, multiValuedProperties) { const metaPropName = `${fullProp}.meta`; const meta = lodash.get(mappings.properties, metaPropName) || {}; meta.isArray = 'true'; - lodash.set(mappings.properties, metaPropName, meta); + set(mappings.properties, metaPropName, meta); } } diff --git a/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx b/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx index 22f7d3d3cd50a1..35fb66b2620d60 100644 --- a/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx +++ b/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set, values } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { values } from 'lodash'; import React, { useContext, useMemo } from 'react'; import * as t from 'io-ts'; import { ThrowReporter } from 'io-ts/lib/ThrowReporter'; diff --git a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts index a81e11418cd6ae..3afc0d050e7364 100644 --- a/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts @@ -6,7 +6,7 @@ import { encode } from 'rison-node'; import uuid from 'uuid'; -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { colorTransformer, MetricsExplorerColor } from '../../../../../../common/color_palette'; import { MetricsExplorerSeries } from '../../../../../../common/http_api/metrics_explorer'; import { diff --git a/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts index 8a21a97631fbbb..d0f0bd18b5d56c 100644 --- a/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts +++ b/x-pack/plugins/infra/server/routes/metadata/lib/get_node_info.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { first, set, startsWith } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { first, startsWith } from 'lodash'; import { RequestHandlerContext } from 'src/core/server'; import { KibanaFramework } from '../../../lib/adapters/framework/kibana_framework_adapter'; import { InfraSourceConfiguration } from '../../../lib/sources'; diff --git a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts index f4f877c188d0d9..fdecb5f3d93153 100644 --- a/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts +++ b/x-pack/plugins/infra/server/routes/metrics_explorer/lib/get_groupings.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { isObject, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { isObject } from 'lodash'; import { i18n } from '@kbn/i18n'; import { InfraDatabaseSearchResponse } from '../../../lib/adapters/framework'; import { diff --git a/x-pack/plugins/infra/server/utils/create_afterkey_handler.ts b/x-pack/plugins/infra/server/utils/create_afterkey_handler.ts index 2b65c42410723d..cdfb9d7cc99f30 100644 --- a/x-pack/plugins/infra/server/utils/create_afterkey_handler.ts +++ b/x-pack/plugins/infra/server/utils/create_afterkey_handler.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { InfraDatabaseSearchResponse } from '../lib/adapters/framework'; export const createAfterKeyHandler = ( diff --git a/x-pack/plugins/monitoring/public/components/table/storage.js b/x-pack/plugins/monitoring/public/components/table/storage.js index 037839a2654c1a..1be8528d5ab232 100644 --- a/x-pack/plugins/monitoring/public/components/table/storage.js +++ b/x-pack/plugins/monitoring/public/components/table/storage.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get } from 'lodash'; import { STORAGE_KEY } from '../../../common/constants'; export const tableStorageGetter = (keyPrefix) => { diff --git a/x-pack/plugins/monitoring/public/lib/calculate_shard_stats.js b/x-pack/plugins/monitoring/public/lib/calculate_shard_stats.js index 83a79a30069f02..6aee89a9817d54 100644 --- a/x-pack/plugins/monitoring/public/lib/calculate_shard_stats.js +++ b/x-pack/plugins/monitoring/public/lib/calculate_shard_stats.js @@ -4,11 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ +import { set } from '@elastic/safer-lodash-set'; import _ from 'lodash'; function addOne(obj, key) { let value = _.get(obj, key); - _.set(obj, key, ++value); + set(obj, key, ++value); } export function calculateShardStats(state) { diff --git a/x-pack/plugins/monitoring/server/lib/__tests__/create_query.js b/x-pack/plugins/monitoring/server/lib/__tests__/create_query.js index 7d5661ccd7560e..e8862c47d4bf2c 100644 --- a/x-pack/plugins/monitoring/server/lib/__tests__/create_query.js +++ b/x-pack/plugins/monitoring/server/lib/__tests__/create_query.js @@ -5,7 +5,7 @@ */ import expect from '@kbn/expect'; -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { MissingRequiredError } from '../error_missing_required'; import { ElasticsearchMetric } from '../metrics'; import { createQuery } from '../create_query.js'; diff --git a/x-pack/plugins/monitoring/server/lib/cluster/__tests__/get_clusters_state.js b/x-pack/plugins/monitoring/server/lib/cluster/__tests__/get_clusters_state.js index d1bc3a0a7e3816..cc62e59986f1de 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/__tests__/get_clusters_state.js +++ b/x-pack/plugins/monitoring/server/lib/cluster/__tests__/get_clusters_state.js @@ -7,7 +7,7 @@ import { handleResponse } from '../get_clusters_state'; import expect from '@kbn/expect'; import moment from 'moment'; -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; const clusters = [ { diff --git a/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.js b/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.js index 03de24916a6db0..8e0d125d122aa0 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.js +++ b/x-pack/plugins/monitoring/server/lib/cluster/flag_supported_clusters.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { get, set, find } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get, find } from 'lodash'; import { checkParam } from '../error_missing_required'; import { STANDALONE_CLUSTER_CLUSTER_UUID } from '../../../common/constants'; diff --git a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js index 50a4df8a3ff57e..18db738bba38e6 100644 --- a/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js +++ b/x-pack/plugins/monitoring/server/lib/cluster/get_clusters_from_request.js @@ -5,7 +5,8 @@ */ import { notFound } from 'boom'; -import { set, findIndex } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { findIndex } from 'lodash'; import { getClustersStats } from './get_clusters_stats'; import { flagSupportedClusters } from './flag_supported_clusters'; import { getMlJobsForCluster } from '../elasticsearch'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/__tests__/get_ml_jobs.js b/x-pack/plugins/monitoring/server/lib/elasticsearch/__tests__/get_ml_jobs.js index 58fc2e30972e5a..c2cf19471ecb2e 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/__tests__/get_ml_jobs.js +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/__tests__/get_ml_jobs.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import expect from '@kbn/expect'; import { handleResponse } from '../get_ml_jobs'; diff --git a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/__tests__/calculate_node_type.js b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/__tests__/calculate_node_type.js index b9adcb725f0b8e..9b4f1d586a319a 100644 --- a/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/__tests__/calculate_node_type.js +++ b/x-pack/plugins/monitoring/server/lib/elasticsearch/nodes/__tests__/calculate_node_type.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import expect from '@kbn/expect'; import { calculateNodeType } from '../calculate_node_type.js'; diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/create_query.test.ts b/x-pack/plugins/monitoring/server/telemetry_collection/create_query.test.ts index a85d084f83d83b..ae5ae9320f0f41 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/create_query.test.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/create_query.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { createTypeFilter, createQuery } from './create_query'; describe('Create Type Filter', () => { diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_all_stats.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_all_stats.ts index 45fdf1997d2149..726db1706758d9 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_all_stats.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_all_stats.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { get, set, merge } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get, merge } from 'lodash'; import { StatsGetter } from 'src/plugins/telemetry_collection_manager/server'; import { LOGSTASH_SYSTEM_ID, KIBANA_SYSTEM_ID, BEATS_SYSTEM_ID } from '../../common/constants'; diff --git a/x-pack/plugins/reporting/server/browsers/network_policy.ts b/x-pack/plugins/reporting/server/browsers/network_policy.ts index 158362cee3c7e9..77458a7d61e087 100644 --- a/x-pack/plugins/reporting/server/browsers/network_policy.ts +++ b/x-pack/plugins/reporting/server/browsers/network_policy.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import * as _ from 'lodash'; +import { every } from 'lodash'; import { parse } from 'url'; interface NetworkPolicyRule { @@ -22,7 +22,7 @@ const isHostMatch = (actualHost: string, ruleHost: string) => { const hostParts = actualHost.split('.').reverse(); const ruleParts = ruleHost.split('.').reverse(); - return _.every(ruleParts, (part, idx) => part === hostParts[idx]); + return every(ruleParts, (part, idx) => part === hostParts[idx]); }; export const allowRequest = (url: string, rules: NetworkPolicyRule[]) => { diff --git a/x-pack/plugins/reporting/server/export_types/common/validate_urls.ts b/x-pack/plugins/reporting/server/export_types/common/validate_urls.ts index 58e63a522e6096..651c6a0347c464 100644 --- a/x-pack/plugins/reporting/server/export_types/common/validate_urls.ts +++ b/x-pack/plugins/reporting/server/export_types/common/validate_urls.ts @@ -5,7 +5,7 @@ */ import { parse } from 'url'; -import * as _ from 'lodash'; +import { filter } from 'lodash'; /* * isBogusUrl @@ -21,7 +21,7 @@ const isBogusUrl = (url: string) => { }; export const validateUrls = (urls: string[]): void => { - const badUrls = _.filter(urls, (url) => isBogusUrl(url)); + const badUrls = filter(urls, (url) => isBogusUrl(url)); if (badUrls.length) { throw new Error(`Found invalid URL(s), all URLs must be relative: ${badUrls.join(' ')}`); diff --git a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/check_cells_for_formulas.ts b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/check_cells_for_formulas.ts index d89eb45ead75e3..83a73c53a0b604 100644 --- a/x-pack/plugins/reporting/server/export_types/csv/generate_csv/check_cells_for_formulas.ts +++ b/x-pack/plugins/reporting/server/export_types/csv/generate_csv/check_cells_for_formulas.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import * as _ from 'lodash'; +import { pick, keys, values, some } from 'lodash'; import { cellHasFormulas } from './cell_has_formula'; interface IFlattened { @@ -12,8 +12,8 @@ interface IFlattened { } export const checkIfRowsHaveFormulas = (flattened: IFlattened, fields: string[]) => { - const pruned = _.pick(flattened, fields); - const cells = [..._.keys(pruned), ...(_.values(pruned) as string[])]; + const pruned = pick(flattened, fields); + const cells = [...keys(pruned), ...(values(pruned) as string[])]; - return _.some(cells, (cell) => cellHasFormulas(cell)); + return some(cells, (cell) => cellHasFormulas(cell)); }; diff --git a/x-pack/plugins/reporting/server/routes/lib/get_document_payload.ts b/x-pack/plugins/reporting/server/routes/lib/get_document_payload.ts index 93f79bfd892b99..d384cbb878a0ed 100644 --- a/x-pack/plugins/reporting/server/routes/lib/get_document_payload.ts +++ b/x-pack/plugins/reporting/server/routes/lib/get_document_payload.ts @@ -6,7 +6,7 @@ // @ts-ignore import contentDisposition from 'content-disposition'; -import * as _ from 'lodash'; +import { get } from 'lodash'; import { CSV_JOB_TYPE } from '../../../common/constants'; import { statuses } from '../../lib/esqueue/constants/statuses'; import { ExportTypesRegistry } from '../../lib/export_types_registry'; @@ -35,8 +35,8 @@ const getReportingHeaders = (output: TaskRunResult, exportType: ExportTypeType) const metaDataHeaders: Record = {}; if (exportType.jobType === CSV_JOB_TYPE) { - const csvContainsFormulas = _.get(output, 'csv_contains_formulas', false); - const maxSizedReach = _.get(output, 'max_size_reached', false); + const csvContainsFormulas = get(output, 'csv_contains_formulas', false); + const maxSizedReach = get(output, 'max_size_reached', false); metaDataHeaders['kbn-csv-contains-formulas'] = csvContainsFormulas; metaDataHeaders['kbn-max-size-reached'] = maxSizedReach; diff --git a/x-pack/plugins/security_solution/public/cases/containers/utils.ts b/x-pack/plugins/security_solution/public/cases/containers/utils.ts index ef4e1ff05118b2..313c71375111cc 100644 --- a/x-pack/plugins/security_solution/public/cases/containers/utils.ts +++ b/x-pack/plugins/security_solution/public/cases/containers/utils.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { camelCase, isArray, isObject, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { camelCase, isArray, isObject } from 'lodash'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/json_view.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/json_view.tsx index 788ca95e2022ea..1b8177b2038ae5 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/json_view.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/json_view.tsx @@ -5,7 +5,7 @@ */ import { EuiCodeEditor } from '@elastic/eui'; -import { set } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; import React from 'react'; import styled from 'styled-components'; diff --git a/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx b/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx index a182102329f050..de60bca73cedf6 100644 --- a/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/search_bar/index.tsx @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getOr, set } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; +import { getOr } from 'lodash/fp'; import React, { memo, useEffect, useCallback, useMemo } from 'react'; import { connect, ConnectedProps } from 'react-redux'; import { Dispatch } from 'redux'; diff --git a/x-pack/plugins/security_solution/public/common/components/toasters/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/toasters/index.test.tsx index 35036ef4b16b57..d366da1df9fd3f 100644 --- a/x-pack/plugins/security_solution/public/common/components/toasters/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/toasters/index.test.tsx @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { cloneDeep, set } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; +import { cloneDeep } from 'lodash/fp'; import { mount } from 'enzyme'; import React, { useEffect } from 'react'; diff --git a/x-pack/plugins/security_solution/public/common/containers/source/index.tsx b/x-pack/plugins/security_solution/public/common/containers/source/index.tsx index 9b7dfe84277c6e..8c03ab7b9f5086 100644 --- a/x-pack/plugins/security_solution/public/common/containers/source/index.tsx +++ b/x-pack/plugins/security_solution/public/common/containers/source/index.tsx @@ -5,7 +5,8 @@ */ import { isUndefined } from 'lodash'; -import { get, keyBy, pick, set, isEmpty } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; +import { get, keyBy, pick, isEmpty } from 'lodash/fp'; import { useEffect, useMemo, useState } from 'react'; import memoizeOne from 'memoize-one'; import { IIndexPattern } from 'src/plugins/data/public'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/flyout/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/flyout/index.test.tsx index 50578ef0a8e42e..9f550f87068bee 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/flyout/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/flyout/index.test.tsx @@ -5,7 +5,7 @@ */ import { mount, shallow } from 'enzyme'; -import { set } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; import React from 'react'; import { ActionCreator } from 'typescript-fsa'; diff --git a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.ts b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.ts index 04aef6f07c60af..9899b38f445f97 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.ts @@ -7,7 +7,8 @@ /* eslint-disable complexity */ import ApolloClient from 'apollo-client'; -import { getOr, set, isEmpty } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; +import { getOr, isEmpty } from 'lodash/fp'; import { Action } from 'typescript-fsa'; import uuid from 'uuid'; import { Dispatch } from 'redux'; diff --git a/x-pack/plugins/security_solution/public/timelines/store/timeline/reducer.test.ts b/x-pack/plugins/security_solution/public/timelines/store/timeline/reducer.test.ts index 0197ccc7eec05a..55451882d96faf 100644 --- a/x-pack/plugins/security_solution/public/timelines/store/timeline/reducer.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/store/timeline/reducer.test.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { cloneDeep, set } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; +import { cloneDeep } from 'lodash/fp'; import { TimelineType, TimelineStatus } from '../../../../common/types/timeline'; diff --git a/x-pack/plugins/security_solution/server/lib/hosts/elasticsearch_adapter.ts b/x-pack/plugins/security_solution/server/lib/hosts/elasticsearch_adapter.ts index 796338e189d601..142d2a68faed0d 100644 --- a/x-pack/plugins/security_solution/server/lib/hosts/elasticsearch_adapter.ts +++ b/x-pack/plugins/security_solution/server/lib/hosts/elasticsearch_adapter.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { get, getOr, has, head, set } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; +import { get, getOr, has, head } from 'lodash/fp'; import { FirstLastSeenHost, diff --git a/x-pack/plugins/security_solution/server/lib/timeline/routes/utils/common.ts b/x-pack/plugins/security_solution/server/lib/timeline/routes/utils/common.ts index 6eefdb0bfc5eca..fc25f1a48194e2 100644 --- a/x-pack/plugins/security_solution/server/lib/timeline/routes/utils/common.ts +++ b/x-pack/plugins/security_solution/server/lib/timeline/routes/utils/common.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash/fp'; +import { set } from '@elastic/safer-lodash-set/fp'; import readline from 'readline'; import fs from 'fs'; import { Readable } from 'stream'; diff --git a/x-pack/plugins/snapshot_restore/server/test/helpers/router_mock.ts b/x-pack/plugins/snapshot_restore/server/test/helpers/router_mock.ts index 5f15d7ea08c549..b71dea96ec6627 100644 --- a/x-pack/plugins/snapshot_restore/server/test/helpers/router_mock.ts +++ b/x-pack/plugins/snapshot_restore/server/test/helpers/router_mock.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; type RequestHandler = (...params: any[]) => any; diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs.tsx index 77ee3448cd06de..146cebabbb3826 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs.tsx @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { findIndex, get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { findIndex, get } from 'lodash'; import React from 'react'; import { diff --git a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/button.tsx b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/button.tsx index d88abc9c9c9ea5..a20f4117f693d5 100644 --- a/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/button.tsx +++ b/x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/reindex/button.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import React, { Fragment, ReactNode } from 'react'; import { i18n } from '@kbn/i18n'; import { Subscription } from 'rxjs'; diff --git a/x-pack/plugins/uptime/server/lib/requests/__tests__/get_monitor_charts.test.ts b/x-pack/plugins/uptime/server/lib/requests/__tests__/get_monitor_charts.test.ts index 45be1df3e8d3bf..2ebe670bc43c1d 100644 --- a/x-pack/plugins/uptime/server/lib/requests/__tests__/get_monitor_charts.test.ts +++ b/x-pack/plugins/uptime/server/lib/requests/__tests__/get_monitor_charts.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import mockChartsData from './monitor_charts_mock.json'; import { getMonitorDurationChart } from '../get_monitor_duration'; import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../common/constants'; diff --git a/x-pack/plugins/uptime/server/lib/requests/__tests__/get_pings.test.ts b/x-pack/plugins/uptime/server/lib/requests/__tests__/get_pings.test.ts index fd890a30cf7428..a52bf86499396c 100644 --- a/x-pack/plugins/uptime/server/lib/requests/__tests__/get_pings.test.ts +++ b/x-pack/plugins/uptime/server/lib/requests/__tests__/get_pings.test.ts @@ -5,7 +5,7 @@ */ import { getPings } from '../get_pings'; -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../common/constants'; describe('getAll', () => { diff --git a/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts b/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts index 8bdf7faf380e86..6c229cf30e165f 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get } from 'lodash'; import { QueryContext } from './query_context'; /** diff --git a/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js index d9d02f4af882ef..1aeec518545a02 100644 --- a/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js +++ b/x-pack/plugins/watcher/common/lib/serialization/serialization_helpers/build_input.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; /* watch.input.search.request.indices diff --git a/x-pack/plugins/watcher/common/lib/serialization/serialize_json_watch.js b/x-pack/plugins/watcher/common/lib/serialization/serialize_json_watch.js index 70b00070447a4f..9b8ce90d7fa825 100644 --- a/x-pack/plugins/watcher/common/lib/serialization/serialize_json_watch.js +++ b/x-pack/plugins/watcher/common/lib/serialization/serialize_json_watch.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { WATCH_TYPES } from '../../constants'; export function serializeJsonWatch(name, json) { diff --git a/x-pack/plugins/watcher/common/models/action/action.js b/x-pack/plugins/watcher/common/models/action/action.js index 0375b6ebf5d475..78e3fa2fc2582e 100644 --- a/x-pack/plugins/watcher/common/models/action/action.js +++ b/x-pack/plugins/watcher/common/models/action/action.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { getActionType } from '../../lib/get_action_type'; import { ACTION_TYPES } from '../../constants'; import { LoggingAction } from './logging_action'; diff --git a/x-pack/plugins/watcher/public/application/models/action/action.js b/x-pack/plugins/watcher/public/application/models/action/action.js index 43874c9ee1dd1a..d2393e327e5ffe 100644 --- a/x-pack/plugins/watcher/public/application/models/action/action.js +++ b/x-pack/plugins/watcher/public/application/models/action/action.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get } from 'lodash'; import { ACTION_TYPES } from '../../../../common/constants'; import { EmailAction } from './email_action'; import { LoggingAction } from './logging_action'; diff --git a/x-pack/plugins/watcher/public/application/models/watch/watch.js b/x-pack/plugins/watcher/public/application/models/watch/watch.js index 934d1e338ed0c6..64ec8db37b1799 100644 --- a/x-pack/plugins/watcher/public/application/models/watch/watch.js +++ b/x-pack/plugins/watcher/public/application/models/watch/watch.js @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { get, set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; +import { get } from 'lodash'; import { WATCH_TYPES } from '../../../../common/constants'; import { JsonWatch } from './json_watch'; import { ThresholdWatch } from './threshold_watch'; diff --git a/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js index 1000b6369ae3c1..4a77324da18be9 100644 --- a/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js +++ b/x-pack/plugins/watcher/server/lib/fetch_all_from_scroll/__tests__/fetch_all_from_scroll.js @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import sinon from 'sinon'; import { fetchAllFromScroll } from '../fetch_all_from_scroll'; -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; describe('fetch_all_from_scroll', () => { let mockResponse; diff --git a/x-pack/plugins/watcher/server/models/watch/watch.js b/x-pack/plugins/watcher/server/models/watch/watch.js index febf9c20b07a65..4e7ecf7feae096 100644 --- a/x-pack/plugins/watcher/server/models/watch/watch.js +++ b/x-pack/plugins/watcher/server/models/watch/watch.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { set } from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { badRequest } from 'boom'; import { WATCH_TYPES } from '../../../common/constants'; import { JsonWatch } from './json_watch'; diff --git a/x-pack/test/functional/apps/maps/joins.js b/x-pack/test/functional/apps/maps/joins.js index 7534a1b09cc230..e447996a08dfe1 100644 --- a/x-pack/test/functional/apps/maps/joins.js +++ b/x-pack/test/functional/apps/maps/joins.js @@ -5,7 +5,7 @@ */ import expect from '@kbn/expect'; -import _ from 'lodash'; +import { set } from '@elastic/safer-lodash-set'; import { MAPBOX_STYLES } from './mapbox_styles'; @@ -99,7 +99,7 @@ export default function ({ getPageObjects, getService }) { //circle layer for points expect(layersForVectorSource[CIRCLE_STYLE_LAYER_INDEX]).to.eql( - _.set(MAPBOX_STYLES.POINT_LAYER, 'paint.circle-stroke-color', dynamicColor) + set(MAPBOX_STYLES.POINT_LAYER, 'paint.circle-stroke-color', dynamicColor) ); //fill layer @@ -107,7 +107,7 @@ export default function ({ getPageObjects, getService }) { //line layer for borders expect(layersForVectorSource[LINE_STYLE_LAYER_INDEX]).to.eql( - _.set(MAPBOX_STYLES.LINE_LAYER, 'paint.line-color', dynamicColor) + set(MAPBOX_STYLES.LINE_LAYER, 'paint.line-color', dynamicColor) ); }); diff --git a/yarn.lock b/yarn.lock index b8aa559bc1d40d..0f144078ff46fa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5420,6 +5420,11 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-2.0.29.tgz#5002e14f75e2d71e564281df0431c8c1b4a2a36a" integrity sha1-UALhT3Xi1x5WQoHfBDHIwbSio2o= +"@types/minimist@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" + integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= + "@types/minipass@*": version "2.2.0" resolved "https://registry.yarnpkg.com/@types/minipass/-/minipass-2.2.0.tgz#51ad404e8eb1fa961f75ec61205796807b6f9651" @@ -6605,7 +6610,7 @@ acorn-jsx@^5.1.0: resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.1.0.tgz#294adb71b57398b0680015f0a38c563ee1db5384" integrity sha512-tMUqwBWfLFbJbizRmEcWSLw6HnFzfdJs2sOJEOwwtVPMoH/0Ay+E703oZz78VSXZiiDcZrQ5XKjPIUQixhmgVw== -acorn-node@^1.3.0: +acorn-node@^1.3.0, acorn-node@^1.6.1: version "1.8.2" resolved "https://registry.yarnpkg.com/acorn-node/-/acorn-node-1.8.2.tgz#114c95d64539e53dede23de8b9d96df7c7ae2af8" integrity sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A== @@ -7870,6 +7875,13 @@ autoprefixer@^9.4.9, autoprefixer@^9.7.4: postcss "^7.0.26" postcss-value-parser "^4.0.2" +available-typed-arrays@^1.0.0, available-typed-arrays@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz#6b098ca9d8039079ee3f77f7b783c4480ba513f5" + integrity sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ== + dependencies: + array-filter "^1.0.0" + await-event@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/await-event/-/await-event-2.1.0.tgz#78e9f92684bae4022f9fa0b5f314a11550f9aa76" @@ -9498,6 +9510,15 @@ camelcase-keys@^4.0.0: map-obj "^2.0.0" quick-lru "^1.0.0" +camelcase-keys@^6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0" + integrity sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg== + dependencies: + camelcase "^5.3.1" + map-obj "^4.0.0" + quick-lru "^4.0.1" + camelcase@5.0.0, camelcase@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.0.0.tgz#03295527d58bd3cd4aa75363f35b2e8d97be2f42" @@ -9528,6 +9549,11 @@ camelcase@^4.0.0, camelcase@^4.1.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= +camelcase@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.0.0.tgz#5259f7c30e35e278f1bdc2a4d91230b37cad981e" + integrity sha512-8KMDF1Vz2gzOq54ONPJS65IvTUaB1cHJ2DMM7MbPmLZljDH1qpzzLsWdiN9pHh6qvkRVDTi/07+eNGch/oLU4w== + camelize@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b" @@ -9686,7 +9712,7 @@ chalk@^3.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chalk@^4.1.0: +chalk@^4.0.0, chalk@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== @@ -11898,7 +11924,7 @@ debuglog@^1.0.1: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= -decamelize-keys@^1.0.0: +decamelize-keys@^1.0.0, decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" integrity sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk= @@ -12024,6 +12050,26 @@ deep-equal@^1.0.1, deep-equal@~1.0.1: resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" integrity sha1-9dJgKStmDghO/0zbyfCK0yR0SLU= +deep-equal@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.3.tgz#cad1c15277ad78a5c01c49c2dee0f54de8a6a7b0" + integrity sha512-Spqdl4H+ky45I9ByyJtXteOm9CaIrPmnIPmOhrkKGNYWeDgCvJ8jNYVCTjChxW4FqGuZnLHADc8EKRMX6+CgvA== + dependencies: + es-abstract "^1.17.5" + es-get-iterator "^1.1.0" + is-arguments "^1.0.4" + is-date-object "^1.0.2" + is-regex "^1.0.5" + isarray "^2.0.5" + object-is "^1.1.2" + object-keys "^1.1.1" + object.assign "^4.1.0" + regexp.prototype.flags "^1.3.0" + side-channel "^1.0.2" + which-boxed-primitive "^1.0.1" + which-collection "^1.0.1" + which-typed-array "^1.1.2" + deep-extend@^0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" @@ -12132,7 +12178,7 @@ define-property@^2.0.2: is-descriptor "^1.0.2" isobject "^3.0.1" -defined@~1.0.0: +defined@^1.0.0, defined@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" integrity sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM= @@ -12224,6 +12270,21 @@ depd@~1.1.1, depd@~1.1.2: resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= +dependency-check@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/dependency-check/-/dependency-check-4.1.0.tgz#d45405cabb50298f8674fe28ab594c8a5530edff" + integrity sha512-nlw+PvhVQwg0gSNNlVUiuRv0765gah9pZEXdQlIFzeSnD85Eex0uM0bkrAWrHdeTzuMGZnR9daxkup/AqqgqzA== + dependencies: + debug "^4.0.0" + detective "^5.0.2" + globby "^10.0.1" + is-relative "^1.0.0" + micromatch "^4.0.2" + minimist "^1.2.0" + pkg-up "^3.1.0" + read-package-json "^2.0.10" + resolve "^1.1.7" + dependency-tree@^7.0.2: version "7.0.2" resolved "https://registry.yarnpkg.com/dependency-tree/-/dependency-tree-7.0.2.tgz#01df8bbdc51e41438f5bb93f4a53e1a9cf8301a1" @@ -12391,6 +12452,15 @@ detective-typescript@^5.1.1: node-source-walk "^4.2.0" typescript "^3.4.5" +detective@^5.0.2: + version "5.2.0" + resolved "https://registry.yarnpkg.com/detective/-/detective-5.2.0.tgz#feb2a77e85b904ecdea459ad897cc90a99bd2a7b" + integrity sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg== + dependencies: + acorn-node "^1.6.1" + defined "^1.0.0" + minimist "^1.1.1" + dezalgo@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.3.tgz#7f742de066fc748bc8db820569dddce49bf0d456" @@ -12695,7 +12765,7 @@ dotenv@^8.1.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== -dotignore@~0.1.2: +dotignore@^0.1.2, dotignore@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/dotignore/-/dotignore-0.1.2.tgz#f942f2200d28c3a76fbdd6f0ee9f3257c8a2e905" integrity sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw== @@ -13299,6 +13369,36 @@ es-abstract@^1.15.0, es-abstract@^1.17.0-next.1: string.prototype.trimleft "^2.1.1" string.prototype.trimright "^2.1.1" +es-abstract@^1.17.4, es-abstract@^1.17.5: + version "1.17.6" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" + integrity sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.2.0" + is-regex "^1.1.0" + object-inspect "^1.7.0" + object-keys "^1.1.1" + object.assign "^4.1.0" + string.prototype.trimend "^1.0.1" + string.prototype.trimstart "^1.0.1" + +es-get-iterator@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.0.tgz#bb98ad9d6d63b31aacdc8f89d5d0ee57bcb5b4c8" + integrity sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ== + dependencies: + es-abstract "^1.17.4" + has-symbols "^1.0.1" + is-arguments "^1.0.4" + is-map "^2.0.1" + is-set "^2.0.1" + is-string "^1.0.5" + isarray "^2.0.5" + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -13522,6 +13622,19 @@ eslint-formatter-pretty@^1.3.0: plur "^2.1.2" string-width "^2.0.0" +eslint-formatter-pretty@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-formatter-pretty/-/eslint-formatter-pretty-4.0.0.tgz#dc15f3bf4fb51b7ba5fbedb77f57ba8841140ce2" + integrity sha512-QgdeZxQwWcN0TcXXNZJiS6BizhAANFhCzkE7Yl9HKB7WjElzwED6+FbbZB2gji8ofgJTGPqKm6VRCNT3OGCeEw== + dependencies: + ansi-escapes "^4.2.1" + chalk "^4.1.0" + eslint-rule-docs "^1.1.5" + log-symbols "^4.0.0" + plur "^4.0.0" + string-width "^4.2.0" + supports-hyperlinks "^2.0.0" + eslint-import-resolver-node@0.3.2, eslint-import-resolver-node@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a" @@ -13695,6 +13808,11 @@ eslint-rule-composer@^0.3.0: resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9" integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg== +eslint-rule-docs@^1.1.5: + version "1.1.199" + resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.199.tgz#f4e0befb6907101399624964ce4726f684415630" + integrity sha512-0jXhQ2JLavUsV/8HVFrBSHL4EM17cl0veZHAVcF1HOEoPdrr09huADK9/L7CbsqP4tMJy9FG23neUEDH8W/Mmg== + eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" @@ -15026,7 +15144,7 @@ for-each@^0.3.2: dependencies: is-function "~1.0.0" -for-each@~0.3.3: +for-each@^0.3.3, for-each@~0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" integrity sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw== @@ -15057,6 +15175,11 @@ for-own@^1.0.0: dependencies: for-in "^1.0.1" +foreach@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" + integrity sha1-C+4AUBiusmDQo6865ljdATbsG5k= + foreachasync@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/foreachasync/-/foreachasync-3.0.0.tgz#5502987dc8714be3392097f32e0071c9dee07cf6" @@ -16737,6 +16860,11 @@ har-validator@~5.1.0, har-validator@~5.1.3: ajv "^6.5.5" har-schema "^2.0.0" +hard-rejection@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883" + integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA== + has-ansi@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-0.1.0.tgz#84f265aae8c0e6a88a12d7022894b7568894c62e" @@ -17651,7 +17779,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4, inherits@~2.0.3, inherits@~2.0.4: +inherits@2, inherits@2.0.4, inherits@^2.0.4, inherits@~2.0.3, inherits@~2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -18014,6 +18142,11 @@ irregular-plurals@^1.0.0: resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-1.4.0.tgz#2ca9b033651111855412f16be5d77c62a458a766" integrity sha1-LKmwM2UREYVUEvFr5dd8YqRYp2Y= +irregular-plurals@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-3.2.0.tgz#b19c490a0723798db51b235d7e39add44dab0822" + integrity sha512-YqTdPLfwP7YFN0SsD3QUVCkm9ZG2VzOXv3DOrw5G5mkMbVwptTwVcFv7/C0vOpBmgTxAeTG19XpUs1E522LW9Q== + is-absolute-url@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/is-absolute-url/-/is-absolute-url-3.0.3.tgz#96c6a22b6a23929b11ea0afb1836c36ad4a5d698" @@ -18069,6 +18202,11 @@ is-arrayish@^0.3.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.1.tgz#c2dfc386abaa0c3e33c48db3fe87059e69065efd" integrity sha1-wt/DhquqDD4zxI2z/ocFnmkGXv0= +is-bigint@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.0.tgz#73da8c33208d00f130e9b5e15d23eac9215601c4" + integrity sha512-t5mGUXC/xRheCK431ylNiSkGGpBp8bHENBcENTkDT6ppwPzEVxNGZRvgvmOEfbWkFhA7D2GEuE2mmQTr78sl2g== + is-binary-path@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" @@ -18090,7 +18228,7 @@ is-binary-path@~2.1.0: dependencies: binary-extensions "^2.0.0" -is-boolean-object@^1.0.1: +is-boolean-object@^1.0.0, is-boolean-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.0.1.tgz#10edc0900dd127697a92f6f9807c7617d68ac48e" integrity sha512-TqZuVwa/sppcrhUCAYkGBk7w0yxfQQnxq28fjkO53tnK9FQXmdwz2JS5+GjsWQ6RByES1K40nI+yDic5c9/aAQ== @@ -18117,6 +18255,11 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.1.5: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== +is-callable@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb" + integrity sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw== + is-ci@2.0.0, is-ci@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" @@ -18150,6 +18293,11 @@ is-date-object@^1.0.1: resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" integrity sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY= +is-date-object@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" + integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g== + is-decimal@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-decimal/-/is-decimal-1.0.1.tgz#f5fb6a94996ad9e8e3761fbfbd091f1fca8c4e82" @@ -18332,6 +18480,11 @@ is-lower-case@^1.1.0: dependencies: lower-case "^1.1.0" +is-map@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1" + integrity sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw== + is-my-ip-valid@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" @@ -18381,7 +18534,7 @@ is-npm@^4.0.0: resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-4.0.0.tgz#c90dd8380696df87a7a6d823c20d0b12bbe3c84d" integrity sha512-96ECIfh9xtDDlPylNPXhzjsykHsMJZ18ASpaWzQyBr4YRTcVjUvzaHayDAES2oU/3KpljhHUjtSRNiDwi0F0ig== -is-number-object@^1.0.4: +is-number-object@^1.0.3, is-number-object@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197" integrity sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw== @@ -18521,6 +18674,13 @@ is-regex@^1.0.3, is-regex@^1.0.4, is-regex@^1.0.5, is-regex@~1.0.5: dependencies: has "^1.0.3" +is-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.0.tgz#ece38e389e490df0dc21caea2bd596f987f767ff" + integrity sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw== + dependencies: + has-symbols "^1.0.1" + is-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" @@ -18570,6 +18730,11 @@ is-secret@^1.0.0: resolved "https://registry.yarnpkg.com/is-secret/-/is-secret-1.2.1.tgz#04b9ca1880ea763049606cfe6c2a08a93f33abe3" integrity sha512-VtBantcgKL2a64fDeCmD1JlkHToh3v0bVOhyJZ5aGTjxtCgrdNcjaC9GaaRFXi19gA4/pYFpnuyoscIgQCFSMQ== +is-set@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.1.tgz#d1604afdab1724986d30091575f54945da7e5f43" + integrity sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA== + is-ssh@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/is-ssh/-/is-ssh-1.3.1.tgz#f349a8cadd24e65298037a522cf7520f2e81a0f3" @@ -18587,7 +18752,7 @@ is-stream@^2.0.0: resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3" integrity sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw== -is-string@^1.0.5: +is-string@^1.0.4, is-string@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== @@ -18609,6 +18774,16 @@ is-symbol@^1.0.2: dependencies: has-symbols "^1.0.0" +is-typed-array@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.3.tgz#a4ff5a5e672e1a55f99c7f54e59597af5c1df04d" + integrity sha512-BSYUBOK/HJibQ30wWkWold5txYwMUXQct9YHAQJr8fSwvZoiglcqB0pd7vEN23+Tsi9IUEjztdOSzl4qLVYGTQ== + dependencies: + available-typed-arrays "^1.0.0" + es-abstract "^1.17.4" + foreach "^2.0.5" + has-symbols "^1.0.1" + is-typedarray@^1.0.0, is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -18650,6 +18825,16 @@ is-valid-path@0.1.1, is-valid-path@^0.1.1: dependencies: is-invalid-path "^0.1.0" +is-weakmap@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.1.tgz#5008b59bdc43b698201d18f62b37b2ca243e8cf2" + integrity sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA== + +is-weakset@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-weakset/-/is-weakset-2.0.1.tgz#e9a0af88dbd751589f5e50d80f4c98b780884f83" + integrity sha512-pi4vhbhVHGLxohUw7PhGsueT4vRGFoXhP7+RGN0jKIv9+8PWYCQTqtADngrxOm2g46hoH0+g8uZZBzMrvVGDmw== + is-whitespace-character@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-whitespace-character/-/is-whitespace-character-1.0.1.tgz#9ae0176f3282b65457a1992cdb084f8a5f833e3b" @@ -18704,6 +18889,11 @@ isarray@2.0.1: resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" integrity sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4= +isarray@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" + integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== + isbinaryfile@4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.2.tgz#bfc45642da645681c610cca831022e30af426488" @@ -20122,7 +20312,7 @@ kind-of@^5.0.0, kind-of@^5.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== -kind-of@^6.0.0, kind-of@^6.0.2: +kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== @@ -20941,6 +21131,13 @@ log-symbols@^1.0.1, log-symbols@^1.0.2: dependencies: chalk "^1.0.0" +log-symbols@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920" + integrity sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA== + dependencies: + chalk "^4.0.0" + log-update@2.3.0, log-update@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/log-update/-/log-update-2.3.0.tgz#88328fd7d1ce7938b29283746f0b1bc126b24708" @@ -21224,6 +21421,11 @@ map-obj@^2.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" integrity sha1-plzSkIepJZi4eRJXpSPgISIqwfk= +map-obj@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.1.0.tgz#b91221b542734b9f14256c0132c897c5d7256fd5" + integrity sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g== + map-or-similar@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/map-or-similar/-/map-or-similar-1.5.0.tgz#6de2653174adfb5d9edc33c69d3e92a1b76faf08" @@ -21513,6 +21715,25 @@ meow@^5.0.0: trim-newlines "^2.0.0" yargs-parser "^10.0.0" +meow@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/meow/-/meow-7.0.1.tgz#1ed4a0a50b3844b451369c48362eb0515f04c1dc" + integrity sha512-tBKIQqVrAHqwit0vfuFPY3LlzJYkEOFyKa3bPgxzNl6q/RtN8KQ+ALYEASYuFayzSAsjlhXj/JZ10rH85Q6TUw== + dependencies: + "@types/minimist" "^1.2.0" + arrify "^2.0.1" + camelcase "^6.0.0" + camelcase-keys "^6.2.2" + decamelize-keys "^1.1.0" + hard-rejection "^2.1.0" + minimist-options "^4.0.2" + normalize-package-data "^2.5.0" + read-pkg-up "^7.0.1" + redent "^3.0.0" + trim-newlines "^3.0.0" + type-fest "^0.13.1" + yargs-parser "^18.1.3" + merge-deep@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/merge-deep/-/merge-deep-3.0.2.tgz#f39fa100a4f1bd34ff29f7d2bf4508fbb8d83ad2" @@ -21753,6 +21974,15 @@ minimist-options@^3.0.1: arrify "^1.0.1" is-plain-obj "^1.1.0" +minimist-options@^4.0.2: + version "4.1.0" + resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-4.1.0.tgz#c0655713c53a8a2ebd77ffa247d342c40f010619" + integrity sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A== + dependencies: + arrify "^1.0.1" + is-plain-obj "^1.1.0" + kind-of "^6.0.3" + minimist@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.5.tgz#d7aa327bcecf518f9106ac6b8f003fa3bcea8566" @@ -22821,7 +23051,7 @@ npm-keyword@^5.0.0: got "^7.1.0" registry-url "^3.0.3" -npm-normalize-package-bin@^1.0.1: +npm-normalize-package-bin@^1.0.0, npm-normalize-package-bin@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== @@ -23034,6 +23264,14 @@ object-is@^1.0.1, object-is@^1.0.2: resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.0.2.tgz#6b80eb84fe451498f65007982f035a5b445edec4" integrity sha512-Epah+btZd5wrrfjkJZq1AOB9O6OxUQto45hzFd7lXGrpHPGE0W1k+426yrZV+k6NJOzLNNW/nVsmZdIWsAqoOQ== +object-is@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.2.tgz#c5d2e87ff9e119f78b7a088441519e2eec1573b6" + integrity sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -24290,6 +24528,13 @@ plur@^2.1.2: dependencies: irregular-plurals "^1.0.0" +plur@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/plur/-/plur-4.0.0.tgz#729aedb08f452645fe8c58ef115bf16b0a73ef84" + integrity sha512-4UGewrYgqDFw9vV6zNV+ADmPAUAfJPKtGvb/VdpQAx25X5f3xXdGdyOEVFwkl8Hl/tl7+xbeHqSEM+D5/TirUg== + dependencies: + irregular-plurals "^3.2.0" + pluralize@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-3.1.0.tgz#84213d0a12356069daa84060c559242633161368" @@ -25125,6 +25370,11 @@ quick-lru@^1.0.0: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" integrity sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g= +quick-lru@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" + integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== + quickselect@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018" @@ -26106,6 +26356,18 @@ read-package-json@^2.0.0: optionalDependencies: graceful-fs "^4.1.2" +read-package-json@^2.0.10: + version "2.1.1" + resolved "https://registry.yarnpkg.com/read-package-json/-/read-package-json-2.1.1.tgz#16aa66c59e7d4dad6288f179dd9295fd59bb98f1" + integrity sha512-dAiqGtVc/q5doFz6096CcnXhpYk0ZN8dEKVkGLU0CsASt8SrgF6SF7OTKAYubfvFhWaqofl+Y8HK19GR8jwW+A== + dependencies: + glob "^7.1.1" + json-parse-better-errors "^1.0.1" + normalize-package-data "^2.0.0" + npm-normalize-package-bin "^1.0.0" + optionalDependencies: + graceful-fs "^4.1.2" + read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -26147,7 +26409,7 @@ read-pkg-up@^6.0.0: read-pkg "^5.1.1" type-fest "^0.5.0" -read-pkg-up@^7.0.1: +read-pkg-up@^7.0.0, read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" integrity sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg== @@ -26633,6 +26895,14 @@ regexp.prototype.flags@^1.2.0: dependencies: define-properties "^1.1.2" +regexp.prototype.flags@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz#7aba89b3c13a64509dabcf3ca8d9fbb9bdf5cb75" + integrity sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -27258,7 +27528,7 @@ restructure@^0.5.3: dependencies: browserify-optional "^1.0.0" -resumer@~0.0.0: +resumer@^0.0.0, resumer@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" integrity sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k= @@ -28190,6 +28460,14 @@ shot@4.x.x: hoek "5.x.x" joi "13.x.x" +side-channel@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.2.tgz#df5d1abadb4e4bf4af1cd8852bf132d2f7876947" + integrity sha512-7rL9YlPHg7Ancea1S96Pa8/QWb4BtXL/TZvS6B8XFetGBeuhAsfmUspK6DokBeZ64+Kj9TCNRD/30pVz1BvQNA== + dependencies: + es-abstract "^1.17.0-next.1" + object-inspect "^1.7.0" + signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" @@ -29111,6 +29389,14 @@ string.prototype.trim@~1.1.2: es-abstract "^1.5.0" function-bind "^1.0.2" +string.prototype.trimend@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" + integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + string.prototype.trimleft@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz#9bdb8ac6abd6d602b17a4ed321870d2f8dcefc74" @@ -29127,6 +29413,14 @@ string.prototype.trimright@^2.1.1: define-properties "^1.1.3" function-bind "^1.1.1" +string.prototype.trimstart@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" + integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + string_decoder@0.10, string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" @@ -29690,6 +29984,29 @@ tape@^4.5.1: string.prototype.trim "~1.1.2" through "~2.3.8" +tape@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/tape/-/tape-5.0.1.tgz#0d70ce90a586387c4efda4393e72872672a416a3" + integrity sha512-wVsOl2shKPcjdJdc8a+PwacvrOdJZJ57cLUXlxW4TQ2R6aihXwG0m0bKm4mA4wjtQNTaLMCrYNEb4f9fjHKUYQ== + dependencies: + deep-equal "^2.0.3" + defined "^1.0.0" + dotignore "^0.1.2" + for-each "^0.3.3" + function-bind "^1.1.1" + glob "^7.1.6" + has "^1.0.3" + inherits "^2.0.4" + is-regex "^1.0.5" + minimist "^1.2.5" + object-inspect "^1.7.0" + object-is "^1.1.2" + object.assign "^4.1.0" + resolve "^1.17.0" + resumer "^0.0.0" + string.prototype.trim "^1.2.1" + through "^2.3.8" + tar-fs@^1.16.3: version "1.16.3" resolved "https://registry.yarnpkg.com/tar-fs/-/tar-fs-1.16.3.tgz#966a628841da2c4010406a82167cbd5e0c72d509" @@ -29995,7 +30312,7 @@ through2@~2.0.3: readable-stream "~2.3.6" xtend "~4.0.1" -through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6, through@~2.3.4, through@~2.3.6, through@~2.3.8: +through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6, through@^2.3.8, through@~2.3.4, through@~2.3.6, through@~2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= @@ -30394,6 +30711,11 @@ trim-newlines@^2.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" integrity sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA= +trim-newlines@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.0.tgz#79726304a6a898aa8373427298d54c2ee8b1cb30" + integrity sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA== + trim-repeated@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-repeated/-/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21" @@ -30490,6 +30812,18 @@ ts-pnp@^1.1.2: resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.1.4.tgz#ae27126960ebaefb874c6d7fa4729729ab200d90" integrity sha512-1J/vefLC+BWSo+qe8OnJQfWTYRS6ingxjwqmHMqaMxXMj7kFtKLgAaYW3JeX3mktjgUL+etlU8/B4VUAUI9QGw== +tsd@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/tsd/-/tsd-0.13.1.tgz#d2a8baa80b8319dafea37fbeb29fef3cec86e92b" + integrity sha512-+UYM8LRG/M4H8ISTg2ow8SWi65PS7Os+4DUnyiQLbJysXBp2DEmws9SMgBH+m8zHcJZqUJQ+mtDWJXP1IAvB2A== + dependencies: + eslint-formatter-pretty "^4.0.0" + globby "^11.0.1" + meow "^7.0.1" + path-exists "^4.0.0" + read-pkg-up "^7.0.0" + update-notifier "^4.1.0" + tsd@^0.7.4: version "0.7.4" resolved "https://registry.yarnpkg.com/tsd/-/tsd-0.7.4.tgz#d9aba567f1394641821a6800dcee60746c87bd03" @@ -31022,6 +31356,11 @@ type-fest@^0.10.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.10.0.tgz#7f06b2b9fbfc581068d1341ffabd0349ceafc642" integrity sha512-EUV9jo4sffrwlg8s0zDhP0T2WD3pru5Xi0+HTE3zTUmBaZNhfkite9PdSJwdXLwPVW0jnAHT56pZHIOYckPEiw== +type-fest@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934" + integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg== + type-fest@^0.3.0, type-fest@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.3.1.tgz#63d00d204e059474fe5e1b7c011112bbd1dc29e1" @@ -31574,7 +31913,7 @@ update-notifier@^2.5.0: semver-diff "^2.0.0" xdg-basedir "^3.0.0" -update-notifier@^4.0.0: +update-notifier@^4.0.0, update-notifier@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.0.tgz#4866b98c3bc5b5473c020b1250583628f9a328f3" integrity sha512-w3doE1qtI0/ZmgeoDoARmI5fjDoT93IfKgEGqm26dGUOh8oNpaSTsGNdYRN/SjOuo10jcJGwkEL3mroKzktkew== @@ -32784,6 +33123,27 @@ whatwg-url@^7.0.0: tr46 "^1.0.1" webidl-conversions "^4.0.2" +which-boxed-primitive@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.1.tgz#cbe8f838ebe91ba2471bb69e9edbda67ab5a5ec1" + integrity sha512-7BT4TwISdDGBgaemWU0N0OU7FeAEJ9Oo2P1PHRm/FCWoEi2VLWC9b6xvxAA3C/NMpxg3HXVgi0sMmGbNUbNepQ== + dependencies: + is-bigint "^1.0.0" + is-boolean-object "^1.0.0" + is-number-object "^1.0.3" + is-string "^1.0.4" + is-symbol "^1.0.2" + +which-collection@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/which-collection/-/which-collection-1.0.1.tgz#70eab71ebbbd2aefaf32f917082fc62cdcb70906" + integrity sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A== + dependencies: + is-map "^2.0.1" + is-set "^2.0.1" + is-weakmap "^2.0.1" + is-weakset "^2.0.1" + which-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" @@ -32794,6 +33154,18 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= +which-typed-array@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.2.tgz#e5f98e56bda93e3dac196b01d47c1156679c00b2" + integrity sha512-KT6okrd1tE6JdZAy3o2VhMoYPh3+J6EMZLyrxBQsZflI1QCZIxMrIYLkosd8Twf+YfknVIHmYQPgJt238p8dnQ== + dependencies: + available-typed-arrays "^1.0.2" + es-abstract "^1.17.5" + foreach "^2.0.5" + function-bind "^1.1.1" + has-symbols "^1.0.1" + is-typed-array "^1.1.3" + which@1, which@1.3.1, which@^1.2.9, which@^1.3.1, which@~1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" @@ -33357,7 +33729,7 @@ yargs-parser@^11.1.1: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^18.1.1, yargs-parser@^18.1.2: +yargs-parser@^18.1.1, yargs-parser@^18.1.2, yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==