@shell-shock/core 0.17.3 → 0.17.5

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.
@@ -41,14 +41,7 @@ function ExecBuiltin(props) {
41
41
  });
42
42
  },
43
43
  get builtinImports() {
44
- return (0, defu.default)(rest.builtinImports ?? {}, { env: [
45
- "isWindows",
46
- "env",
47
- {
48
- name: "Env",
49
- type: true
50
- }
51
- ] });
44
+ return (0, defu.default)(rest.builtinImports ?? {}, { env: ["isWindows", "env"] });
52
45
  },
53
46
  get children() {
54
47
  return [
@@ -60,32 +53,32 @@ function ExecBuiltin(props) {
60
53
  }],
61
54
  returnType: "NodeJS.ProcessEnv",
62
55
  children: _alloy_js_core.code`const argv = params.argv;
63
- const shouldSuppressNpmFund = (() => {
64
- const cmd = basename(argv[0] ?? "");
65
- if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
66
- return true;
67
- }
68
- if (cmd === "node" || cmd === "node.exe") {
69
- const script = argv[1] ?? "";
56
+ const shouldSuppressNpmFund = (() => {
57
+ const cmd = basename(argv[0] ?? "");
58
+ if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
59
+ return true;
60
+ }
61
+ if (cmd === "node" || cmd === "node.exe") {
62
+ const script = argv[1] ?? "";
70
63
 
71
- return script.includes("npm-cli.js");
72
- }
73
- return false;
74
- })();
64
+ return script.includes("npm-cli.js");
65
+ }
66
+ return false;
67
+ })();
75
68
 
76
- const result = Object.fromEntries(
77
- Object.entries({
78
- ...env,
79
- ...(params.env ?? {})
80
- })
81
- .filter(([, value]) => value !== undefined)
82
- .map(([key, value]) => [key, String(value)])
83
- );
84
- if (shouldSuppressNpmFund) {
85
- result.NPM_CONFIG_FUND ??= "false";
86
- result.npm_config_fund ??= "false";
87
- }
88
- return result; `
69
+ const result = Object.fromEntries(
70
+ Object.entries({
71
+ ...env,
72
+ ...(params.env ?? {})
73
+ })
74
+ .filter(([, value]) => value !== undefined)
75
+ .map(([key, value]) => [key, String(value)])
76
+ );
77
+ if (shouldSuppressNpmFund) {
78
+ result.NPM_CONFIG_FUND ??= "false";
79
+ result.npm_config_fund ??= "false";
80
+ }
81
+ return result; `
89
82
  }),
90
83
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
91
84
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
@@ -96,11 +89,11 @@ return result; `
96
89
  }],
97
90
  returnType: "boolean",
98
91
  children: _alloy_js_core.code`if (!isWindows) {
99
- return false;
100
- }
101
- const ext = extname(resolvedCommand).toLowerCase();
92
+ return false;
93
+ }
94
+ const ext = extname(resolvedCommand).toLowerCase();
102
95
 
103
- return ext === ".cmd" || ext === ".bat";`
96
+ return ext === ".cmd" || ext === ".bat"; `
104
97
  }),
105
98
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
106
99
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
@@ -111,15 +104,15 @@ return ext === ".cmd" || ext === ".bat";`
111
104
  }],
112
105
  returnType: "string",
113
106
  children: _alloy_js_core.code`if (/[&|<>^%\\\\r\\\\n]/.test(arg)) {
114
- throw new Error(
115
- \`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
116
- "Pass an explicit shell-wrapper argv at the call site instead."
117
- );
118
- }
119
- if (!arg.includes(" ") && !arg.includes('"')) {
120
- return arg;
121
- }
122
- return \`"\${arg.replace(/"/g, '""')}"\`;`
107
+ throw new Error(
108
+ \`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
109
+ "Pass an explicit shell-wrapper argv at the call site instead."
110
+ );
111
+ }
112
+ if (!arg.includes(" ") && !arg.includes('"')) {
113
+ return arg;
114
+ }
115
+ return \`"\${arg.replace(/"/g, '""')}"\`; `
123
116
  }),
124
117
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
125
118
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
@@ -133,8 +126,8 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
133
126
  }],
134
127
  returnType: "string",
135
128
  children: _alloy_js_core.code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(
136
- " "
137
- );`
129
+ " "
130
+ ); `
138
131
  }),
139
132
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
140
133
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
@@ -146,26 +139,26 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
146
139
  }],
147
140
  returnType: "string[] | null",
