@bytecodealliance/preview3-shim 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -872,6 +872,15 @@ class Descriptor {
|
|
|
872
872
|
* Resolve a relative subpath against this descriptor.
|
|
873
873
|
*/
|
|
874
874
|
#getFullPath(subpath, _followSymlinks) {
|
|
875
|
+
const segments = this.#normalizeSubpath(subpath);
|
|
876
|
+
const base = this.#hostPreopen ?? this.#fullPath;
|
|
877
|
+
if (segments.length === 0) {
|
|
878
|
+
return base;
|
|
879
|
+
}
|
|
880
|
+
const baseNormalized = stripTrailingSlash(base);
|
|
881
|
+
return `${baseNormalized}/${segments.join("/")}`;
|
|
882
|
+
}
|
|
883
|
+
#normalizeSubpath(subpath) {
|
|
875
884
|
subpath = subpath.replaceAll("\\", "/").replace(/\/\/+/g, "/");
|
|
876
885
|
if (subpath === "") {
|
|
877
886
|
throw new FSError("no-entry");
|
|
@@ -894,12 +903,7 @@ class Descriptor {
|
|
|
894
903
|
segments.push(seg);
|
|
895
904
|
}
|
|
896
905
|
}
|
|
897
|
-
|
|
898
|
-
if (segments.length === 0) {
|
|
899
|
-
return base;
|
|
900
|
-
}
|
|
901
|
-
const baseNormalized = stripTrailingSlash(base);
|
|
902
|
-
return `${baseNormalized}/${segments.join("/")}`;
|
|
906
|
+
return segments;
|
|
903
907
|
}
|
|
904
908
|
async #statForIdentity() {
|
|
905
909
|
if (this.#hostPreopen) {
|
|
@@ -916,19 +920,12 @@ class Descriptor {
|
|
|
916
920
|
}
|
|
917
921
|
const base = this.#hostPreopen ?? this.#fullPath;
|
|
918
922
|
const baseResolved = nodePath.resolve(base);
|
|
919
|
-
|
|
923
|
+
// Validate the same normalized path that the filesystem operation will use.
|
|
924
|
+
// Otherwise an ENOENT segment followed by `..` can stop validation before a
|
|
925
|
+
// surviving symlink that #getFullPath later exposes.
|
|
926
|
+
const segments = this.#normalizeSubpath(subpath);
|
|
920
927
|
let current = baseResolved;
|
|
921
928
|
for (const seg of segments) {
|
|
922
|
-
if (seg === "" || seg === ".") {
|
|
923
|
-
continue;
|
|
924
|
-
}
|
|
925
|
-
if (seg === "..") {
|
|
926
|
-
current = nodePath.dirname(current);
|
|
927
|
-
if (!isWithinPath(baseResolved, current)) {
|
|
928
|
-
throw new FSError("not-permitted");
|
|
929
|
-
}
|
|
930
|
-
continue;
|
|
931
|
-
}
|
|
932
929
|
current = nodePath.join(current, seg);
|
|
933
930
|
let stat;
|
|
934
931
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/preview3-shim",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "WASI Preview3 shim for JS environments",
|
|
5
5
|
"homepage": "https://github.com/bytecodealliance/jco/blob/main/packages/preview3-shim/#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@bytecodealliance/jco-node-fs": "0.3.2",
|
|
52
|
-
"@bytecodealliance/preview2-shim": "^0.
|
|
52
|
+
"@bytecodealliance/preview2-shim": "^0.27.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@bytecodealliance/jco": "1.25.2",
|