From cbb187dec6ccfe096bf6df70dad898a41a90ae49 Mon Sep 17 00:00:00 2001 From: Cecilia Avila <44245136+ceciliaavila@users.noreply.github.com> Date: Fri, 8 Sep 2023 14:04:34 -0300 Subject: [PATCH] fix: [#4525] Replace read-text-file package to avoid using LGPL (#4534) * remove read-text-file package * include rule disabling * make async function --------- Co-authored-by: JhontSouth --- libraries/botframework-config/package.json | 1 - .../botframework-config/src/botConfiguration.ts | 8 +++++--- package.json | 1 - yarn.lock | 15 +-------------- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/libraries/botframework-config/package.json b/libraries/botframework-config/package.json index 5d73d4da8a..f1c06a7478 100644 --- a/libraries/botframework-config/package.json +++ b/libraries/botframework-config/package.json @@ -35,7 +35,6 @@ }, "dependencies": { "fs-extra": "^7.0.1", - "read-text-file": "^1.1.0", "uuid": "^8.3.2" }, "devDependencies": { diff --git a/libraries/botframework-config/src/botConfiguration.ts b/libraries/botframework-config/src/botConfiguration.ts index f74e79d801..94fa77452a 100644 --- a/libraries/botframework-config/src/botConfiguration.ts +++ b/libraries/botframework-config/src/botConfiguration.ts @@ -5,9 +5,9 @@ * Licensed under the MIT License. */ import * as fsx from 'fs-extra'; +import * as fs from 'fs'; import * as path from 'path'; import * as process from 'process'; -import * as txtfile from 'read-text-file'; import { v4 as uuidv4 } from 'uuid'; import { BotConfigurationBase } from './botConfigurationBase'; import * as encrypt from './encrypt'; @@ -106,7 +106,8 @@ export class BotConfiguration extends BotConfigurationBase { * @returns A Promise with the new BotConfiguration instance. */ static async load(botpath: string, secret?: string): Promise { - const json: string = await txtfile.read(botpath); + // eslint-disable-next-line security/detect-non-literal-fs-filename + const json: string = await fs.promises.readFile(botpath, 'utf8'); const bot: BotConfiguration = BotConfiguration.internalLoad(json, secret); bot.internal.location = botpath; @@ -121,7 +122,8 @@ export class BotConfiguration extends BotConfigurationBase { * @returns A new BotConfiguration instance. */ static loadSync(botpath: string, secret?: string): BotConfiguration { - const json: string = txtfile.readSync(botpath); + // eslint-disable-next-line security/detect-non-literal-fs-filename + const json: string = fs.readFileSync(botpath, 'utf8'); const bot: BotConfiguration = BotConfiguration.internalLoad(json, secret); bot.internal.location = botpath; diff --git a/package.json b/package.json index 3f4cedaab5..6d2586cc74 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,6 @@ "npm-run-all": "^4.1.5", "nyc": "^15.1.0", "prettier": "^2.1.2", - "read-text-file": "^1.1.0", "replace-in-file": "^4.1.0", "rimraf": "^3.0.2", "shx": "^0.3.3", diff --git a/yarn.lock b/yarn.lock index 3c9d3835d3..47a551449c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7380,7 +7380,7 @@ hyperlinker@^1.0.0: resolved "https://registry.yarnpkg.com/hyperlinker/-/hyperlinker-1.0.0.tgz#23dc9e38a206b208ee49bc2d6c8ef47027df0c0e" integrity sha512-Ty8UblRWFEcfSuIaajM34LdPXIhbs1ajEX/BBPv24J+enSVaEVY63xQ6lTO9VRYS5LAoghIG0IDJ+p+IPzKUQQ== -iconv-lite@0.4.24, iconv-lite@^0.4.17: +iconv-lite@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -8148,11 +8148,6 @@ jsbn@~0.1.0: resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= -jschardet@^1.4.2: - version "1.6.0" - resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.6.0.tgz#c7d1a71edcff2839db2f9ec30fc5d5ebd3c1a678" - integrity sha512-xYuhvQ7I9PDJIGBWev9xm0+SMSed3ZDBAmvVjbFR1ZRLAF+vlXcQu6cRI9uAlj81rzikElRVteehwV7DuX2ZmQ== - jsdoctypeparser@^9.0.0: version "9.0.0" resolved "https://registry.yarnpkg.com/jsdoctypeparser/-/jsdoctypeparser-9.0.0.tgz#8c97e2fb69315eb274b0f01377eaa5c940bd7b26" @@ -10995,14 +10990,6 @@ read-pkg@^3.0.0: normalize-package-data "^2.3.2" path-type "^3.0.0" -read-text-file@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/read-text-file/-/read-text-file-1.1.0.tgz#d0c3f18768828f9107d61bb0b368ee7b90f71893" - integrity sha1-0MPxh2iCj5EH1huws2jue5D3GJM= - dependencies: - iconv-lite "^0.4.17" - jschardet "^1.4.2" - "readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57"