148
141
  children: _alloy_js_core.code`if (!isWindows || argv.length === 0) {
149
- return null;
150
- }
151
- const base = basename(argv[0] ?? "")
152
- .toLowerCase()
153
- .replace(/\.(?:cmd|exe|bat)$/, "");
154
- const cliName =
155
- base === "npx" ? "npx-cli.js" : base === "npm" ? "npm-cli.js" : null;
156
- if (!cliName) {
157
- return null;
158
- }
159
- const nodeDir = dirname(process.execPath);
160
- const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
161
- if (!existsSync(cliPath)) {
162
- const command = argv[0] ?? "";
163
- const ext = extname(command).toLowerCase();
164
- const shimmedCommand = ext ? command : \`\${command}.cmd\`;
142
+ return null;
143
+ }
144
+ const base = basename(argv[0] ?? "")
145
+ .toLowerCase()
146
+ .replace(/\.(?:cmd|exe|bat)$/, "");
147
+ const cliName =
148
+ base === "npx" ? "npx-cli.js" : base === "npm" ? "npm-cli.js" : null;
149
+ if (!cliName) {
150
+ return null;
151
+ }
152
+ const nodeDir = dirname(process.execPath);
153
+ const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
154
+ if (!existsSync(cliPath)) {
155
+ const command = argv[0] ?? "";
156
+ const ext = extname(command).toLowerCase();
157
+ const shimmedCommand = ext ? command : \`\${command}.cmd\`;
165
158
 
166
- return [shimmedCommand, ...argv.slice(1)];
167
- }
168
- return [process.execPath, cliPath, ...argv.slice(1)];`
159
+ return [shimmedCommand, ...argv.slice(1)];
160
+ }
161
+ return [process.execPath, cliPath, ...argv.slice(1)]; `
169
162
  }),
170
163
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
171
164
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
@@ -177,16 +170,16 @@ return [process.execPath, cliPath, ...argv.slice(1)];`
177
170
  }],
178
171
  returnType: "string",
179
172
  children: _alloy_js_core.code`if (!isWindows) {
180
- return command;
181
- }
182
- const base = basename(command).toLowerCase();
183
- if (extname(base)) {
184
- return command;
185
- }
186
- if (["pnpm", "yarn"].includes(base)) {
187
- return \`\${command}.cmd\`;
188
- }
189
- return command;`
173
+ return command;
174
+ }
175
+ const base = basename(command).toLowerCase();
176
+ if (extname(base)) {
177
+ return command;
178
+ }
179
+ if (["pnpm", "yarn"].includes(base)) {
180
+ return \`\${command}.cmd\`;
181
+ }
182
+ return command; `
190
183
  }),
191
184
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
192
185
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
@@ -197,12 +190,12 @@ return command;`
197
190
  }],
198
191
  returnType: "[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]",
199
192
  children: _alloy_js_core.code`const stdin = params.hasInput
200
- ? "pipe"
201
- : params.preferInherit
202
- ? "inherit"
203
- : "pipe";
193
+ ? "pipe"
194
+ : params.preferInherit
195
+ ? "inherit"
196
+ : "pipe";
204
197
 
205
- return [stdin, "pipe", "pipe"];`
198
+ return [stdin, "pipe", "pipe"]; `
206
199
  }),
207
200
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
208
201
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
@@ -213,16 +206,16 @@ return [stdin, "pipe", "pipe"];`
213
206
  }],
214
207
  returnType: "number | null",
215
208
  children: _alloy_js_core.code`return (
216
- params.explicitCode ??
217
- params.childExitCode ??
218
- (params.usesWindowsExitCodeShim &&
219
- params.resolvedSignal == null &&
220
- !params.timedOut &&
221
- !params.noOutputTimedOut &&
222
- !params.killIssuedByTimeout
223
- ? 0
224
- : null)
225
- );`
209
+ params.explicitCode ??
210
+ params.childExitCode ??
211
+ (params.usesWindowsExitCodeShim &&
212
+ params.resolvedSignal == null &&
213
+ !params.timedOut &&
214
+ !params.noOutputTimedOut &&
215
+ !params.killIssuedByTimeout
216
+ ? 0
217
+ : null)
218
+ ); `
226
219
  }),
227
220
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
228
221
  (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
@@ -233,12 +226,12 @@ return [stdin, "pipe", "pipe"];`
233
226
  }],
234
227
  returnType: "boolean",
235
228
  children: _alloy_js_core.code`// SECURITY: never enable \`shell\` for argv-based execution.
236
- // \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
237
- // (like chat prompts passed as CLI args) into command-injection primitives.
238
- // If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
239
- // and validate/escape at the call site.
240
- void params;
241
- return false;`
229
+ // \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
230
+ // (like chat prompts passed as CLI args) into command-injection primitives.
231
+ // If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
232
+ // and validate/escape at the call site.
233
+ void params;
234
+ return false; `
242
235
  }),
243
236
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
244
237
  (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The result of a spawn operation." }),
@@ -38,14 +38,7 @@ function ExecBuiltin(props) {
38
38
  });
39
39
  },
