@ai-ecoverse/slicc-kernel 1.196.22 → 1.196.23

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.
@@ -9313,7 +9313,7 @@ var init_version = __esm({
9313
9313
  "src/version.ts"() {
9314
9314
  "use strict";
9315
9315
  init_captured_globals();
9316
- KERNEL_VERSION = true ? "1.196.22" : "0.0.0-dev";
9316
+ KERNEL_VERSION = true ? "1.196.23" : "0.0.0-dev";
9317
9317
  OS_RELEASE = "6.0.0-slicc";
9318
9318
  }
9319
9319
  });
@@ -9312,7 +9312,7 @@ var init_version = __esm({
9312
9312
  "src/version.ts"() {
9313
9313
  "use strict";
9314
9314
  init_captured_globals();
9315
- KERNEL_VERSION = true ? "1.196.22" : "0.0.0-dev";
9315
+ KERNEL_VERSION = true ? "1.196.23" : "0.0.0-dev";
9316
9316
  OS_RELEASE = "6.0.0-slicc";
9317
9317
  }
9318
9318
  });
package/dist/node.js CHANGED
@@ -7738,7 +7738,7 @@ function satisfies(version, range2) {
7738
7738
  }
7739
7739
 
7740
7740
  // src/version.ts
7741
- var KERNEL_VERSION = true ? "1.196.22" : "0.0.0-dev";
7741
+ var KERNEL_VERSION = true ? "1.196.23" : "0.0.0-dev";
7742
7742
  var OS_RELEASE = "6.0.0-slicc";
7743
7743
  function procVersion() {
7744
7744
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -7883,14 +7883,16 @@ function commandsOf(pkg, manifest) {
7883
7883
  }
7884
7884
  return out;
7885
7885
  }
7886
- async function withPackagePaths(fs, pkg, command) {
7886
+ async function withPackagePaths(fs, pkg, command, provenance) {
7887
7887
  if (!command.env) return command;
7888
7888
  const env = {};
7889
+ const envPaths = /* @__PURE__ */ new Set();
7889
7890
  for (const [key, value2] of Object.entries(command.env)) {
7890
7891
  const path = !value2.startsWith("/") && value2.includes("/") && inside(pkg, value2);
7892
+ if (path && provenance) envPaths.add(path);
7891
7893
  env[key] = path && await fs.exists(path) ? path : value2;
7892
7894
  }
7893
- return { ...command, env };
7895
+ return { ...command, env, ...envPaths.size ? { envPaths: [...envPaths] } : {} };
7894
7896
  }
7895
7897
  async function packages(fs, modules) {
7896
7898
  const names2 = await fs.readdir(modules).catch(() => []);
@@ -8085,7 +8087,7 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, ke
8085
8087
  );
8086
8088
  const take = async (tier) => {
8087
8089
  for (const [name2, { pkg, command }] of winners(tier)) {
8088
- if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command));
8090
+ if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command, provenance));
8089
8091
  }
8090
8092
  };
8091
8093
  const dependencies = [];
