@poe-platform/safe-bash 0.1.425 → 0.1.427
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.
|
@@ -4109,6 +4109,7 @@ function filesystemCommands(maxDirectoryEntries) {
|
|
|
4109
4109
|
|
|
4110
4110
|
// packages/safe-bash/src/commands/predicates.ts
|
|
4111
4111
|
init_platform();
|
|
4112
|
+
var maxExpressionDepth = 256;
|
|
4112
4113
|
async function metadata(context, path, link = false) {
|
|
4113
4114
|
assertCommandRequirements(context, predicateRequirements, ["metadata"]);
|
|
4114
4115
|
try {
|
|
@@ -4141,15 +4142,16 @@ function predicateCommands() {
|
|
|
4141
4142
|
if (!/^[ \t]*[+-]?[0-9]+[ \t]*$/u.test(text)) throw new UsageError(`integer expression expected: '${text}'`);
|
|
4142
4143
|
return BigInt(text.trim());
|
|
4143
4144
|
};
|
|
4144
|
-
const primary = () => {
|
|
4145
|
+
const primary = (depth) => {
|
|
4145
4146
|
const token = args[offset++];
|
|
4146
4147
|
if (token === void 0) throw new UsageError("argument expected");
|
|
4147
|
-
if (token === "!" && !binary.has(args[offset] ?? "")) {
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4148
|
+
if ((token === "!" || token === "(") && !binary.has(args[offset] ?? "")) {
|
|
4149
|
+
if (depth >= maxExpressionDepth) throw new UsageError(`expression nesting exceeds ${maxExpressionDepth}`);
|
|
4150
|
+
if (token === "!") {
|
|
4151
|
+
const inner2 = primary(depth + 1);
|
|
4152
|
+
return async () => !await inner2();
|
|
4153
|
+
}
|
|
4154
|
+
const inner = disjunction(depth + 1);
|
|
4153
4155
|
if (args[offset++] !== ")") throw new UsageError("missing ')'");
|
|
4154
4156
|
return inner;
|
|
4155
4157
|
}
|
|
@@ -4214,27 +4216,27 @@ function predicateCommands() {
|
|
|
4214
4216
|
}
|
|
4215
4217
|
return async () => token !== "";
|
|
4216
4218
|
};
|
|
4217
|
-
const conjunction = () => {
|
|
4218
|
-
let predicate = primary();
|
|
4219
|
+
const conjunction = (depth) => {
|
|
4220
|
+
let predicate = primary(depth);
|
|
4219
4221
|
while (args[offset] === "-a") {
|
|
4220
4222
|
offset++;
|
|
4221
4223
|
const left = predicate;
|
|
4222
|
-
const right = primary();
|
|
4224
|
+
const right = primary(depth);
|
|
4223
4225
|
predicate = async () => await left() && await right();
|
|
4224
4226
|
}
|
|
4225
4227
|
return predicate;
|
|
4226
4228
|
};
|
|
4227
|
-
const disjunction = () => {
|
|
4228
|
-
let predicate = conjunction();
|
|
4229
|
+
const disjunction = (depth) => {
|
|
4230
|
+
let predicate = conjunction(depth);
|
|
4229
4231
|
while (args[offset] === "-o") {
|
|
4230
4232
|
offset++;
|
|
4231
4233
|
const left = predicate;
|
|
4232
|
-
const right = conjunction();
|
|
4234
|
+
const right = conjunction(depth);
|
|
4233
4235
|
predicate = async () => await left() || await right();
|
|
4234
4236
|
}
|
|
4235
4237
|
return predicate;
|
|
4236
4238
|
};
|
|
4237
|
-
const evaluate = disjunction();
|
|
4239
|
+
const evaluate = disjunction(0);
|
|
4238
4240
|
if (offset !== args.length) throw new UsageError(`unexpected argument '${args[offset]}'`);
|
|
4239
4241
|
return { exitCode: await evaluate() ? 0 : 1 };
|
|
4240
4242
|
})).map((command2) => ({ ...command2, filesystemRequirements: predicateRequirements }));
|