@theokit/sdk 4.19.3 → 4.19.4

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/eval.js CHANGED
@@ -2,7 +2,7 @@ import { z, toJSONSchema } from 'zod';
2
2
  import { createRequire } from 'module';
3
3
  import { randomUUID, randomBytes, createHash } from 'crypto';
4
4
  import { mkdir, readFile, open, rename, unlink, writeFile, statfs, readdir, stat, access } from 'fs/promises';
5
- import { join, dirname, resolve, sep, relative, isAbsolute } from 'path';
5
+ import { join, dirname, resolve, relative, sep, isAbsolute } from 'path';
6
6
  import { readFileSync, existsSync, mkdirSync, appendFileSync, realpathSync, lstatSync, readlinkSync, readdirSync, statSync, chmodSync, openSync, writeFileSync, fsyncSync, closeSync, renameSync, unlinkSync } from 'fs';
7
7
  import { homedir } from 'os';
8
8
  import { fileURLToPath, pathToFileURL } from 'url';
@@ -847,6 +847,11 @@ var init_atomic_write = __esm({
847
847
  warnedNfsDirs = /* @__PURE__ */ new Set();
848
848
  }
849
849
  });
850
+ function isInside(target, base) {
851
+ if (target === base) return true;
852
+ const prefix = base.endsWith(sep) ? base : base + sep;
853
+ return target.startsWith(prefix);
854
+ }
850
855
  function safePathJoin(base, ...parts) {
851
856
  if (base === "") {
852
857
  throw new Error("safePathJoin: base must be non-empty");
@@ -857,8 +862,7 @@ function safePathJoin(base, ...parts) {
857
862
  }
858
863
  const baseResolved = resolve(base);
859
864
  const target = resolve(base, ...parts);
860
- const prefix = baseResolved.endsWith(sep) ? baseResolved : baseResolved + sep;
861
- if (target !== baseResolved && !target.startsWith(prefix)) {
865
+ if (!isInside(target, baseResolved)) {
862
866
  throw new PathTraversalError(parts.join("/"), target);
863
867
  }
864
868
  return target;
@@ -883,7 +887,7 @@ function assertNoSymlinkEscape(path, base) {
883
887
  }
884
888
  const resolved = realpathOfDeepestExisting(path);
885
889
  if (resolved === void 0) return;
886
- if (resolved !== baseResolved && !resolved.startsWith(baseResolved + sep)) {
890
+ if (!isInside(resolved, baseResolved)) {
887
891
  throw new PathTraversalError(`symlink ${path}`, resolved);
888
892
  }
889
893
  }