40
40
  get builtinImports() {
41
- return defu$1(rest.builtinImports ?? {}, { env: [
42
- "isWindows",
43
- "env",
44
- {
45
- name: "Env",
46
- type: true
47
- }
48
- ] });
41
+ return defu$1(rest.builtinImports ?? {}, { env: ["isWindows", "env"] });
49
42
  },
50
43
  get children() {
51
44
  return [
@@ -57,32 +50,32 @@ function ExecBuiltin(props) {
57
50
  }],
58
51
  returnType: "NodeJS.ProcessEnv",
59
52
  children: code`const argv = params.argv;
60
- const shouldSuppressNpmFund = (() => {
61
- const cmd = basename(argv[0] ?? "");
62
- if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
63
- return true;
64
- }
65
- if (cmd === "node" || cmd === "node.exe") {
66
- const script = argv[1] ?? "";
53
+ const shouldSuppressNpmFund = (() => {
54
+ const cmd = basename(argv[0] ?? "");
55
+ if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
56
+ return true;
57
+ }
58
+ if (cmd === "node" || cmd === "node.exe") {
59
+ const script = argv[1] ?? "";
67
60
 
68
- return script.includes("npm-cli.js");
69
- }
70
- return false;
71
- })();
61
+ return script.includes("npm-cli.js");
62
+ }
63
+ return false;
64
+ })();
72
65
 
73
- const result = Object.fromEntries(
74
- Object.entries({
75
- ...env,
76
- ...(params.env ?? {})
77
- })
78
- .filter(([, value]) => value !== undefined)
79
- .map(([key, value]) => [key, String(value)])
80
- );
81
- if (shouldSuppressNpmFund) {
82
- result.NPM_CONFIG_FUND ??= "false";
83
- result.npm_config_fund ??= "false";
84
- }
85
- return result; `
66
+ const result = Object.fromEntries(
67
+ Object.entries({
68
+ ...env,
69
+ ...(params.env ?? {})
70
+ })
71
+ .filter(([, value]) => value !== undefined)
72
+ .map(([key, value]) => [key, String(value)])
73
+ );
74
+ if (shouldSuppressNpmFund) {
75
+ result.NPM_CONFIG_FUND ??= "false";
76
+ result.npm_config_fund ??= "false";
77
+ }
78
+ return result; `
86
79
  }),
87
80
  createComponent(Spacing, {}),
88
81
  createComponent(FunctionDeclaration, {
@@ -93,11 +86,11 @@ return result; `
93
86
  }],
94
87
  returnType: "boolean",
95
88
  children: code`if (!isWindows) {
96
- return false;
97
- }
98
- const ext = extname(resolvedCommand).toLowerCase();
89
+ return false;
90
+ }
91
+ const ext = extname(resolvedCommand).toLowerCase();
99
92
 
100
- return ext === ".cmd" || ext === ".bat";`
93
+ return ext === ".cmd" || ext === ".bat"; `
101
94
  }),
102
95
  createComponent(Spacing, {}),
103
96
  createComponent(FunctionDeclaration, {
@@ -108,15 +101,15 @@ return ext === ".cmd" || ext === ".bat";`
108
101
  }],
109
102
  returnType: "string",
110
103
  children: code`if (/[&|<>^%\\\\r\\\\n]/.test(arg)) {
111
- throw new Error(
112
- \`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
113
- "Pass an explicit shell-wrapper argv at the call site instead."
114
- );
115
- }
116
- if (!arg.includes(" ") && !arg.includes('"')) {
117
- return arg;
118
- }
119
- return \`"\${arg.replace(/"/g, '""')}"\`;`
104
+ throw new Error(
105
+ \`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
106
+ "Pass an explicit shell-wrapper argv at the call site instead."
107
+ );
108
+ }
109
+ if (!arg.includes(" ") && !arg.includes('"')) {
110
+ return arg;
111
+ }
112
+ return \`"\${arg.replace(/"/g, '""')}"\`; `
120
113
  }),
121
114
  createComponent(Spacing, {}),
122
115
  createComponent(FunctionDeclaration, {
@@ -130,8 +123,8 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
130
123
  }],
131
124
  returnType: "string",
132
125
  children: code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(
133
- " "
134
- );`
126
+ " "
127
+ ); `
135
128
  }),
136
129
  createComponent(Spacing, {}),
137
130
  createComponent(FunctionDeclaration, {
@@ -143,26 +136,26 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
143
136
  }],
144
137
  returnType: "string[] | null",
