-
Notifications
You must be signed in to change notification settings - Fork 699
fix(storage): resolve Node compatibility crashes, security vulnerability, and stream hangs #8622
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
Merged
+75
−5
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ecc6028
fix(deps): update yargs to v17.7.2 for Node 18 and 26 compatibility
thiyaguk09 9296697
fix: relocate yargs shim generation to local directory and handle str…
thiyaguk09 fb70bad
fix: update safeFs reference in tests and add yargs shim generation w…
thiyaguk09 cb00a3b
Merge branch 'main' into fix/yargs-esm-error
thiyaguk09 2e95d68
fix: update fs mocking to use property descriptors for safer member a…
thiyaguk09 8dbd83b
refactor: simplify yargs resolution by targeting the build index dire…
thiyaguk09 a6603d0
Merge branch 'main' into fix/yargs-esm-error
thiyaguk09 0562a6e
refactor: generate unique local shim files for yargs resolution to im…
thiyaguk09 74475fb
Merge branch 'main' into fix/yargs-esm-error
thiyaguk09 4196985
Merge branch 'main' into fix/yargs-esm-error
thiyaguk09 2a1f10f
Merge branch 'main' into fix/yargs-esm-error
thiyaguk09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| const Module = require('module'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const originalResolveFilename = Module._resolveFilename; | ||
|
|
||
| Module._resolveFilename = function(request, parent, isMain, options) { | ||
| if (request === 'yargs/yargs') { | ||
| const resolved = originalResolveFilename.apply(this, arguments); | ||
| if (resolved.endsWith('.mjs')) { | ||
| return resolved; | ||
| } | ||
| // Create a unique shim file in the local scripts directory to avoid shared temp directory vulnerabilities | ||
| const safeHash = Buffer.from(resolved).toString('base64').replace(/[^a-zA-Z0-9]/g, ''); | ||
| const shimPath = path.join(__dirname, `yargs-shim-${safeHash}.cjs`); | ||
|
|
||
| if (!fs.existsSync(shimPath)) { | ||
| const content = fs.readFileSync(resolved, 'utf8'); | ||
| // Replace `./build/index.cjs` with the absolute path | ||
| const buildIndexPath = path.join(path.dirname(resolved), 'build', 'index.cjs'); | ||
| // We must replace ALL relative requires. Luckily yargs/yargs only requires `./build/index.cjs` | ||
| const newContent = content.replace(/require\(['"]\.\/build\/index\.cjs['"]\)/g, `require(${JSON.stringify(buildIndexPath)})`); | ||
| fs.writeFileSync(shimPath, newContent); | ||
| } | ||
|
|
||
| global.__yargsShimCleanups = global.__yargsShimCleanups || new Set(); | ||
| if (!global.__yargsShimCleanups.has(shimPath)) { | ||
| global.__yargsShimCleanups.add(shimPath); | ||
| process.on('exit', () => { | ||
| try { | ||
| fs.unlinkSync(shimPath); | ||
| } catch (e) {} | ||
| }); | ||
| } | ||
|
|
||
| return shimPath; | ||
| } | ||
| return originalResolveFilename.apply(this, arguments); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.