Version 4.0.4 - #128
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR bumps the package version to 4.0.4 and hardens the Vite dev-server middleware that serves libopencor assets by properly parsing/decoding request URLs and adding a directory-traversal guard before resolving paths under node_modules/@opencor/opencor/dist/libopencor.
Changes:
- Update the dev-server
configureServermiddleware to strip query strings, safely decode URL paths, and ensure resolved file paths remain withinlibopencorDir. - Add a file-type check before serving content from disk.
- Bump package version from 4.0.3 → 4.0.4 in
package.jsonandpackage-lock.json.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| vite.config.js | Improves dev middleware URL parsing and prevents directory traversal when serving /libopencor/* paths. |
| package.json | Version bump to 4.0.4. |
| package-lock.json | Lockfile version bump to 4.0.4. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (2)
vite.config.js:148
- The traversal guard rejects
relative === "", but an empty relative path just means the resolved path is exactlyrealLibopencorDir(i.e.,/libopencor/). That’s not an escape, and it’s already handled by thestatSync(...).isFile()check below. Keeping this condition makes the comment about “escaping the directory” misleading and adds an unnecessary special case.
relative === "" ||
relative === ".." ||
relative.startsWith(`..${path.sep}`) ||
path.isAbsolute(relative)
) {
vite.config.js:176
- This middleware hard-codes
Content-Type: application/javascriptfor every/libopencor/*asset, but libopencor is under awasm/<version>/...directory and is likely to serve.wasmand other non-JS assets as well. Serving.wasmas JS can break streaming compilation and can cause incorrect handling in some clients. Consider selecting the content type based onpath.extname(filePath)(at least.wasmvs.js).
res.writeHead(200, {
"Content-Type": "application/javascript",
"Cross-Origin-Embedder-Policy": "require-corp",
"Cross-Origin-Resource-Policy": "same-origin",
});
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.