@@ -19045,6 +19047,7 @@ var SudoReads = class {
19045
19047
  documents = /* @__PURE__ */ new Map();
19046
19048
  texts = /* @__PURE__ */ new Map();
19047
19049
  relevant = /* @__PURE__ */ new Set();
19050
+ envPaths = /* @__PURE__ */ new Set();
19048
19051
  verified = /* @__PURE__ */ new Set();
19049
19052
  interpreters = [];
19050
19053
  chainSha256;
@@ -19064,11 +19067,13 @@ var SudoReads = class {
19064
19067
  }
19065
19068
  resetSelection() {
19066
19069
  this.relevant.clear();
19070
+ this.envPaths.clear();
19067
19071
  this.interpreters.length = 0;
19068
19072
  delete this.chainSha256;
19069
19073
  this.operandsFromEnd.clear();
19070
19074
  }
19071
- include(paths) {
19075
+ include(paths, envPaths) {
19076
+ for (const path of envPaths ?? []) this.envPaths.add(path);
19072
19077
  for (const path of paths ?? []) if (this.verified.has(path)) this.relevant.add(path);
19073
19078
  }
19074
19079
  async digest(path) {
@@ -19160,6 +19165,12 @@ var SudoReads = class {
19160
19165
  ...scripts.length ? { scripts } : {},
19161
19166
  ...this.chainSha256 ? { chainSha256: this.chainSha256 } : {}
19162
19167
  };
19168
+ for (const path of this.envPaths) {
19169
+ if (!await this.access.trustedEnvPath(path)) {
19170
+ binding.writableEnvPath = true;
19171
+ break;
19172
+ }
19173
+ }
19163
19174
  if (!Object.keys(routes).some((path) => path !== routes[path])) return binding;
19164
19175
  const pairs = Object.keys(routes).sort().map((path) => [path, routes[path]]);
19165
19176
  const routeSha256 = await sha2562(new TextEncoder().encode(JSON.stringify(pairs)));
@@ -20251,7 +20262,9 @@ function changedFile(approved, now) {
20251
20262
  return [...files].find((file) => approved[file] !== now[file]);
20252
20263
  }
20253
20264
  function pinned(rule2, hashes, proof) {
20254
- return rule2.sha256 === void 0 || rule2.routeSha256 === proof.routeSha256 && (rule2.chainSha256 === void 0 || rule2.chainSha256 === proof.chainSha256) && changedFile(rule2.sha256, hashes) === void 0;
20265
+ if (!rule2.sha256) return true;
20266
+ if (proof.writableEnvPath && !rule2.chainSha256 && !Object.keys(rule2.sha256).length) return false;
20267
+ return rule2.routeSha256 === proof.routeSha256 && (rule2.chainSha256 === void 0 || rule2.chainSha256 === proof.chainSha256) && changedFile(rule2.sha256, hashes) === void 0;
20255
20268
  }
20256
20269
  function changedManifests(rules, bound3) {
20257
20270
  const changed2 = /* @__PURE__ */ new Set();
@@ -20272,8 +20285,11 @@ function proofOf({ routeSha256, chainSha256 }) {
20272
20285
  function changedDecision(hashes, proof, now, path) {
20273
20286
  return changedFile(hashes, now.hashes) ?? (proof.routeSha256 !== now.routeSha256 || proof.chainSha256 !== now.chainSha256 ? path : void 0);
20274
20287
  }
20288
+ function durableProof(files) {
20289
+ return files.writableEnvPath || Object.keys(files.hashes).length ? proofOf(files) : {};
20290
+ }
20275
20291
  function stampOf(files) {
20276
- return Object.keys(files.hashes).length ? { ...files.hashes, ...proofOf(files) } : files.hashes;
20292
+ return { ...files.hashes, ...durableProof(files) };
20277
20293
  }
20278
20294
  var REPLAY_ID = /^[!-~]{1,256}$/;
20279
20295
  var REPLAY_TAGS_MAX = 64;
@@ -20730,6 +20746,7 @@ var Sudo = class {
20730
20746
  {
20731
20747
  real: (at) => this.real(at),
20732
20748
  trusted: (at) => this.trustedThrough(at, void 0, fs),
20749
+ trustedEnvPath: (at) => this.trusted(at, true),
20733
20750
  read: (at) => fs.readFileBuffer(at)
20734
20751
  },
20735
20752
  snapshots
@@ -20850,13 +20867,12 @@ ${SCRIPT_HELP}
20850
20867
  const cred = credOf(self);
20851
20868
  const [word = "", ...args] = r.argv;
20852
20869
  const argv = [r.path, ...args];
20853
- if (!await this.mayAsk(self, target, r, argv)) {
20854
- const quoted = r.argv.map(quoteWord).join(" ");
20855
- return failed2(
20856
- "EACCES",
20857
- `sudo: ${self.name} may no longer ask to run ${quoted} as ${target.name}`
20858
- );
20859
- }
20870
+ const rules = await this.replayRules(self, target, r, argv);
20871
+ const denied2 = () => failed2(
20872
+ "EACCES",
20873
+ `sudo: ${self.name} may no longer ask to run ${r.argv.map(quoteWord).join(" ")} as ${target.name}`
20874
+ );
20875
+ if (rules?.length === 0) return denied2();
20860
20876
  if (await this.canonical(r.cwd) !== r.cwd) {
20861
20877
  return failed2("EACCES", `sudo: ${r.cwd} changed since it was requested`);
20862
20878
  }
@@ -20885,6 +20901,8 @@ ${SCRIPT_HELP}
20885
20901
  const hint = missing7.length && changedFile(r.bound, bound3.hashes) === void 0 ? `; the saved request lacks ${missing7.join(" and ")}; pass back the whole request from approve unchanged` : "";
20886
20902
  return failed2("EPERM", requestedText(word) + hint);
20887
20903
  }
20904
+ if (bound3.writableEnvPath && rules && !rules.some((rule2) => pinned(rule2, bound3.hashes, bound3)))
20905
+ return denied2();
20888
20906
  const now = await this.rootOnly(r.cwd, args);
20889
20907
  const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
20890
20908
  if (flipped !== void 0) return failed2("EPERM", `sudo: ${flipped} is no longer root-only`);
@@ -20905,12 +20923,12 @@ ${SCRIPT_HELP}
20905
20923
  );
20906
20924
  return { grant, caller: self, target, tags: r.tags };
20907
20925
  }
20908
- async mayAsk(self, target, r, argv) {
20909
- if (self.uid === 0) return true;
20926
+ async replayRules(self, target, r, argv) {
20927
+ if (self.uid === 0) return void 0;
20910
20928
  const cred = credOf(self);
20911
20929
  const { rules } = await this.policyRules({ cred, pid: 0, stdin: r.stdin });
20912
20930
  const applies = await this.applies(self, cred);
20913
- return rules.some(
20931
+ return rules.filter(
20914
20932
  (rule2) => applies(rule2.who) && (rule2.target === "ALL" || rule2.target === target.name) && (rule2.cwd === void 0 || rule2.cwd === r.cwd) && stdinMatches(rule2, r.stdin) && commandMatches(rule2.cmnd, argv) && pinned(rule2, r.bound, r)
20915
20933
  );
20916
20934
  }
@@ -20976,7 +20994,7 @@ ${SCRIPT_HELP}
20976
20994
  const result = answer2.answer === "once" ? grant() : await this.always(
20977
20995
  self,
20978
20996
  target,
20979
- { cwd, argv, bound: bound3.hashes, ...proof },
20997
+ { cwd, argv, bound: bound3.hashes, ...durableProof(now) },
20980
20998
  shown2,
20981
20999
  grant
20982
21000
  );
@@ -38576,7 +38594,7 @@ function expandDefaults(defaults2, env) {
38576
38594
  return out;
38577
38595
  }
38578
38596
  function targetOf(command, reads) {
38579
- reads?.include(command.manifests);
38597
+ reads?.include(command.manifests, command.envPaths);
38580
38598
  return {
38581
38599
  abi: command.abi,
38582
38600
  command: command.name,
@@ -39444,7 +39462,7 @@ var Launcher = class {
39444
39462
  const at = direct ? file : await this.followCommand(this.fs.resolvePath(cwd, file), reads, parentHops);
39445
39463
  const command = await this.commandAt(at, scope, reads);
39446
39464
  if (!command?.script) return void 0;
39447
- reads?.include(command.manifests);
39465
+ reads?.include(command.manifests, command.envPaths);
39448
39466
  return command;
39449
39467
  }
39450
39468
  async mayRead(reader, path, reads) {