Skip to content

Commit 1111558

Browse files
authored
[WTF-2591]: Fix vulnerabilities in transitive dependencies of PWT (#174)
The main objective of this PR is to ensure widget developers don't install vulnerable packages through the pluggable-widgets-tools. It accomplishes this with the following methods: - Upgrade outdated dependencies - Add an `audit` command that adds overrides for transitive dependencies of the PWT Additionally this PR: - Moves linting & formatting to monorepo root for widgets-tools development - Migrated generator-widget and command-tests to ESM - Improved logging of command-tests - Removed node 18 tests - Updated migration script to handle non-npm package managers gracefully ## Testing When installing this version of the PWT it should have significantly less vulnerabilities reported by `npm audit`. Running `npx pluggable-widgets-tools audit:fix` should eliminate all of them. Existing widgets should continue to function. Depending on the configuration it may require some upgrade work.
2 parents 579050c + a5ed65d commit 1111558

87 files changed

Lines changed: 8142 additions & 8563 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/CreateGWRelease.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ jobs:
2525

2626
- name: Setup pnpm
2727
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
28-
with:
29-
version: 10
3028

3129
- name: "Defining node version"
3230
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0

.github/workflows/CreatePWTRelease.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ jobs:
2525

2626
- name: Setup pnpm
2727
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
28-
with:
29-
version: 10
3028

3129
- name: "Defining node version"
3230
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0

.github/workflows/PublishNpm.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ jobs:
5353

5454
- name: Setup pnpm
5555
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
56-
with:
57-
version: 10
5856

5957
- name: Setup node
6058
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0

.github/workflows/TestPWTCommands.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ${{ matrix.os }}
2525
strategy:
2626
matrix:
27-
node: [18, 20]
27+
node: [20]
2828
os: [windows-latest, ubuntu-latest]
2929
steps:
3030
- name: "Checking-out code"
@@ -34,13 +34,10 @@ jobs:
3434

3535
- name: Setup pnpm
3636
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
37-
with:
38-
version: 10
3937

4038
- name: "Defining node version"
4139
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
4240
with:
43-
node-version: ${{ matrix.node == 18 && '18.15.0' || matrix.node }}
4441
cache: 'pnpm'
4542

4643
- name: "Installing dependencies"

.github/workflows/UnitTests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ jobs:
2525

2626
- name: Setup pnpm
2727
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda #v4.1.0
28-
with:
29-
version: 10
3028

3129
- name: "Defining node version"
3230
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
@@ -41,5 +39,4 @@ jobs:
4139
run: pnpm -r test
4240

4341
- name: "Linting packages"
44-
working-directory: ./packages/generator-widget
45-
run: pnpm -r lint
42+
run: pnpm lint

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.15.0
1+
20.20.2

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ $ git clone https://github.com/mendix/widgets-tools.git
99
$ cd widgets-tools
1010
```
1111

12-
2. Open the folder of the package you want to change and read the README.md for details on how to install and run.
12+
2. Setup `pnpm` using `npm run dev:prepare`.
1313

14-
3. Go make it!
14+
3. Open the folder of the package you want to change and read the README.md for details on how to install and run.
15+
16+
4. Go make it!

eslint.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import { defineConfig, globalIgnores } from "eslint/config";
4+
import jest from "eslint-plugin-jest";
5+
import tseslint from "typescript-eslint";
6+
import prettierRecommended from "eslint-plugin-prettier/recommended";
7+
8+
export default defineConfig(
9+
globalIgnores([
10+
"packages/generator-widget/generators/app/templates/**",
11+
"packages/pluggable-widgets-tools/dist/**"
12+
]),
13+
{
14+
files: ["**/*.js", "**/*.mjs"],
15+
ignores: ["packages/release-tools/utils/changelog-parser/changelog.js"],
16+
plugins: { js },
17+
extends: ["js/recommended"],
18+
languageOptions: { globals: globals.node },
19+
rules: {
20+
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }]
21+
}
22+
},
23+
{
24+
files: ["**/*.ts"],
25+
plugins: { tseslint },
26+
extends: ["tseslint/recommended"],
27+
languageOptions: { globals: globals.node },
28+
rules: {
29+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }]
30+
}
31+
},
32+
{
33+
files: ["**/__mocks__/**/*.js", "**/__tests__/**/*.js", "packages/pluggable-widgets-tools/test-config/**"],
34+
plugins: { jest },
35+
languageOptions: { globals: jest.environments.globals.globals }
36+
},
37+
{ ...prettierRecommended, rules: { "prettier/prettier": process.env.CI ? "error" : "warn" } }
38+
);

package.json

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
{
22
"name": "widgets-tools",
33
"engines": {
4-
"node": ">=16"
4+
"node": ">=20"
55
},
6-
"overrides": {
7-
"cheerio": "1.0.0-rc.12",
8-
"colors": "1.4.0",
9-
"react": "^18.2.0",
10-
"react-dom": "^18.2.0",
11-
"react-native": "~0.77.3"
6+
"private": "true",
7+
"type": "module",
8+
"scripts": {
9+
"dev:prepare": "corepack enable && corepack prepare",
10+
"lint": "eslint"
1211
},
1312
"license": "Apache-2.0",
1413
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
1514
"repository": {
1615
"type": "git",
1716
"url": "https://github.com/mendix/widgets-tools.git"
17+
},
18+
"packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800",
19+
"devDependencies": {
20+
"@eslint/js": "^10.0.1",
21+
"@prettier/plugin-xml": "^3.4.2",
22+
"@typescript-eslint/eslint-plugin": "^8.59.0",
23+
"@typescript-eslint/parser": "^8.59.0",
24+
"eslint": "^10.4.0",
25+
"eslint-config-prettier": "^10.1.8",
26+
"eslint-plugin-jest": "^29.15.2",
27+
"eslint-plugin-prettier": "^5.5.5",
28+
"globals": "^17.6.0",
29+
"prettier": "^3.8.3",
30+
"typescript-eslint": "^8.59.3"
1831
}
1932
}

0 commit comments

Comments
 (0)