@poe-platform/safe-bash 0.1.763 → 0.1.765

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.
Files changed (32) hide show
  1. package/dist/image-ast/index.browser.js +321 -162
  2. package/dist/image-ast/index.js +321 -162
  3. package/dist/pdf-ast/ast.d.ts +2 -0
  4. package/dist/pdf-ast/index.js +340 -173
  5. package/dist/safe-bash/chunks/{chunk-CRQDMBQA.js → chunk-FSH7QRIC.js} +10 -1
  6. package/dist/safe-bash/command-chunks/{chunk-4XHONGIU.js → chunk-DT4MFWV4.js} +2 -2
  7. package/dist/safe-bash/command-chunks/{chunk-S3G2B4OX.js → chunk-KO4PXCNL.js} +324 -162
  8. package/dist/safe-bash/command-chunks/{chunk-S5EX6UP5.js → chunk-SVL6HYQL.js} +1 -1
  9. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  10. package/dist/safe-bash/commands/python/llm-module.js +3 -1
  11. package/dist/safe-bash/commands/python/shell-module.js +7 -0
  12. package/dist/safe-bash/core.browser.js +32 -12
  13. package/dist/safe-bash/shell/runtime.js +43 -11
  14. package/dist/safe-bash-command-ffmpeg/index.js +5800 -5693
  15. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  16. package/dist/safe-bash-command-pandoc/command.js +3 -3
  17. package/dist/safe-bash-command-pandoc/index.js +3 -3
  18. package/dist/safe-bash-command-pdfimages/index.js +321 -162
  19. package/dist/safe-bash-command-pdfinfo/index.js +338 -173
  20. package/dist/safe-bash-command-pdftk/index.js +321 -162
  21. package/dist/safe-bash-command-pdftoppm/index.js +338 -173
  22. package/dist/safe-bash-command-pdftotext/index.js +321 -162
  23. package/dist/safe-bash-command-qpdf/index.js +321 -162
  24. package/dist/safe-bash-command-sips/index.js +2 -2
  25. package/dist/safe-bash-command-soffice/index.js +1 -1
  26. package/dist/safe-bash-command-ssconvert/index.js +373 -169
  27. package/dist/safe-bash-command-wkhtmltopdf/index.js +322 -162
  28. package/dist/safe-playwright-cloudflare/browser-snapshot-labels.d.ts +14 -0
  29. package/dist/safe-playwright-cloudflare/browser-snapshot-labels.js +62 -0
  30. package/dist/safe-playwright-cloudflare/browser-snapshot-scheduler.js +8 -1
  31. package/package.json +2 -2
  32. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +24 -0
