forked from lidge-jun/opencodex
-
Notifications
You must be signed in to change notification settings - Fork 0
[WRONG BRANCH] fix(update): reject project-local npm commands #61
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
Draft
luvs01
wants to merge
1
commit into
main
Choose a base branch
from
codex/fix-windows-project-local-npm.cmd-execution
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: luvs01/opencodex
Length of output: 29297
🏁 Script executed:
Repository: luvs01/opencodex
Length of output: 50373
🌐 Web query:
Bun documentation realpathSync native node:fs support Windows symlink junction 8.3 path canonicalization💡 Result:
Bun's implementation of
node:fsprovides full support for Windows symlinks, junctions, and 8.3 path canonicalization, though the behavior depends on the specific method used [1][2]. To achieve reliable path canonicalization on Windows—including resolving NTFS junctions, symlinks, and expanding 8.3 "short" path names (e.g.,PROGRA~1) to their full, long-form equivalents—you should usefs.realpathSync.native(orfs.realpath.native) [3][1][2]. Key implementation details: 1. Native Resolution:fs.realpathSync.nativeand its asynchronous counterpart leverage the Win32GetFinalPathNameByHandleAPI [4][5][3]. This native approach is required to correctly "see through" NTFS junctions and map 8.3 short names to their canonical long names [1][2]. 2. Compatibility: While the standard, pure-JavaScriptfs.realpathSyncexists for Node.js compatibility, it historically has limitations regarding complex Windows reparse points (like junctions) compared to the native binding [4][1]. Bun's implementation ensuresrealpathSync.nativeeffectively handles these Windows-specific filesystem structures [2]. 3. Canonicalization: BecauseGetFinalPathNameByHandleis used, the returned paths may include the Windows extended-length path prefix (\\?\), which allows for long path support but requires that consumers handle this format correctly if passing paths to other applications [5][6]. 4. Best Practice: If your application requires robust path comparison or identity verification on Windows, prioritizefs.realpathSync.nativeoverfs.realpathSyncorpath.resolve[4][3]. Bun maintains these behaviors to ensure that filesystem-dependent operations (such as bundler asset resolution and package installation) remain consistent even when complex filesystem links are involved [5][7].Citations:
🏁 Script executed:
Repository: luvs01/opencodex
Length of output: 14063
🏁 Script executed:
Repository: luvs01/opencodex
Length of output: 579
🌐 Web query:
Bun official docs node:fs realpathSync.native Windows support💡 Result:
Bun supports fs.realpathSync.native on Windows [1][2]. While Bun generally aims to emulate Node.js behavior, its implementation of fs.realpathSync.native on Windows is specifically designed to provide compatibility. Internally, Bun's implementation for Windows aliases realpathSync.native to its internal fs.realpathNativeSync function [1][3][2]. According to Bun's source code, the implementation for realpathSync on Windows explicitly distinguishes itself from non-Windows platforms to handle path resolution correctly [1][2]. Specifically, Bun's internal code notes that while the standard fs.realpathSync (which is often ported 1:1 from Node.js) may be unable to resolve certain Windows-specific path structures like subst drives, the "native" version (fs.realpathSync.native) is specifically intended to provide the underlying location resolution capability [1][2]. In summary, fs.realpathSync.native is available and supported in Bun on Windows [1][2].
Citations:
Canonicalize Windows PATH directories before applying the trust boundary.
At
src/update/npm-invocation.mjs:15-26,win32.resolve()andwin32.relative()normalize text only. A junction, symlink, or 8.3 alias can make a PATH entry appear outsidecwdwhile it targetscwd\node_modules\.bin; line 55 then accepts and executes itsnpm.cmd. Use Bun-supportedrealpathSync.nativeto canonicalizecwd, each existing PATH directory, andAPPDATA\npmbeforeisInside()andisSamePath(). Fail closed if canonicalization fails. Add a Windows regression test for an alias path.🤖 Prompt for AI Agents
Source: Path instructions