@hunterzhu/pulse-adapters 0.4.1 → 0.4.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.
@@ -161,6 +161,12 @@ function shellEnvironment(env) {
161
161
  const source = env ?? process.env;
162
162
  return Object.fromEntries(Object.entries(source).filter(([key]) => !/(API_KEY|TOKEN|SECRET|PASSWORD|PRIVATE_KEY|AUTHORIZATION|BEARER|CREDENTIAL|COOKIE)/i.test(key) && key !== 'NODE_OPTIONS'));
163
163
  }
164
+ function shellLaunchesCommand(command, args) {
165
+ const base = basename(command).toLowerCase();
166
+ if (!['sh', 'bash', 'zsh', 'dash', 'fish', 'ksh', 'cmd', 'cmd.exe', 'powershell', 'powershell.exe', 'pwsh', 'pwsh.exe'].includes(base))
167
+ return false;
168
+ return args.some((arg) => /^(?:-lc|-c|-command|\/c)$/i.test(arg));
169
+ }
164
170
  export function runShell(command, args = [], options = {}) {
165
171
  const max = options.maxOutputBytes ?? 256 * 1024;
166
172
  if (!Number.isFinite(max) || max < 0)
@@ -169,6 +175,8 @@ export function runShell(command, args = [], options = {}) {
169
175
  return Promise.reject(shellError('INVALID_SHELL_TIMEOUT'));
170
176
  if (!command || typeof command !== 'string' || !Array.isArray(args) || args.some((arg) => typeof arg !== 'string'))
171
177
  return Promise.reject(shellError('INVALID_SHELL_ARGUMENT'));
178
+ if (/&&|\|\||[|&;<>\n`]|\$\(/.test(command) || shellLaunchesCommand(command, args))
179
+ return Promise.reject(Object.assign(shellError('SHELL_SYNTAX_UNSUPPORTED'), { message: 'shell.exec does not start a shell. Pass the executable in command and each argument in args. Do not put &&, pipes, redirects, command substitution, or sh -c in command.' }));
172
180
  try {
173
181
  encodeSandboxCommand(command, args);
174
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunterzhu/pulse-adapters",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "license": "PolyForm-Noncommercial-1.0.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,8 +18,8 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@anthropic-ai/sandbox-runtime": "0.0.77",
21
- "@hunterzhu/pulse-runtime": "0.4.1",
22
- "@hunterzhu/pulse-tool-sdk": "0.4.1",
21
+ "@hunterzhu/pulse-runtime": "0.4.3",
22
+ "@hunterzhu/pulse-tool-sdk": "0.4.3",
23
23
  "exceljs": "4.4.0",
24
24
  "pdfjs-dist": "4.10.38"
25
25
  }