@@ -158,7 +158,7 @@ import {
158
158
  sha256,
159
159
  sha384,
160
160
  sha512
161
- } from "./chunks/chunk-CRQDMBQA.js";
161
+ } from "./chunks/chunk-FSH7QRIC.js";
162
162
  import {
163
163
  PythonFailure,
164
164
  inspectPythonCapabilities
@@ -85450,6 +85450,7 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
85450
85450
  let inc = 1;
85451
85451
  let noRenumber = false;
85452
85452
  let joinBlanks = 1;
85453
+ let hasFileOperand = false;
85453
85454
  const parseSecSpec = (v) => {
85454
85455
  if (v === "a" || v === "t" || v === "n") return { style: v };
85455
85456
  if (v.startsWith("p") && v.length > 1) {
@@ -85542,9 +85543,11 @@ ${prefix2} line ${offset + line}: \`${source.split("\n")[line - 1] ?? ""}'
85542
85543
  } else if (/^-i-?[0-9]{1,9}$/.test(a)) {
85543
85544
  inc = Number(a.slice(2));
85544
85545
  } else if (!a.startsWith("-")) {
85545
- if (cwd === void 0) return [];
85546
+ if (cwd === void 0) return void 0;
85546
85547
  const fl = this.readSyncMemoryLines(resolvePath(cwd, a));
85547
85548
  if (!fl) return void 0;
85549
+ if (!hasFileOperand) rawLines = [];
85550
+ hasFileOperand = true;
85548
85551
  rawLines = [...rawLines, ...fl];
85549
85552
  } else {
85550
85553
  return void 0;
@@ -87258,11 +87261,11 @@ unsigned int ${ident}_len = ${view.byteLength};
87258
87261
  if (cmdName === "whoami") {
87259
87262
  if (opArgs.length !== 0 || this.tryReadMemoryFileViewSync("/etc/passwd", false) !== void 0) return void 0;
87260
87263
  if (getEnv("ID_EUID") !== void 0 || getEnv("EUID") !== void 0 || getEnv("ID_UID") !== void 0 || getEnv("UID") !== void 0) return void 0;
87261
- return getEnv("WHOAMI_USER") ?? getEnv("USER") ?? getEnv("LOGNAME") ?? "sandbox";
87264
+ return getEnv("WHOAMI") ?? getEnv("USER") ?? getEnv("LOGNAME") ?? "sandbox";
87262
87265
  }
87263
87266
  if (cmdName === "id") {
87264
87267
  if (this.tryReadMemoryFileViewSync("/etc/passwd", false) !== void 0 || this.tryReadMemoryFileViewSync("/etc/group", false) !== void 0) return void 0;
87265
- for (const k of ["ID_UID", "UID", "ID_EUID", "EUID", "ID_GID", "GID", "ID_EGID", "EGID", "ID_USER", "USER", "LOGNAME", "ID_GROUP", "ID_GROUPS", "ID_CONTEXT"]) {
87268
+ for (const k of ["ID_UID", "UID", "ID_EUID", "EUID", "ID_GID", "GID", "ID_EGID", "EGID", "ID_USER", "USER", "LOGNAME", "GROUP", "ID_GROUPS", "SELINUX_CONTEXT"]) {
87266
87269
  if (getEnv(k) !== void 0) return void 0;
87267
87270
  }
87268
87271
  if (opArgs.length === 0) return "uid=1000(sandbox) gid=1000(sandbox) groups=1000(sandbox)";
@@ -87275,10 +87278,12 @@ unsigned int ${ident}_len = ${view.byteLength};
87275
87278
  }
87276
87279
  if (cmdName === "hostname") {
87277
87280
  if (this.tryReadMemoryFileViewSync("/etc/hostname", false) !== void 0 || getEnv("HOSTNAME_DOMAIN") !== void 0 || getEnv("HOSTNAME_IP") !== void 0) return void 0;
87278
- const host2 = getEnv("HOSTNAME") ?? "sandbox";
87279
- if (opArgs.length === 0 || opArgs.length === 1 && (opArgs[0] === "-f" || opArgs[0] === "--fqdn" || opArgs[0] === "--long")) return host2;
87281
+ const host2 = getEnv("HOSTNAME") || "sandbox";
87282
+ if (opArgs.length === 0) return host2;
87283
+ if (opArgs.length === 1 && (opArgs[0] === "-f" || opArgs[0] === "--fqdn" || opArgs[0] === "--long")) return host2.includes(".") ? host2 : `${host2}.vfs.local`;
87280
87284
  if (opArgs.length === 1 && (opArgs[0] === "-s" || opArgs[0] === "--short")) return host2.split(".")[0];
87281
- if (opArgs.length === 1 && (opArgs[0] === "-i" || opArgs[0] === "--ip-address" || opArgs[0] === "-I" || opArgs[0] === "--all-ip-addresses")) return "127.0.0.1";
87285
+ if (opArgs.length === 1 && (opArgs[0] === "-i" || opArgs[0] === "--ip-address")) return "127.0.0.1";
87286
+ if (opArgs.length === 1 && (opArgs[0] === "-I" || opArgs[0] === "--all-ip-addresses")) return "127.0.0.1 ";
87282
87287
  return void 0;
87283
87288
  }
87284
87289
  if (cmdName === "nproc") {
@@ -87460,6 +87465,7 @@ unsigned int ${ident}_len = ${view.byteLength};
87460
87465
  if (operands.length > 0) {
87461
87466
  for (const op of operands) tokens.push(op);
87462
87467
  } else {
87468
+ if (rawLines === void 0) return void 0;
87463
87469
  for (const line of rawLines) {
87464
87470
  for (const t of line.split(/[ \t\r\n\f\v]+/)) {
87465
87471
  if (t.length > 0) tokens.push(t);
@@ -87524,6 +87530,7 @@ unsigned int ${ident}_len = ${view.byteLength};
87524
87530
  if (memLines === void 0) return void 0;
87525
87531
  linesToRead = memLines;
87526
87532
  }
87533
+ if (linesToRead === void 0) return void 0;
87527
87534
  const tokens = [];
87528
87535
  for (const line of linesToRead) {
87529
87536
  for (const t of line.split(/[ \t\r\n\f\v]+/)) {
@@ -87604,6 +87611,7 @@ unsigned int ${ident}_len = ${view.byteLength};
87604
87611
  const vars = extractVars(operands[0]);
87605
87612
  return vars.length > 0 ? vars.join("\n") + "\n" : "";
87606
87613
  }
87614
+ if (inStr === void 0) return void 0;
87607
87615
  const allowedVars = operands.length === 1 ? new Set(extractVars(operands[0])) : void 0;
87608
87616
  const raw = stateMonitor(rawState)?.raw ?? rawState;
87609
87617
  const isRestrictedEnv = raw._exported === void 0 && "_exported" in raw;
@@ -88805,7 +88813,18 @@ unsigned int ${ident}_len = ${view.byteLength};
88805
88813
  const list = part.script.lists[0];
88806
88814
  if (list.terminator || list.pipelines.length !== 1) return void 0;
88807
88815
  const pipeline = list.pipelines[0];
88808
- if (pipeline.negate) return void 0;
88816
+ if (pipeline.negate || customRegisteredRegistries.has(this.commands)) return void 0;
88817
+ for (const command4 of pipeline.commands) {
88818
+ if (command4.kind !== "simple") continue;
88819
+ const name2 = command4.words[0]?.plain;
88820
+ if (!name2) continue;
88821
+ if (name2 === "fmt" && command4 === pipeline.commands[0] && command4.redirects.length === 0 && !io.stdinIsDefault) return void 0;
88822
+ const definition2 = this.getExternalCommand(name2);
88823
+ if (definition2 && customRegisteredCommands.has(definition2.execute)) return void 0;
88824
+ if (name2 === "uname" || name2 === "nproc" || name2 === "hostname" || name2 === "id" || name2 === "whoami") {
88825
+ if (!definition2 || !internal_exports.builtInDirectContextExecutors.has(definition2.execute)) return void 0;
88826
+ }
88827
+ }
88809
88828
  if (pipeline.commands.length >= 2 && pipeline.commands.length <= 5) {
88810
88829
  if (syncPurePipelineSlotInUse || !this.budget.canSyncPurePipe || (0, yield_exports.hasYieldCheckpoint)(this.signal) || rawState.errexit || rawState.nounset || this.budget.commands + pipeline.commands.length > this.budget.limits.maxCommands) {
88811
88830
  return void 0;
@@ -89790,7 +89809,8 @@ unsigned int ${ident}_len = ${view.byteLength};
89790
89809
  if (cmd.kind !== "simple" || cmd.redirects.length > 0 && !hasSingleStdinRedir && !hasSingleHereStringRedir || cmd.words.length === 0) return void 0;
89791
89810
  let w0Plain = cmd.words[0].plain;
89792
89811
  if (!w0Plain || rawState.extensions?.builtins.has(w0Plain)) return void 0;
89793
- if (w0Plain === "xxd" || w0Plain === "od" || w0Plain === "mktemp" || w0Plain === "chmod") {
89812
+ if (w0Plain === "fmt" && !hasSingleStdinRedir && !hasSingleHereStringRedir && !io.stdinIsDefault) return void 0;
89813
+ if (w0Plain === "xxd" || w0Plain === "od" || w0Plain === "mktemp" || w0Plain === "chmod" || w0Plain === "uname" || w0Plain === "nproc" || w0Plain === "hostname" || w0Plain === "id" || w0Plain === "whoami") {
89794
89814
  const definition2 = this.getExternalCommand(w0Plain);
89795
89815
  if (!definition2 || !internal_exports.builtInDirectContextExecutors.has(definition2.execute)) return void 0;
89796
89816
  }
@@ -90432,11 +90452,11 @@ unsigned int ${ident}_len = ${view.byteLength};
90432
90452
  if (w0Plain === "comm") cjLines = this.evalSyncComm(stdinLines, allArgs, rawState.cwd);
90433
90453
  else if (w0Plain === "join") cjLines = this.evalSyncJoin(stdinLines, allArgs, rawState.cwd);
90434
90454
  else if (w0Plain === "paste") cjLines = this.evalSyncPaste(stdinLines ?? [], allArgs, rawState.cwd);
90435
- else if (w0Plain === "factor") cjLines = this.evalSyncFactor(stdinLines ?? [], allArgs);
90436
- else if (w0Plain === "tsort") cjLines = this.evalSyncTsort(stdinLines ?? [], allArgs, rawState.cwd);
90455
+ else if (w0Plain === "factor") cjLines = this.evalSyncFactor(stdinLines, allArgs);
90456
+ else if (w0Plain === "tsort") cjLines = this.evalSyncTsort(stdinLines, allArgs, rawState.cwd);
90437
90457
  else if (w0Plain === "jq") cjLines = this.evalSyncJq(void 0, allArgs, rawState.cwd);
90438
90458
  else if (w0Plain === "envsubst") {
90439
- const esOut = this.evalSyncEnvsubst("", allArgs, rawState);
90459
+ const esOut = this.evalSyncEnvsubst(void 0, allArgs, rawState);
90440
90460
  if (esOut !== void 0) cjLines = esOut.endsWith("\n") ? esOut.slice(0, -1).split("\n") : esOut ? [esOut] : [];
90441
90461
  } else if (w0Plain === "numfmt") {
90442
90462
  const optArgs = [];
@@ -31701,6 +31701,7 @@ export class Runtime {
31701
31701
  let inc = 1;
31702
31702
  let noRenumber = false;
31703
31703
  let joinBlanks = 1;
31704
+ let hasFileOperand = false;
31704
31705
  const parseSecSpec = (v) => {
31705
31706
  if (v === "a" || v === "t" || v === "n")
31706
31707
  return { style: v };
@@ -31835,10 +31836,13 @@ export class Runtime {
31835
31836
  }
31836
31837
  else if (!a.startsWith("-")) {
31837
31838
  if (cwd === undefined)
31838
- return [];
31839
+ return undefined;
31839
31840
  const fl = this.readSyncMemoryLines(resolvePath(cwd, a));
31840
31841
  if (!fl)
31841
31842
  return undefined;
31843
+ if (!hasFileOperand)
31844
+ rawLines = [];
31845
+ hasFileOperand = true;
31842
31846
  rawLines = [...rawLines, ...fl];
31843
31847
  }
31844
31848
  else {
@@ -33937,12 +33941,12 @@ export class Runtime {
33937
33941
  return undefined;
33938
33942
  if (getEnv("ID_EUID") !== undefined || getEnv("EUID") !== undefined || getEnv("ID_UID") !== undefined || getEnv("UID") !== undefined)
33939
33943
  return undefined;
33940
- return getEnv("WHOAMI_USER") ?? getEnv("USER") ?? getEnv("LOGNAME") ?? "sandbox";
33944
+ return getEnv("WHOAMI") ?? getEnv("USER") ?? getEnv("LOGNAME") ?? "sandbox";
33941
33945
  }
33942
33946
  if (cmdName === "id") {
33943
33947
  if (this.tryReadMemoryFileViewSync("/etc/passwd", false) !== undefined || this.tryReadMemoryFileViewSync("/etc/group", false) !== undefined)
33944
33948
  return undefined;
33945
- for (const k of ["ID_UID", "UID", "ID_EUID", "EUID", "ID_GID", "GID", "ID_EGID", "EGID", "ID_USER", "USER", "LOGNAME", "ID_GROUP", "ID_GROUPS", "ID_CONTEXT"]) {
33949
+ for (const k of ["ID_UID", "UID", "ID_EUID", "EUID", "ID_GID", "GID", "ID_EGID", "EGID", "ID_USER", "USER", "LOGNAME", "GROUP", "ID_GROUPS", "SELINUX_CONTEXT"]) {
33946
33950
  if (getEnv(k) !== undefined)
33947
33951
  return undefined;
33948
33952
  }
@@ -33960,13 +33964,17 @@ export class Runtime {
33960
33964
  if (cmdName === "hostname") {
33961
33965
  if (this.tryReadMemoryFileViewSync("/etc/hostname", false) !== undefined || getEnv("HOSTNAME_DOMAIN") !== undefined || getEnv("HOSTNAME_IP") !== undefined)
33962
33966
  return undefined;
33963
- const host = getEnv("HOSTNAME") ?? "sandbox";
33964
- if (opArgs.length === 0 || (opArgs.length === 1 && (opArgs[0] === "-f" || opArgs[0] === "--fqdn" || opArgs[0] === "--long")))
33967
+ const host = getEnv("HOSTNAME") || "sandbox";
33968
+ if (opArgs.length === 0)
33965
33969
  return host;
33970
+ if (opArgs.length === 1 && (opArgs[0] === "-f" || opArgs[0] === "--fqdn" || opArgs[0] === "--long"))
33971
+ return host.includes(".") ? host : `${host}.vfs.local`;
33966
33972
  if (opArgs.length === 1 && (opArgs[0] === "-s" || opArgs[0] === "--short"))
33967
33973
  return host.split(".")[0];
33968
- if (opArgs.length === 1 && (opArgs[0] === "-i" || opArgs[0] === "--ip-address" || opArgs[0] === "-I" || opArgs[0] === "--all-ip-addresses"))
33974
+ if (opArgs.length === 1 && (opArgs[0] === "-i" || opArgs[0] === "--ip-address"))
33969
33975
  return "127.0.0.1";
33976
+ if (opArgs.length === 1 && (opArgs[0] === "-I" || opArgs[0] === "--all-ip-addresses"))
33977
+ return "127.0.0.1 ";
33970
33978
  return undefined;
33971
33979
  }
33972
33980
  if (cmdName === "nproc") {
@@ -34153,6 +34161,8 @@ export class Runtime {
34153
34161
  tokens.push(op);
34154
34162
  }
34155
34163
  else {
34164
+ if (rawLines === undefined)
34165
+ return undefined;
34156
34166
  for (const line of rawLines) {
34157
34167
  for (const t of line.split(/[ \t\r\n\f\v]+/)) {
34158
34168
  if (t.length > 0)
@@ -34226,6 +34236,8 @@ export class Runtime {
34226
34236
  return undefined;
34227
34237
  linesToRead = memLines;
34228
34238
  }
34239
+ if (linesToRead === undefined)
34240
+ return undefined;
34229
34241
  const tokens = [];
34230
34242
  for (const line of linesToRead) {
34231
34243
  for (const t of line.split(/[ \t\r\n\f\v]+/)) {
@@ -34314,6 +34326,8 @@ export class Runtime {
34314
34326
  const vars = extractVars(operands[0]);
34315
34327
  return vars.length > 0 ? vars.join("\n") + "\n" : "";
34316
34328
  }
34329
+ if (inStr === undefined)
34330
+ return undefined;
34317
34331
  const allowedVars = operands.length === 1 ? new Set(extractVars(operands[0])) : undefined;
34318
34332
  const raw = (stateMonitor(rawState)?.raw ?? rawState);
34319
34333
  const isRestrictedEnv = raw._exported === undefined && "_exported" in raw;
@@ -35866,8 +35880,24 @@ export class Runtime {
35866
35880
  if (list.terminator || list.pipelines.length !== 1)
35867
35881
  return undefined;
35868
35882
  const pipeline = list.pipelines[0];
35869
- if (pipeline.negate)
35883
+ if (pipeline.negate || customRegisteredRegistries.has(this.commands))
35870
35884
  return undefined;
35885
+ for (const command of pipeline.commands) {
35886
+ if (command.kind !== "simple")
35887
+ continue;
35888
+ const name = command.words[0]?.plain;
35889
+ if (!name)
35890
+ continue;
35891
+ if (name === "fmt" && command === pipeline.commands[0] && command.redirects.length === 0 && !io.stdinIsDefault)
35892
+ return undefined;
35893
+ const definition = this.getExternalCommand(name);
35894
+ if (definition && customRegisteredCommands.has(definition.execute))
35895
+ return undefined;
35896
+ if (name === "uname" || name === "nproc" || name === "hostname" || name === "id" || name === "whoami") {
35897
+ if (!definition || !builtInDirectContextExecutors.has(definition.execute))
35898
+ return undefined;
35899
+ }
35900
+ }
35871
35901
  // Range-aware tr and Buffer-free 76-col base64 are supported below.
35872
35902
  if (pipeline.commands.length >= 2 && pipeline.commands.length <= 5) {
35873
35903
  if (syncPurePipelineSlotInUse ||
@@ -37493,7 +37523,9 @@ export class Runtime {
37493
37523
  let w0Plain = cmd.words[0].plain;
37494
37524
  if (!w0Plain || rawState.extensions?.builtins.has(w0Plain))
37495
37525
  return undefined;
37496
- if (w0Plain === "xxd" || w0Plain === "od" || w0Plain === "mktemp" || w0Plain === "chmod") {
37526
+ if (w0Plain === "fmt" && !hasSingleStdinRedir && !hasSingleHereStringRedir && !io.stdinIsDefault)
37527
+ return undefined;
37528
+ if (w0Plain === "xxd" || w0Plain === "od" || w0Plain === "mktemp" || w0Plain === "chmod" || w0Plain === "uname" || w0Plain === "nproc" || w0Plain === "hostname" || w0Plain === "id" || w0Plain === "whoami") {
37497
37529
  const definition = this.getExternalCommand(w0Plain);
37498
37530
  if (!definition || !builtInDirectContextExecutors.has(definition.execute))
37499
37531
  return undefined;
@@ -38376,13 +38408,13 @@ export class Runtime {
38376
38408
  else if (w0Plain === "paste")
38377
38409
  cjLines = this.evalSyncPaste(stdinLines ?? [], allArgs, rawState.cwd);
38378
38410
  else if (w0Plain === "factor")
38379
- cjLines = this.evalSyncFactor(stdinLines ?? [], allArgs);
38411
+ cjLines = this.evalSyncFactor(stdinLines, allArgs);
38380
38412
  else if (w0Plain === "tsort")
38381
- cjLines = this.evalSyncTsort(stdinLines ?? [], allArgs, rawState.cwd);
38413
+ cjLines = this.evalSyncTsort(stdinLines, allArgs, rawState.cwd);
38382
38414
  else if (w0Plain === "jq")
38383
38415
  cjLines = this.evalSyncJq(undefined, allArgs, rawState.cwd);
38384
38416
  else if (w0Plain === "envsubst") {
38385
- const esOut = this.evalSyncEnvsubst("", allArgs, rawState);
38417
+ const esOut = this.evalSyncEnvsubst(undefined, allArgs, rawState);
38386
38418
  if (esOut !== undefined)
38387
38419
  cjLines = esOut.endsWith("\n") ? esOut.slice(0, -1).split("\n") : (esOut ? [esOut] : []);
38388
38420
  }