diff --git a/CHANGELOG.md b/CHANGELOG.md index 92f117e3a594..094455952569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -182,6 +182,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Remove the unused `renovate.json5` file ([3489](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3489)) - Allow selecting the Node.js binary using `NODE_HOME` and `OSD_NODE_HOME` ([3508](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3508)) - Bump `styled-components` from 5.3.5 to 5.3.9 ([#3678](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3678)) +- Bump `js-yaml` from 3.14.0 to 4.1.0 ([#3770](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3770)) - Bump `oui` from `1.0.0` to `1.1.1` ([#3884](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3884)) ### 🪛 Refactoring diff --git a/package.json b/package.json index b9eb244f7756..4bd9cd10f497 100644 --- a/package.json +++ b/package.json @@ -184,7 +184,7 @@ "inline-style": "^2.0.0", "ip-cidr": "^2.1.0", "joi": "^13.5.2", - "js-yaml": "^3.14.0", + "js-yaml": "^4.1.0", "json-stable-stringify": "^1.0.1", "json-stringify-safe": "5.0.1", "lodash": "^4.17.21", @@ -288,7 +288,7 @@ "@types/jest": "^27.4.0", "@types/joi": "^13.4.2", "@types/jquery": "^3.3.31", - "@types/js-yaml": "^3.11.1", + "@types/js-yaml": "^4.0.5", "@types/json-stable-stringify": "^1.0.32", "@types/json5": "^0.0.30", "@types/license-checker": "15.0.0", diff --git a/packages/osd-apm-config-loader/package.json b/packages/osd-apm-config-loader/package.json index c3c0249bd73e..fc06ff025e8a 100644 --- a/packages/osd-apm-config-loader/package.json +++ b/packages/osd-apm-config-loader/package.json @@ -13,7 +13,7 @@ "dependencies": { "@elastic/safer-lodash-set": "0.0.0", "@osd/utils": "1.0.0", - "js-yaml": "^3.14.0", + "js-yaml": "^4.1.0", "lodash": "^4.17.21" }, "devDependencies": { diff --git a/packages/osd-apm-config-loader/src/utils/read_config.ts b/packages/osd-apm-config-loader/src/utils/read_config.ts index 806a1ad2e92a..7076060cb04d 100644 --- a/packages/osd-apm-config-loader/src/utils/read_config.ts +++ b/packages/osd-apm-config-loader/src/utils/read_config.ts @@ -29,13 +29,13 @@ */ import { readFileSync } from 'fs'; -import { safeLoad } from 'js-yaml'; +import { load } from 'js-yaml'; 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')); +const readYaml = (path: string) => load(readFileSync(path, 'utf8')); function replaceEnvVarRefs(val: string) { return val.replace(/\$\{(\w+)\}/g, (match, envVarName) => { diff --git a/packages/osd-config/package.json b/packages/osd-config/package.json index 7d2f68abc8d8..f6d363c9c386 100644 --- a/packages/osd-config/package.json +++ b/packages/osd-config/package.json @@ -14,7 +14,7 @@ "@osd/config-schema": "1.0.0", "@osd/logging": "1.0.0", "@osd/std": "1.0.0", - "js-yaml": "^3.14.0", + "js-yaml": "^4.1.0", "load-json-file": "^6.2.0", "lodash": "^4.17.21", "moment": "^2.24.0", diff --git a/packages/osd-config/src/raw/read_config.ts b/packages/osd-config/src/raw/read_config.ts index 0c4a7c2330de..ad7820381eee 100644 --- a/packages/osd-config/src/raw/read_config.ts +++ b/packages/osd-config/src/raw/read_config.ts @@ -29,13 +29,13 @@ */ import { readFileSync } from 'fs'; -import { safeLoad } from 'js-yaml'; +import { load } from 'js-yaml'; 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')); +const readYaml = (path: string) => load(readFileSync(path, 'utf8')); function replaceEnvVarRefs(val: string) { return val.replace(/\$\{(\w+)\}/g, (match, envVarName) => { diff --git a/packages/osd-optimizer/package.json b/packages/osd-optimizer/package.json index 2aec5681ba91..5e82a7004fff 100644 --- a/packages/osd-optimizer/package.json +++ b/packages/osd-optimizer/package.json @@ -27,7 +27,7 @@ "execa": "^4.0.2", "fibers": "^5.0.3", "jest-diff": "^27.5.1", - "js-yaml": "^3.14.0", + "js-yaml": "^4.1.0", "json-stable-stringify": "^1.0.1", "lmdb-store": "^1.6.11", "normalize-path": "^3.0.0", diff --git a/packages/osd-optimizer/src/limits.ts b/packages/osd-optimizer/src/limits.ts index 86b186930275..d81137c3a9a4 100644 --- a/packages/osd-optimizer/src/limits.ts +++ b/packages/osd-optimizer/src/limits.ts @@ -51,7 +51,7 @@ export function readLimits(): Limits { } } - return yaml ? (Yaml.safeLoad(yaml) as any) : {}; + return yaml ? (Yaml.load(yaml) as any) : {}; } export function validateLimitsForAllBundles(log: ToolingLog, config: OptimizerConfig) { @@ -109,6 +109,6 @@ export function updateBundleLimits(log: ToolingLog, config: OptimizerConfig) { pageLoadAssetSize, }; - Fs.writeFileSync(LIMITS_PATH, Yaml.safeDump(newLimits)); + Fs.writeFileSync(LIMITS_PATH, Yaml.dump(newLimits)); log.success(`wrote updated limits to ${LIMITS_PATH}`); } diff --git a/src/cli/serve/integration_tests/reload_logging_config.test.ts b/src/cli/serve/integration_tests/reload_logging_config.test.ts index fb3c63ffc71d..5950cb1fdfb0 100644 --- a/src/cli/serve/integration_tests/reload_logging_config.test.ts +++ b/src/cli/serve/integration_tests/reload_logging_config.test.ts @@ -36,7 +36,7 @@ import Del from 'del'; import * as Rx from 'rxjs'; import { map, filter, take } from 'rxjs/operators'; -import { safeDump } from 'js-yaml'; +import { dump } from 'js-yaml'; import { getConfigFromFiles } from '@osd/config'; const legacyConfig = follow('__fixtures__/reload_logging_config/opensearch_dashboards.test.yml'); @@ -89,7 +89,7 @@ function createConfigManager(configPath: string) { return { modify(fn: (input: Record) => Record) { const oldContent = getConfigFromFiles([configPath]); - const yaml = safeDump(fn(oldContent)); + const yaml = dump(fn(oldContent)); Fs.writeFileSync(configPath, yaml); }, }; diff --git a/src/dev/stylelint/lint_files.js b/src/dev/stylelint/lint_files.js index ead1fde5bb23..2d94f98b396c 100644 --- a/src/dev/stylelint/lint_files.js +++ b/src/dev/stylelint/lint_files.js @@ -30,13 +30,13 @@ import stylelint from 'stylelint'; import path from 'path'; -import { safeLoad } from 'js-yaml'; +import { load } from 'js-yaml'; import fs from 'fs'; import { createFailError } from '@osd/dev-utils'; // load the include globs from .stylelintrc.yml and convert them to regular expressions for filtering files const stylelintPath = path.resolve(__dirname, '..', '..', '..', '.stylelintrc.yml'); -const styleLintConfig = safeLoad(fs.readFileSync(stylelintPath)); +const styleLintConfig = load(fs.readFileSync(stylelintPath)); /** * Lints a list of files with eslint. eslint reports are written to the log diff --git a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts index 7347975dbc4a..e15a1921b734 100644 --- a/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts +++ b/src/plugins/telemetry/server/collectors/usage/telemetry_usage_collector.ts @@ -29,7 +29,7 @@ */ import { accessSync, constants, readFileSync, statSync } from 'fs'; -import { safeLoad } from 'js-yaml'; +import { load } from 'js-yaml'; import { dirname, join } from 'path'; import { Observable } from 'rxjs'; @@ -78,7 +78,7 @@ export async function readTelemetryFile( try { if (isFileReadable(configPath)) { const yaml = readFileSync(configPath); - const data = safeLoad(yaml.toString()); + const data = load(yaml.toString()); // don't bother returning empty objects if (Object.keys(data).length) { diff --git a/tasks/function_test_groups.js b/tasks/function_test_groups.js index 91f017a437c3..d6df1573a661 100644 --- a/tasks/function_test_groups.js +++ b/tasks/function_test_groups.js @@ -33,10 +33,10 @@ import { resolve } from 'path'; import execa from 'execa'; import grunt from 'grunt'; -import { safeLoad } from 'js-yaml'; +import { load } from 'js-yaml'; const JOBS_YAML = readFileSync(resolve(__dirname, '../.ci/jobs.yml'), 'utf8'); -const TEST_TAGS = safeLoad(JOBS_YAML) +const TEST_TAGS = load(JOBS_YAML) .JOB.filter((id) => id.startsWith('opensearch-dashboards-ciGroup')) .map((id) => id.replace(/^opensearch-dashboards-/, '')); diff --git a/yarn.lock b/yarn.lock index 33ca05a2f2c1..7817a668b032 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3126,10 +3126,10 @@ resolved "https://registry.yarnpkg.com/@types/js-cookie/-/js-cookie-2.2.5.tgz#38dfaacae8623b37cc0b0d27398e574e3fc28b1e" integrity sha512-cpmwBRcHJmmZx0OGU7aPVwGWGbs4iKwVYchk9iuMtxNCA2zorwdaTz4GkLgs2WGxiRZRFKnV1k6tRUHX7tBMxg== -"@types/js-yaml@^3.11.1": - version "3.12.7" - resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.12.7.tgz#330c5d97a3500e9c903210d6e49f02964af04a0e" - integrity sha512-S6+8JAYTE1qdsc9HMVsfY7+SgSuUU/Tp6TYTmITW0PZxiyIMvol3Gy//y69Wkhs0ti4py5qgR3uZH6uz/DNzJQ== +"@types/js-yaml@^4.0.5": + version "4.0.5" + resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-4.0.5.tgz#738dd390a6ecc5442f35e7f03fa1431353f7e138" + integrity sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA== "@types/json-schema@*", "@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": version "7.0.11" @@ -11234,14 +11234,14 @@ js-yaml-js-types@1.0.0: dependencies: esprima "^4.0.1" -js-yaml@4.1.0: +js-yaml@4.1.0, js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== dependencies: argparse "^2.0.1" -js-yaml@^3.13.1, js-yaml@^3.14.0, js-yaml@~3.14.0: +js-yaml@^3.13.1, js-yaml@~3.14.0: version "3.14.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==