Skip to content

Commit

Permalink
fix: use chalk as a dependency instead of colors (#473)
Browse files Browse the repository at this point in the history
a denial of service has been introduced into the latest version of colors
and not in chalk
  • Loading branch information
imnotjames committed Jan 10, 2022
1 parent aea2052 commit 8a6f59b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@babel/preset-typescript": "^7.13.0",
"@babel/register": "^7.13.16",
"babel-core": "^7.0.0-bridge.0",
"colors": "^1.1.2",
"chalk": "^4.1.2",
"flow-parser": "0.*",
"graceful-fs": "^4.2.4",
"micromatch": "^3.1.10",
Expand Down
26 changes: 13 additions & 13 deletions src/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'use strict';

const child_process = require('child_process');
const colors = require('colors/safe');
const chalk = require('chalk');
const fs = require('graceful-fs');
const path = require('path');
const http = require('http');
Expand Down Expand Up @@ -47,21 +47,21 @@ const bufferedWrite = (function() {

const log = {
ok(msg, verbose) {
verbose >= 2 && bufferedWrite(colors.white.bgGreen(' OKK ') + msg);
verbose >= 2 && bufferedWrite(chalk.white.bgGreen(' OKK ') + msg);
},
nochange(msg, verbose) {
verbose >= 1 && bufferedWrite(colors.white.bgYellow(' NOC ') + msg);
verbose >= 1 && bufferedWrite(chalk.white.bgYellow(' NOC ') + msg);
},
skip(msg, verbose) {
verbose >= 1 && bufferedWrite(colors.white.bgYellow(' SKIP ') + msg);
verbose >= 1 && bufferedWrite(chalk.white.bgYellow(' SKIP ') + msg);
},
error(msg, verbose) {
verbose >= 0 && bufferedWrite(colors.white.bgRed(' ERR ') + msg);
verbose >= 0 && bufferedWrite(chalk.white.bgRed(' ERR ') + msg);
},
};

function report({file, msg}) {
bufferedWrite(lineBreak(`${colors.white.bgBlue(' REP ')}${file} ${msg}`));
bufferedWrite(lineBreak(`${chalk.white.bgBlue(' REP ')}${file} ${msg}`));
}

function concatAll(arrays) {
Expand All @@ -77,17 +77,17 @@ function concatAll(arrays) {
function showFileStats(fileStats) {
process.stdout.write(
'Results: \n'+
colors.red(fileStats.error + ' errors\n')+
colors.yellow(fileStats.nochange + ' unmodified\n')+
colors.yellow(fileStats.skip + ' skipped\n')+
colors.green(fileStats.ok + ' ok\n')
chalk.red(fileStats.error + ' errors\n')+
chalk.yellow(fileStats.nochange + ' unmodified\n')+
chalk.yellow(fileStats.skip + ' skipped\n')+
chalk.green(fileStats.ok + ' ok\n')
);
}

function showStats(stats) {
const names = Object.keys(stats).sort();
if (names.length) {
process.stdout.write(colors.blue('Stats: \n'));
process.stdout.write(chalk.blue('Stats: \n'));
}
names.forEach(name => process.stdout.write(name + ': ' + stats[name] + '\n'));
}
Expand Down Expand Up @@ -201,7 +201,7 @@ function run(transformFile, paths, options) {
});
} else if (!fs.existsSync(transformFile)) {
process.stderr.write(
colors.white.bgRed('ERROR') + ' Transform file ' + transformFile + ' does not exist \n'
chalk.white.bgRed('ERROR') + ' Transform file ' + transformFile + ' does not exist \n'
);
return;
} else {
Expand Down Expand Up @@ -247,7 +247,7 @@ function run(transformFile, paths, options) {
}
if (options.dry) {
process.stdout.write(
colors.green('Running in dry mode, no files will be written! \n')
chalk.green('Running in dry mode, no files will be written! \n')
);
}
}
Expand Down
44 changes: 39 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,13 @@ ansi-styles@^3.2.0, ansi-styles@^3.2.1:
dependencies:
color-convert "^1.9.0"

ansi-styles@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
dependencies:
color-convert "^2.0.1"

anymatch@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb"
Expand Down Expand Up @@ -1015,6 +1022,14 @@ chalk@^2.0.1:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

chalk@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chardet@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
Expand Down Expand Up @@ -1090,21 +1105,28 @@ color-convert@^1.9.0:
dependencies:
color-name "1.1.3"

color-convert@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
dependencies:
color-name "~1.1.4"

color-name@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=

color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

colorette@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==

colors@^1.1.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b"
integrity sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ==

combined-stream@^1.0.6, combined-stream@~1.0.6:
version "1.0.7"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828"
Expand Down Expand Up @@ -1944,6 +1966,11 @@ has-flag@^3.0.0:
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=

has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==

has-symbols@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8"
Expand Down Expand Up @@ -4136,6 +4163,13 @@ supports-color@^5.3.0:
dependencies:
has-flag "^3.0.0"

supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"

symbol-tree@^3.2.1:
version "3.2.2"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"
Expand Down

0 comments on commit 8a6f59b

Please sign in to comment.