From f9da643511aaec345f7219651615324b6e6c3d55 Mon Sep 17 00:00:00 2001 From: TaylorHo Date: Wed, 7 May 2025 11:00:18 -0300 Subject: [PATCH 1/4] feat!: support pnpm audit + removing duplicated tests + updated docs --- .github/CONTRIBUTING.md | 19 +- .github/workflows/playwright.yml | 7 +- ...audit-v10.json => npm-audit-node-v10.json} | 0 ...audit-v16.json => npm-audit-node-v16.json} | 0 .playwright/fixtures/pnpm-audit-v10.json | 174 ++++++++++++++++++ README.md | 25 ++- package-lock.json | 44 ++--- package.json | 13 +- src/index.js | 38 ++-- tests/data-table-v10.spec.js | 31 ---- tests/data-table-v16.spec.js | 31 ---- tests/summary-pnpm.spec.js | 42 +++++ tests/summary-v10.spec.js | 2 +- tests/summary-v16.spec.js | 2 +- 14 files changed, 309 insertions(+), 119 deletions(-) rename .playwright/fixtures/{npm-audit-v10.json => npm-audit-node-v10.json} (100%) rename .playwright/fixtures/{npm-audit-v16.json => npm-audit-node-v16.json} (100%) create mode 100644 .playwright/fixtures/pnpm-audit-v10.json delete mode 100644 tests/data-table-v10.spec.js delete mode 100644 tests/data-table-v16.spec.js create mode 100644 tests/summary-pnpm.spec.js diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6c77762..640955a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -7,13 +7,21 @@ To test the project locally, you use one of the test audits as input to this script, as shown below: 1. To test with a NodeJS v16+ audit: + ```bash -cat .playwright/fixtures/npm-audit-v16.json | node ./src/index.js +cat .playwright/fixtures/npm-audit-node-v16.json | node ./src/index.js ``` 2. To test with a NodeJS v10 to v15 audits: + +```bash +cat .playwright/fixtures/npm-audit-node-v10.json | node ./src/index.js +``` + +3. To test with pnpm audits: + ```bash -cat .playwright/fixtures/npm-audit-v10.json | node ./src/index.js +cat .playwright/fixtures/pnpm-audit-v10.json | node ./src/index.js ``` ## Node.js Version Compatibility @@ -23,12 +31,13 @@ The tool is designed to work with different versions of Node.js. Specifically: - For Node.js v10 to v14. - For Node.js v16 and higher. -odd versions aren't listed, but also works. +It also works with npm, pnpm and yarn
+Odd versions aren't listed, but also works. -So make sure to test the tool in both version ranges to ensure compatibility. 🔄 +So make sure to test the tool in both version ranges and tools to ensure compatibility. 🔄 ## Thank You! 🙌 We would like to extend our heartfelt gratitude to all contributors who have helped improve this project. Your time and effort are highly appreciated. If you encounter any issues or have suggestions, please open an issue or submit a pull request. Together, we can make audit-export even more awesome! 💪 -Happy coding! 🚀 \ No newline at end of file +Happy coding! 🚀 diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index e5169e4..80aabd1 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -55,10 +55,13 @@ jobs: if: matrix.browser == 'webkit' - name: Generate mock audit report for Node v10 ~ v14 (default options) - run: cat ${{ github.workspace }}/.playwright/fixtures/npm-audit-v10.json | node ./src/index.js --path ${{ github.workspace }}/npm-audit-v10.html --title playwright-test + run: cat ${{ github.workspace }}/.playwright/fixtures/npm-audit-node-v10.json | node ./src/index.js --path ${{ github.workspace }}/npm-audit-node-v10.html --title playwright-test - name: Generate mock audit report for Node v16 ~ lts (default options) - run: cat ${{ github.workspace }}/.playwright/fixtures/npm-audit-v16.json | node ./src/index.js --path ${{ github.workspace }}/npm-audit-v16.html --title playwright-test + run: cat ${{ github.workspace }}/.playwright/fixtures/npm-audit-node-v16.json | node ./src/index.js --path ${{ github.workspace }}/npm-audit-node-v16.html --title playwright-test + + - name: Generate mock audit report for pnpm v10 (default options) + run: cat ${{ github.workspace }}/.playwright/fixtures/pnpm-audit-v10.json | node ./src/index.js --path ${{ github.workspace }}/pnpm-audit-v10.html --title playwright-test - name: Run Playwright tests for ${{ matrix.browser }} env: diff --git a/.playwright/fixtures/npm-audit-v10.json b/.playwright/fixtures/npm-audit-node-v10.json similarity index 100% rename from .playwright/fixtures/npm-audit-v10.json rename to .playwright/fixtures/npm-audit-node-v10.json diff --git a/.playwright/fixtures/npm-audit-v16.json b/.playwright/fixtures/npm-audit-node-v16.json similarity index 100% rename from .playwright/fixtures/npm-audit-v16.json rename to .playwright/fixtures/npm-audit-node-v16.json diff --git a/.playwright/fixtures/pnpm-audit-v10.json b/.playwright/fixtures/pnpm-audit-v10.json new file mode 100644 index 0000000..8e44508 --- /dev/null +++ b/.playwright/fixtures/pnpm-audit-v10.json @@ -0,0 +1,174 @@ +{ + "actions": [ + { + "action": "review", + "module": "esbuild", + "resolves": [ + { + "id": 1102341, + "path": ".>@sveltejs/adapter-vercel>esbuild", + "dev": false, + "optional": false, + "bundled": false + } + ] + }, + { + "action": "review", + "module": "cookie", + "resolves": [ + { + "id": 1103907, + "path": ".>@sveltejs/kit>cookie", + "dev": false, + "optional": false, + "bundled": false + } + ] + }, + { + "action": "review", + "module": "vite", + "resolves": [ + { + "id": 1104176, + "path": ".>vite", + "dev": false, + "optional": false, + "bundled": false + } + ] + } + ], + "advisories": { + "1102341": { + "findings": [ + { + "version": "0.24.2", + "paths": [ + ".>@sveltejs/adapter-vercel>esbuild" + ] + } + ], + "found_by": null, + "deleted": null, + "references": "- https://github.com/evanw/esbuild/security/advisories/GHSA-67mh-4wv8-2f99\n- https://github.com/evanw/esbuild/commit/de85afd65edec9ebc44a11e245fd9e9a2e99760d\n- https://github.com/advisories/GHSA-67mh-4wv8-2f99", + "created": "2025-02-10T17:48:07.000Z", + "id": 1102341, + "npm_advisory_id": null, + "overview": "### Summary\n\nesbuild allows any websites to send any request to the development server and read the response due to default CORS settings.\n\n### Details\n\nesbuild sets `Access-Control-Allow-Origin: *` header to all requests, including the SSE connection, which allows any websites to send any request to the development server and read the response.\n\nhttps://github.com/evanw/esbuild/blob/df815ac27b84f8b34374c9182a93c94718f8a630/pkg/api/serve_other.go#L121\nhttps://github.com/evanw/esbuild/blob/df815ac27b84f8b34374c9182a93c94718f8a630/pkg/api/serve_other.go#L363\n\n**Attack scenario**:\n\n1. The attacker serves a malicious web page (`http://malicious.example.com`).\n1. The user accesses the malicious web page.\n1. The attacker sends a `fetch('http://127.0.0.1:8000/main.js')` request by JS in that malicious web page. This request is normally blocked by same-origin policy, but that's not the case for the reasons above.\n1. The attacker gets the content of `http://127.0.0.1:8000/main.js`.\n\nIn this scenario, I assumed that the attacker knows the URL of the bundle output file name. But the attacker can also get that information by\n\n- Fetching `/index.html`: normally you have a script tag here\n- Fetching `/assets`: it's common to have a `assets` directory when you have JS files and CSS files in a different directory and the directory listing feature tells the attacker the list of files\n- Connecting `/esbuild` SSE endpoint: the SSE endpoint sends the URL path of the changed files when the file is changed (`new EventSource('/esbuild').addEventListener('change', e => console.log(e.type, e.data))`)\n- Fetching URLs in the known file: once the attacker knows one file, the attacker can know the URLs imported from that file\n\nThe scenario above fetches the compiled content, but if the victim has the source map option enabled, the attacker can also get the non-compiled content by fetching the source map file.\n\n### PoC\n\n1. Download [reproduction.zip](https://github.com/user-attachments/files/18561484/reproduction.zip)\n2. Extract it and move to that directory\n1. Run `npm i`\n1. Run `npm run watch`\n1. Run `fetch('http://127.0.0.1:8000/app.js').then(r => r.text()).then(content => console.log(content))` in a different website's dev tools.\n\n![image](https://github.com/user-attachments/assets/08fc2e4d-e1ec-44ca-b0ea-78a73c3c40e9)\n\n### Impact\n\nUsers using the serve feature may get the source code stolen by malicious websites.", + "reported_by": null, + "title": "esbuild enables any website to send any requests to the development server and read the response", + "metadata": null, + "cves": [], + "access": "public", + "severity": "moderate", + "module_name": "esbuild", + "vulnerable_versions": "<=0.24.2", + "github_advisory_id": "GHSA-67mh-4wv8-2f99", + "recommendation": "Upgrade to version 0.25.0 or later", + "patched_versions": ">=0.25.0", + "updated": "2025-02-10T17:48:08.000Z", + "cvss": { + "score": 5.3, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N" + }, + "cwe": [ + "CWE-346" + ], + "url": "https://github.com/advisories/GHSA-67mh-4wv8-2f99" + }, + "1103907": { + "findings": [ + { + "version": "0.6.0", + "paths": [ + ".>@sveltejs/kit>cookie" + ] + } + ], + "found_by": null, + "deleted": null, + "references": "- https://github.com/jshttp/cookie/security/advisories/GHSA-pxg6-pf52-xh8x\n- https://github.com/jshttp/cookie/pull/167\n- https://github.com/jshttp/cookie/commit/e10042845354fea83bd8f34af72475eed1dadf5c\n- https://github.com/advisories/GHSA-pxg6-pf52-xh8x", + "created": "2024-10-04T20:31:00.000Z", + "id": 1103907, + "npm_advisory_id": null, + "overview": "### Impact\n\nThe cookie name could be used to set other fields of the cookie, resulting in an unexpected cookie value. For example, `serialize(\"userName=; Max-Age=2592000; a\", value)` would result in `\"userName=; Max-Age=2592000; a=test\"`, setting `userName` cookie to `