@poe-platform/safe-bash 0.1.762 → 0.1.764
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/dist/image-ast/index.browser.js +454 -208
- package/dist/image-ast/index.js +454 -208
- package/dist/pdf-ast/ast.d.ts +23 -0
- package/dist/pdf-ast/index.js +543 -244
- package/dist/safe-bash/chunks/{chunk-CRQDMBQA.js → chunk-FSH7QRIC.js} +10 -1
- package/dist/safe-bash/command-chunks/{chunk-D4GXXV65.js → chunk-B7YLGJRF.js} +2 -2
- package/dist/safe-bash/command-chunks/{chunk-P3Q2QSCA.js → chunk-G3IIEU2N.js} +457 -208
- package/dist/safe-bash/command-chunks/{chunk-F7MJRXQ2.js → chunk-RDPJGIQF.js} +1 -1
- package/dist/safe-bash/commands/python/index.browser.js +1 -1
- package/dist/safe-bash/commands/python/llm-module.js +3 -1
- package/dist/safe-bash/commands/python/shell-module.js +7 -0
- package/dist/safe-bash/core.browser.js +33 -13
- package/dist/safe-bash/shell/runtime.js +44 -12
- package/dist/safe-bash-checksum-engine/index.d.ts +1 -1
- package/dist/safe-bash-checksum-engine/index.js +5 -1
- package/dist/safe-bash-command-ffmpeg/index.js +7476 -7338
- package/dist/safe-bash-command-gh/index.js +174 -105
- package/dist/safe-bash-command-imagemagick/index.js +2 -2
- package/dist/safe-bash-command-pandoc/command.js +3 -3
- package/dist/safe-bash-command-pandoc/index.js +3 -3
- package/dist/safe-bash-command-pdfimages/index.js +454 -208
- package/dist/safe-bash-command-pdfinfo/index.js +541 -244
- package/dist/safe-bash-command-pdftk/index.js +454 -208
- package/dist/safe-bash-command-pdftoppm/index.js +541 -244
- package/dist/safe-bash-command-pdftotext/index.js +454 -208
- package/dist/safe-bash-command-qpdf/index.js +454 -208
- package/dist/safe-bash-command-sips/index.js +2 -2
- package/dist/safe-bash-command-soffice/index.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +514 -208
- package/dist/safe-bash-command-wkhtmltopdf/index.js +455 -208
- package/dist/safe-playwright-cloudflare/browser-snapshot-labels.d.ts +14 -0
- package/dist/safe-playwright-cloudflare/browser-snapshot-labels.js +62 -0
- package/dist/safe-playwright-cloudflare/browser-snapshot-scheduler.js +8 -1
- package/package.json +2 -2
- package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +27 -0
|
@@ -7,6 +7,7 @@ import asyncio
|
|
|
7
7
|
import copy
|
|
8
8
|
import inspect
|
|
9
9
|
import math
|
|
10
|
+
import os
|
|
10
11
|
from dataclasses import dataclass, field, replace
|
|
11
12
|
from typing import Any, AsyncIterator, Callable, Mapping, Optional, Protocol, Sequence, Union
|
|
12
13
|
|
|
@@ -49,7 +50,8 @@ class Attachment:
|
|
|
49
50
|
def payload(self):
|
|
50
51
|
if not isinstance(self.path, str) or not self.path or "\0" in self.path:
|
|
51
52
|
raise ValueError("Attachment requires an agent filesystem path")
|
|
52
|
-
|
|
53
|
+
path = self.path if os.path.isabs(self.path) else os.path.join(os.getcwd(), self.path)
|
|
54
|
+
result = {"path": path}
|
|
53
55
|
if self.mime_type is not None:
|
|
54
56
|
result["mimeType"] = self.mime_type
|
|
55
57
|
return result
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import asyncio
|
|
5
5
|
import math
|
|
6
6
|
import inspect
|
|
7
|
+
import os
|
|
7
8
|
import subprocess
|
|
8
9
|
from dataclasses import dataclass
|
|
9
10
|
|
|
@@ -59,6 +60,12 @@ def _payload(args, *, shell=False, input=None, cwd=None, env=None, timeout=None,
|
|
|
59
60
|
elif not isinstance(input, (bytes, bytearray, memoryview)):
|
|
60
61
|
raise TypeError('Binary input must be bytes')
|
|
61
62
|
result['input'] = list(input)
|
|
63
|
+
# The host retains the original shell context; snapshot the current guest state.
|
|
64
|
+
if cwd is None:
|
|
65
|
+
cwd = os.getcwd()
|
|
66
|
+
elif cwd and not os.path.isabs(cwd):
|
|
67
|
+
cwd = os.path.join(os.getcwd(), cwd)
|
|
68
|
+
env = dict(os.environ if env is None else env)
|
|
62
69
|
result.update(cwd=cwd, env=env, timeout=timeout, max_output_bytes=max_output_bytes)
|
|
63
70
|
return result
|
|
64
71
|
|
|
@@ -158,7 +158,7 @@ import {
|
|
|
158
158
|
sha256,
|
|
159
159
|
sha384,
|
|
160
160
|
sha512
|
|
161
|
-
} from "./chunks/chunk-
|
|
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("
|
|
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", "
|
|
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")
|
|
87279
|
-
if (opArgs.length === 0
|
|
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"
|
|
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 === "
|
|
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
|
}
|
|
@@ -90386,7 +90406,7 @@ unsigned int ${ident}_len = ${view.byteLength};
|
|
|
90386
90406
|
return false;
|
|
90387
90407
|
}
|
|
90388
90408
|
}, (s, d, sym) => this.tryLinkMemoryNodeSync(sym ? s : resolvePath(rawState.cwd, s), resolvePath(rawState.cwd, d), sym)) : (allArgs.includes("--help") || allArgs.includes("--version")) && (0, gnu_information_exports.gnuInformationSync)(w0Plain, allArgs) !== void 0 ? (0, gnu_information_exports.gnuInformationSync)(w0Plain, allArgs) : w0Plain === "mdq" ? evalSyncMdq(inBytes, allArgs, readFile) : w0Plain === "shuf" ? evalSyncShuf(inBytes, allArgs, readFile) : w0Plain === "html-to-markdown" ? (0, html_to_markdown_exports.evalSyncHtmlToMarkdown)(inBytes, allArgs, readFile) : w0Plain === "unrtf" ? evalSyncUnrtf(optInBytes, allArgs, readFile) : w0Plain === "fmt" ? this.evalSyncFmt(inBytes, allArgs, readFile) : w0Plain === "pr" ? evalSyncPr(optInBytes, allArgs, readFile) : w0Plain === "file" ? (0, file_exports.evalSyncFile)(optInBytes, allArgs, readFile, (p) => this.tryStatMemoryNodeTypeSync(resolvePath(rawState.cwd, p), true)) : w0Plain === "diff3" ? evalSyncDiff3(optInBytes, allArgs, readFile) : w0Plain === "cmp" ? evalSyncCmp(optInBytes, allArgs, readFile) : w0Plain === "diff" ? evalSyncDiff(optInBytes, allArgs, readFile) : w0Plain === "xan" ? evalSyncXan(optInBytes, allArgs, readFile) : w0Plain === "less" || w0Plain === "more" ? (0, less_exports.evalSyncLess)(optInBytes, allArgs, readFile) : w0Plain === "rg" ? evalSyncRg(optInBytes, allArgs, readFile) : w0Plain === "md5sum" || w0Plain === "sha1sum" || w0Plain === "sha224sum" || w0Plain === "sha256sum" || w0Plain === "sha384sum" || w0Plain === "sha512sum" || w0Plain === "cksum" ? (() => {
|
|
90389
|
-
const cs = evalSyncChecksum(w0Plain,
|
|
90409
|
+
const cs = evalSyncChecksum(w0Plain, optInBytes, allArgs, readFile);
|
|
90390
90410
|
return cs !== void 0 && !cs.includes("\0") ? cs : void 0;
|
|
90391
90411
|
})() : w0Plain === "base32" ? (() => {
|
|
90392
90412
|
const b32 = (0, base_exports.evalSyncBase32)(inBytes, allArgs, readFile);
|
|
@@ -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
|
|
90436
|
-
else if (w0Plain === "tsort") cjLines = this.evalSyncTsort(stdinLines
|
|
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(
|
|
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("
|
|
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", "
|
|
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")
|
|
33964
|
-
if (opArgs.length === 0
|
|
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"
|
|
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 === "
|
|
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;
|
|
@@ -38318,7 +38350,7 @@ export class Runtime {
|
|
|
38318
38350
|
: w0Plain === "rg"
|
|
38319
38351
|
? evalSyncRg(optInBytes, allArgs, readFile)
|
|
38320
38352
|
: (w0Plain === "md5sum" || w0Plain === "sha1sum" || w0Plain === "sha224sum" || w0Plain === "sha256sum" || w0Plain === "sha384sum" || w0Plain === "sha512sum" || w0Plain === "cksum")
|
|
38321
|
-
? (() => { const cs = evalSyncChecksum(w0Plain,
|
|
38353
|
+
? (() => { const cs = evalSyncChecksum(w0Plain, optInBytes, allArgs, readFile); return cs !== undefined && !cs.includes("\0") ? cs : undefined; })()
|
|
38322
38354
|
: w0Plain === "base32"
|
|
38323
38355
|
? (() => { const b32 = evalSyncBase32(inBytes, allArgs, readFile); return b32 !== undefined ? sharedSyncPipeDecoder.decode(b32) : undefined; })()
|
|
38324
38356
|
: (w0Plain === "xq" || w0Plain === "yq")
|
|
@@ -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
|
|
38411
|
+
cjLines = this.evalSyncFactor(stdinLines, allArgs);
|
|
38380
38412
|
else if (w0Plain === "tsort")
|
|
38381
|
-
cjLines = this.evalSyncTsort(stdinLines
|
|
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(
|
|
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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CommandDefinition } from "../safe-bash-contracts/index.js";
|
|
2
2
|
type Algorithm = "sha512" | "sha384" | "sha256" | "sha224" | "sha1" | "md5" | "crc" | "bsd" | "sysv" | "crc32b" | "sm3" | "blake2b" | "sha3";
|
|
3
3
|
export declare function command(name: string, algorithm: Algorithm, maxInputBytes: number): CommandDefinition;
|
|
4
|
-
export declare function evalSyncChecksum(name: string, inBytes: Uint8Array, opArgs: readonly string[], readFileSync?: (p: string) => Uint8Array | undefined, fileOperandName?: string): string | undefined;
|
|
4
|
+
export declare function evalSyncChecksum(name: string, inBytes: Uint8Array | undefined, opArgs: readonly string[], readFileSync?: (p: string) => Uint8Array | undefined, fileOperandName?: string): string | undefined;
|
|
5
5
|
export {};
|
|
@@ -505,7 +505,7 @@ function digestSync(bytes, algorithm, bits = 512) {
|
|
|
505
505
|
return { hex: String(~crc >>> 0), length };
|
|
506
506
|
}
|
|
507
507
|
function evalSyncChecksum(name, inBytes, opArgs, readFileSync, fileOperandName) {
|
|
508
|
-
if (inBytes.byteLength > 16384)
|
|
508
|
+
if (inBytes && inBytes.byteLength > 16384)
|
|
509
509
|
return void 0;
|
|
510
510
|
const baseAlg = name === "cksum" ? "crc" : name === "md5sum" ? "md5" : name === "sha1sum" ? "sha1" : name === "sha224sum" ? "sha224" : name === "sha256sum" ? "sha256" : name === "sha384sum" ? "sha384" : name === "sha512sum" ? "sha512" : void 0;
|
|
511
511
|
if (!baseAlg)
|
|
@@ -520,6 +520,8 @@ function evalSyncChecksum(name, inBytes, opArgs, readFileSync, fileOperandName)
|
|
|
520
520
|
} catch {
|
|
521
521
|
return void 0;
|
|
522
522
|
}
|
|
523
|
+
if (fileOperandName !== void 0 && settings.operands.includes("-"))
|
|
524
|
+
return void 0;
|
|
523
525
|
if (settings.encoding === "raw")
|
|
524
526
|
return void 0;
|
|
525
527
|
let stdinUsed = false;
|
|
@@ -530,6 +532,8 @@ function evalSyncChecksum(name, inBytes, opArgs, readFileSync, fileOperandName)
|
|
|
530
532
|
return void 0;
|
|
531
533
|
}
|
|
532
534
|
if (filename === "-") {
|
|
535
|
+
if (inBytes === void 0)
|
|
536
|
+
return void 0;
|
|
533
537
|
if (stdinUsed)
|
|
534
538
|
return new Uint8Array(0);
|
|
535
539
|
stdinUsed = true;
|