Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug DFBUGS-873: [CVE] Improper input validation in PostCSS #1848

Open
wants to merge 1 commit into
base: release-4.17
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module.exports = {
'**/*.spec.tsx',
'./jest/setup.ts',
'./cypress/**',
'./analyzeTest.ts',
],
optionalDependencies: false,
peerDependencies: false,
Expand Down
15 changes: 8 additions & 7 deletions analyzeTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from 'fs';
import { parseChunked } from '@discoveryjs/json-ext';

const pluginName = process.env.PLUGIN;
const MAX_ASSET_SIZE = 17; //17 MiB
Expand All @@ -12,17 +13,17 @@ const stringifyMiB = (value: ReturnType<typeof toMiB>): string =>

const getParsedStatFile = () => {
const filePath = getStatsFilePath();
const statsFile = fs.readFileSync(filePath, 'utf-8');
return JSON.parse(statsFile);

return parseChunked(fs.createReadStream(filePath, { encoding: 'utf8' }));
};

type BundleDataMap = Record<string, number>;

// [Valid Bundles, Violating Bunldes]
type GetBundleInformation = () => [BundleDataMap, BundleDataMap];
type GetBundleInformation = () => Promise<[BundleDataMap, BundleDataMap]>;

const getBundleInformation: GetBundleInformation = () => {
const statsData = getParsedStatFile();
const getBundleInformation: GetBundleInformation = async () => {
const statsData = await getParsedStatFile();
const validAssets = {};
const violatingAssets = {};

Expand All @@ -39,8 +40,8 @@ const getBundleInformation: GetBundleInformation = () => {
return [validAssets, violatingAssets];
};

const validateBuild = () => {
const [validAssets, violatingAssets] = getBundleInformation();
const validateBuild = async () => {
const [validAssets, violatingAssets] = await getBundleInformation();
if (Object.keys(violatingAssets).length > 0) {
// eslint-disable-next-line no-console
console.error('Assets are larger than expected', violatingAssets);
Expand Down
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"circular-dependency-plugin": "5.x",
"classnames": "^2.3.1",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "0.28.x",
"css-loader": "^6.11.0",
"eslint-config-airbnb": "18.2.1",
"file-loader": "1.x",
"fork-ts-checker-webpack-plugin": "^7.2.13",
Expand Down Expand Up @@ -109,7 +109,7 @@
"sass": "^1.55.0",
"sass-loader": "^13.0.2",
"semver": "6.x",
"style-loader": "^0.23.1",
"style-loader": "^3.3.4",
"thread-loader": "3.0.4",
"ts-loader": "^9.4.1",
"ts-node": "5.0.1",
Expand All @@ -124,6 +124,7 @@
},
"devDependencies": {
"@cypress/webpack-preprocessor": "^5.9.1",
"@discoveryjs/json-ext": "0.6.1",
"@swc/core": "1.3.19",
"@swc/jest": "^0.2.23",
"@testing-library/jest-dom": "^6.4.5",
Expand Down Expand Up @@ -166,21 +167,22 @@
"mochawesome-merge": "^4.2.0",
"prettier": "2.3.2",
"read-pkg": "5.x",
"stylelint": "^13.13.1",
"stylelint-config-sass-guidelines": "^8.0.0",
"stylelint-config-standard": "^22.0.0",
"stylelint-order": "^4.1.0",
"stylelint": "^15.11.0",
"stylelint-config-sass-guidelines": "^10.0.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-order": "^6.0.4",
"webpack-dev-server": "^4.15.2"
},
"resolutions": {
"nanoid": "^3.3.8",
"cross-spawn": "^7.0.6",
"jest-environment-jsdom/jsdom": "^20.0.3",
"nanoid": "^3.3.8",
"postcss": "^8.4.49",
"tough-cookie": "^4.1.3",
"webpack": "5.94.0",
"webpack-bundle-analyzer/ws": "^7.5.10",
"webpack-dev-server/express": "^4.21.0",
"webpack-dev-server/ws": "^8.18.0",
"tough-cookie": "^4.1.3",
"cross-spawn": "^7.0.6"
"webpack-dev-server/ws": "^8.18.0"
},
"engines": {
"node": ">=14.17.0"
Expand Down
Loading
Loading