typescript-virtual-container 1.5.2 → 1.5.3
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.
- package/README.md +17 -17
- package/builds/{fortune-nyx-v1.5.1-directbash-k6.1.0.mjs → fortune-nyx-v1.5.3-directbash-k6.1.0.mjs} +374 -378
- package/builds/{fortune-nyx-v1.5.1-ssh-nosftp.js → fortune-nyx-v1.5.3-ssh-nosftp.js} +138 -142
- package/builds/{fortune-nyx-v1.5.1-ssh.cjs → fortune-nyx-v1.5.3-ssh.cjs} +139 -143
- package/builds/{fortune-nyx-v1.5.1-web.min.js → fortune-nyx-v1.5.3-web.min.js} +134 -120
- package/dist/VirtualPackageManager/index.js +0 -10
- package/dist/commands/runtime.js +139 -106
- package/docs/app.js +145 -149
- package/examples/app.js +145 -149
- package/examples/demo.html +1 -1
- package/package.json +1 -1
- package/src/VirtualPackageManager/index.ts +0 -10
- package/src/commands/runtime.ts +44 -1
package/examples/demo.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Virtual Env JS</title>
|
|
7
7
|
<script type="module">
|
|
8
|
-
import { VirtualShell, VirtualFileSystem } from '../builds/fortune-nyx-v1.5.
|
|
8
|
+
import { VirtualShell, VirtualFileSystem } from '../builds/fortune-nyx-v1.5.3-web.min.js';
|
|
9
9
|
|
|
10
10
|
const now1 = new Date();
|
|
11
11
|
const ready = await globalThis.__fsReady__;
|
package/package.json
CHANGED
|
@@ -87,16 +87,6 @@ const PACKAGE_REGISTRY: PackageDefinition[] = [
|
|
|
87
87
|
shortDesc: "Vi IMproved",
|
|
88
88
|
installedSizeKb: 3812,
|
|
89
89
|
files: [
|
|
90
|
-
{
|
|
91
|
-
path: "/usr/bin/vim",
|
|
92
|
-
content: "#!/bin/sh\nexec builtin nano \"$@\"\n",
|
|
93
|
-
mode: 0o755,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
path: "/usr/bin/vi",
|
|
97
|
-
content: "#!/bin/sh\nexec builtin nano \"$@\"\n",
|
|
98
|
-
mode: 0o755,
|
|
99
|
-
},
|
|
100
90
|
{
|
|
101
91
|
path: "/usr/share/doc/vim/README",
|
|
102
92
|
content: "Vim editor — virtual package.\n",
|
package/src/commands/runtime.ts
CHANGED
|
@@ -71,6 +71,9 @@ function resolveVfsBinary(
|
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
const MAX_CALL_DEPTH = 8;
|
|
75
|
+
let _callDepth = 0;
|
|
76
|
+
|
|
74
77
|
export async function runCommandDirect(
|
|
75
78
|
name: string,
|
|
76
79
|
args: string[],
|
|
@@ -81,6 +84,32 @@ export async function runCommandDirect(
|
|
|
81
84
|
shell: VirtualShell,
|
|
82
85
|
stdin: string | undefined,
|
|
83
86
|
env: ShellEnv,
|
|
87
|
+
): Promise<CommandResult> {
|
|
88
|
+
// Anti-loop guard: track call depth via env to avoid infinite recursion
|
|
89
|
+
_callDepth++;
|
|
90
|
+
// console.debug(`[depth=${_callDepth}] runCommandDirect: ${name}`);
|
|
91
|
+
if (_callDepth > MAX_CALL_DEPTH) {
|
|
92
|
+
_callDepth--;
|
|
93
|
+
// console.debug(`[LOOP DETECTED] runCommandDirect blocked: ${name}`);
|
|
94
|
+
return { stderr: `${name}: maximum call depth (${MAX_CALL_DEPTH}) exceeded`, exitCode: 126 };
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
return await _runCommandDirectInner(name, args, authUser, hostname, mode, cwd, shell, stdin, env);
|
|
98
|
+
} finally {
|
|
99
|
+
_callDepth--;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function _runCommandDirectInner(
|
|
104
|
+
name: string,
|
|
105
|
+
args: string[],
|
|
106
|
+
authUser: string,
|
|
107
|
+
hostname: string,
|
|
108
|
+
mode: CommandMode,
|
|
109
|
+
cwd: string,
|
|
110
|
+
shell: VirtualShell,
|
|
111
|
+
stdin: string | undefined,
|
|
112
|
+
env: ShellEnv,
|
|
84
113
|
): Promise<CommandResult> {
|
|
85
114
|
const assignRe = /^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
|
|
86
115
|
const invocation = [name, ...args];
|
|
@@ -156,6 +185,8 @@ export async function runCommandDirect(
|
|
|
156
185
|
env,
|
|
157
186
|
});
|
|
158
187
|
}
|
|
188
|
+
// builtin not found — stop here, don't fall through to sh -c (avoids infinite loop)
|
|
189
|
+
return { stderr: `${name}: exec builtin '${builtinMatch[1]}' not found`, exitCode: 127 };
|
|
159
190
|
}
|
|
160
191
|
const shMod = resolveModule("sh");
|
|
161
192
|
if (shMod) {
|
|
@@ -212,6 +243,15 @@ export async function runCommand(
|
|
|
212
243
|
|
|
213
244
|
const shellEnv: ShellEnv = env ?? makeDefaultEnv(authUser, hostname);
|
|
214
245
|
|
|
246
|
+
// Anti-loop guard: check depth here too — catches sh -c recursive calls
|
|
247
|
+
_callDepth++;
|
|
248
|
+
// console.debug(`[depth=${_callDepth}] runCommand: ${trimmed.slice(0, 60)}`);
|
|
249
|
+
if (_callDepth > MAX_CALL_DEPTH) {
|
|
250
|
+
_callDepth--;
|
|
251
|
+
// console.debug(`[LOOP DETECTED] runCommand blocked: ${trimmed.slice(0, 60)}`);
|
|
252
|
+
return { stderr: `${trimmed.split(" ")[0]}: maximum call depth (${MAX_CALL_DEPTH}) exceeded`, exitCode: 126 };
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
215
255
|
const rawTokens = tokenizeCommand(trimmed);
|
|
216
256
|
const rawFirstWord = rawTokens[0]?.toLowerCase() ?? "";
|
|
217
257
|
const aliasVal = shellEnv.vars[`__alias_${rawFirstWord}`];
|
|
@@ -375,4 +415,7 @@ export async function runCommand(
|
|
|
375
415
|
exitCode: 1,
|
|
376
416
|
};
|
|
377
417
|
}
|
|
378
|
-
}
|
|
418
|
+
} finally {
|
|
419
|
+
_callDepth--;
|
|
420
|
+
}
|
|
421
|
+
}
|