145
138
  children: code`if (!isWindows || argv.length === 0) {
146
- return null;
147
- }
148
- const base = basename(argv[0] ?? "")
149
- .toLowerCase()
150
- .replace(/\.(?:cmd|exe|bat)$/, "");
151
- const cliName =
152
- base === "npx" ? "npx-cli.js" : base === "npm" ? "npm-cli.js" : null;
153
- if (!cliName) {
154
- return null;
155
- }
156
- const nodeDir = dirname(process.execPath);
157
- const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
158
- if (!existsSync(cliPath)) {
159
- const command = argv[0] ?? "";
160
- const ext = extname(command).toLowerCase();
161
- const shimmedCommand = ext ? command : \`\${command}.cmd\`;
139
+ return null;
140
+ }
141
+ const base = basename(argv[0] ?? "")
142
+ .toLowerCase()
143
+ .replace(/\.(?:cmd|exe|bat)$/, "");
144
+ const cliName =
145
+ base === "npx" ? "npx-cli.js" : base === "npm" ? "npm-cli.js" : null;
146
+ if (!cliName) {
147
+ return null;
148
+ }
149
+ const nodeDir = dirname(process.execPath);
150
+ const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
151
+ if (!existsSync(cliPath)) {
152
+ const command = argv[0] ?? "";
153
+ const ext = extname(command).toLowerCase();
154
+ const shimmedCommand = ext ? command : \`\${command}.cmd\`;
162
155
 
163
- return [shimmedCommand, ...argv.slice(1)];
164
- }
165
- return [process.execPath, cliPath, ...argv.slice(1)];`
156
+ return [shimmedCommand, ...argv.slice(1)];
157
+ }
158
+ return [process.execPath, cliPath, ...argv.slice(1)]; `
166
159
  }),
167
160
  createComponent(Spacing, {}),
168
161
  createComponent(FunctionDeclaration, {
@@ -174,16 +167,16 @@ return [process.execPath, cliPath, ...argv.slice(1)];`
174
167
  }],
175
168
  returnType: "string",
176
169
  children: code`if (!isWindows) {
177
- return command;
178
- }
179
- const base = basename(command).toLowerCase();
180
- if (extname(base)) {
181
- return command;
182
- }
183
- if (["pnpm", "yarn"].includes(base)) {
184
- return \`\${command}.cmd\`;
185
- }
186
- return command;`
170
+ return command;
171
+ }
172
+ const base = basename(command).toLowerCase();
173
+ if (extname(base)) {
174
+ return command;
175
+ }
176
+ if (["pnpm", "yarn"].includes(base)) {
177
+ return \`\${command}.cmd\`;
178
+ }
179
+ return command; `
187
180
  }),
188
181
  createComponent(Spacing, {}),
189
182
  createComponent(FunctionDeclaration, {
@@ -194,12 +187,12 @@ return command;`
194
187
  }],
195
188
  returnType: "[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]",
196
189
  children: code`const stdin = params.hasInput
197
- ? "pipe"
198
- : params.preferInherit
199
- ? "inherit"
200
- : "pipe";
190
+ ? "pipe"
191
+ : params.preferInherit
192
+ ? "inherit"
193
+ : "pipe";
201
194
 
202
- return [stdin, "pipe", "pipe"];`
195
+ return [stdin, "pipe", "pipe"]; `
203
196
  }),
204
197
  createComponent(Spacing, {}),
205
198
  createComponent(FunctionDeclaration, {
@@ -210,16 +203,16 @@ return [stdin, "pipe", "pipe"];`
210
203
  }],
211
204
  returnType: "number | null",
212
205
  children: code`return (
213
- params.explicitCode ??
214
- params.childExitCode ??
215
- (params.usesWindowsExitCodeShim &&
216
- params.resolvedSignal == null &&
217
- !params.timedOut &&
218
- !params.noOutputTimedOut &&
219
- !params.killIssuedByTimeout
220
- ? 0
221
- : null)
222
- );`
206
+ params.explicitCode ??
207
+ params.childExitCode ??
208
+ (params.usesWindowsExitCodeShim &&
209
+ params.resolvedSignal == null &&
210
+ !params.timedOut &&
211
+ !params.noOutputTimedOut &&
212
+ !params.killIssuedByTimeout
213
+ ? 0
214
+ : null)
215
+ ); `
223
216
  }),
224
217
  createComponent(Spacing, {}),
225
218
  createComponent(FunctionDeclaration, {
@@ -230,12 +223,12 @@ return [stdin, "pipe", "pipe"];`
230
223
  }],
231
224
  returnType: "boolean",
232
225
  children: code`// SECURITY: never enable \`shell\` for argv-based execution.
233
- // \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
234
- // (like chat prompts passed as CLI args) into command-injection primitives.
235
- // If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
236
- // and validate/escape at the call site.
237
- void params;
238
- return false;`
226
+ // \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
227
+ // (like chat prompts passed as CLI args) into command-injection primitives.
228
+ // If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
229
+ // and validate/escape at the call site.
230
+ void params;
231
+ return false; `
239
232
  }),
240
233
  createComponent(Spacing, {}),
241
234
  createComponent(TSDoc, { heading: "The result of a spawn operation." }),