@poe-platform/safe-bash 0.1.75 → 0.1.77

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 (28) hide show
  1. package/dist/safe-bash/browser.js +25 -4
  2. package/dist/safe-bash/browser.js.map +3 -3
  3. package/dist/safe-bash/commands/regex-execution/matching.d.ts +1 -1
  4. package/dist/safe-bash/commands/regex-execution/matching.d.ts.map +1 -1
  5. package/dist/safe-bash/commands/regex-execution/matching.js +8 -4
  6. package/dist/safe-bash/commands/regex-execution/matching.js.map +1 -1
  7. package/dist/safe-bash/commands/regex-execution/protocol.d.ts +4 -0
  8. package/dist/safe-bash/commands/regex-execution/protocol.d.ts.map +1 -1
  9. package/dist/safe-bash/commands/regex-execution/protocol.js +30 -5
  10. package/dist/safe-bash/commands/regex-execution/protocol.js.map +1 -1
  11. package/dist/safe-bash/commands/regex-execution/worker.js +7 -1
  12. package/dist/safe-bash/commands/regex-execution/worker.js.map +1 -1
  13. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +25 -0
  14. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts.map +1 -0
  15. package/dist/safe-bash/commands/text-programs/awk-reader.js +180 -0
  16. package/dist/safe-bash/commands/text-programs/awk-reader.js.map +1 -0
  17. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +11 -0
  18. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts.map +1 -0
  19. package/dist/safe-bash/commands/text-programs/awk-retention.js +31 -0
  20. package/dist/safe-bash/commands/text-programs/awk-retention.js.map +1 -0
  21. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +11 -1
  22. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts.map +1 -1
  23. package/dist/safe-bash/commands/text-programs/awk-runtime.js +291 -191
  24. package/dist/safe-bash/commands/text-programs/awk-runtime.js.map +1 -1
  25. package/dist/safe-bash/commands/text-programs/awk.d.ts.map +1 -1
  26. package/dist/safe-bash/commands/text-programs/awk.js +2 -1
  27. package/dist/safe-bash/commands/text-programs/awk.js.map +1 -1
  28. package/package.json +2 -2
@@ -16293,6 +16293,7 @@ var RegexExecutionError = class extends Error {
16293
16293
  }
16294
16294
  code;
16295
16295
  };
16296
+ var matchRangeLimits = Object.freeze({ perRow: 1e5, perReply: 1e5 });
16296
16297
  var exprMatchCeilings = Object.freeze({
16297
16298
  maxPatternBytes: 65536,
16298
16299
  maxSubjectBytes: 1048576,
@@ -16393,13 +16394,28 @@ function validateReply(value2, id, rows, signal) {
16393
16394
  throw new RegexExecutionError("MATCH", reply.error);
16394
16395
  }
16395
16396
  if (!("results" in reply) || !Array.isArray(reply.results) || reply.results.length !== rows.length) throw new RegexExecutionError("PROTOCOL", "invalid reply rows");
16396
- return reply.results.map((ranges, index) => {
16397
+ let total = 0;
16398
+ const lengths = [];
16399
+ for (let index = 0; index < reply.results.length; index++) {
16397
16400
  signal.throwIfAborted();
16398
- if (!(ranges instanceof Float64Array) || ranges.length % 2 || ranges.length > 2 * (rows[index].bytes.length + 1)) throw new RegexExecutionError("PROTOCOL", "invalid match ranges");
16401
+ const ranges = reply.results[index];
16402
+ const row = rows[index];
16403
+ if (!(ranges instanceof Float64Array)) throw new RegexExecutionError("PROTOCOL", "invalid match ranges");
16404
+ const length = ranges.length;
16405
+ if (length % 2 || length > 2 * (row.bytes.length + 1)) throw new RegexExecutionError("PROTOCOL", "invalid match ranges");
16406
+ if (!row.all && length > 2) throw new RegexExecutionError("PROTOCOL", "unexpected multiple matches");
16407
+ const count2 = length / 2;
16408
+ if (count2 > matchRangeLimits.perRow || count2 > matchRangeLimits.perReply - total) throw new RegexExecutionError("PROTOCOL", "match range limit exceeded");
16409
+ total += count2;
16410
+ lengths.push(length);
16411
+ }
16412
+ const results = reply.results.map((ranges, index) => {
16413
+ signal.throwIfAborted();
16414
+ const length = lengths[index];
16415
+ if (ranges.length !== length) throw new RegexExecutionError("PROTOCOL", "match ranges changed after admission");
16399
16416
  const result = [];
16400
16417
  const row = rows[index];
16401
- if (!row.all && ranges.length > 2) throw new RegexExecutionError("PROTOCOL", "unexpected multiple matches");
16402
- for (let offset = 0; offset < ranges.length; offset += 2) {
16418
+ for (let offset = 0; offset < length; offset += 2) {
16403
16419
  signal.throwIfAborted();
16404
16420
  const start = ranges[offset];
16405
16421
  const end = ranges[offset + 1];
@@ -16408,6 +16424,11 @@ function validateReply(value2, id, rows, signal) {
16408
16424
  }
16409
16425
  return result;
16410
16426
  });
16427
+ for (let index = 0; index < reply.results.length; index++) {
16428
+ signal.throwIfAborted();
16429
+ if (reply.results[index].length !== lengths[index]) throw new RegexExecutionError("PROTOCOL", "match ranges changed after admission");
16430
+ }
16431
+ return results;
16411
16432
  }
16412
16433
 
16413
16434
  // packages/safe-bash/src/commands/regex-execution/portable.ts