@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.
@@ -9883,7 +9883,7 @@ function satisfies(version, range2) {
9883
9883
  }
9884
9884
 
9885
9885
  // src/version.ts
9886
- var KERNEL_VERSION = true ? "1.196.22" : "0.0.0-dev";
9886
+ var KERNEL_VERSION = true ? "1.196.23" : "0.0.0-dev";
9887
9887
  var OS_RELEASE = "6.0.0-slicc";
9888
9888
  function procVersion() {
9889
9889
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -10028,14 +10028,16 @@ function commandsOf(pkg, manifest) {
10028
10028
  }
10029
10029
  return out;
10030
10030
  }
10031
- async function withPackagePaths(fs, pkg, command) {
10031
+ async function withPackagePaths(fs, pkg, command, provenance) {
10032
10032
  if (!command.env) return command;
10033
10033
  const env = {};
10034
+ const envPaths = /* @__PURE__ */ new Set();
10034
10035
  for (const [key, value2] of Object.entries(command.env)) {
10035
10036
  const path = !value2.startsWith("/") && value2.includes("/") && inside(pkg, value2);
10037
+ if (path && provenance) envPaths.add(path);
10036
10038
  env[key] = path && await fs.exists(path) ? path : value2;
10037
10039
  }
10038
- return { ...command, env };
10040
+ return { ...command, env, ...envPaths.size ? { envPaths: [...envPaths] } : {} };
10039
10041
  }
10040
10042
  async function packages(fs, modules) {
10041
10043
  const names2 = await fs.readdir(modules).catch(() => []);
@@ -10230,7 +10232,7 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY, ke
10230
10232
  );
10231
10233
  const take = async (tier) => {
10232
10234
  for (const [name2, { pkg, command }] of winners(tier)) {
10233
- if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command));
10235
+ if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command, provenance));
10234
10236
  }
10235
10237
  };
10236
10238
  const dependencies = [];
@@ -22662,6 +22664,7 @@ var SudoReads = class {
22662
22664
  documents = /* @__PURE__ */ new Map();
22663
22665
  texts = /* @__PURE__ */ new Map();
22664
22666
  relevant = /* @__PURE__ */ new Set();
22667
+ envPaths = /* @__PURE__ */ new Set();
22665
22668
  verified = /* @__PURE__ */ new Set();
22666
22669
  interpreters = [];
22667
22670
  chainSha256;
@@ -22681,11 +22684,13 @@ var SudoReads = class {
22681
22684
  }
22682
22685
  resetSelection() {
22683
22686
  this.relevant.clear();
22687
+ this.envPaths.clear();
22684
22688
  this.interpreters.length = 0;
22685
22689
  delete this.chainSha256;
22686
22690
  this.operandsFromEnd.clear();
22687
22691
  }
22688
- include(paths) {
22692
+ include(paths, envPaths) {
22693
+ for (const path of envPaths ?? []) this.envPaths.add(path);
22689
22694
  for (const path of paths ?? []) if (this.verified.has(path)) this.relevant.add(path);
22690
22695
  }
22691
22696
  async digest(path) {
@@ -22777,6 +22782,12 @@ var SudoReads = class {
22777
22782
  ...scripts.length ? { scripts } : {},
22778
22783
  ...this.chainSha256 ? { chainSha256: this.chainSha256 } : {}
22779
22784
  };
22785
+ for (const path of this.envPaths) {
22786
+ if (!await this.access.trustedEnvPath(path)) {
22787
+ binding.writableEnvPath = true;
22788
+ break;
22789
+ }
22790
+ }
22780
22791
  if (!Object.keys(routes).some((path) => path !== routes[path])) return binding;
22781
22792
  const pairs = Object.keys(routes).sort().map((path) => [path, routes[path]]);
22782
22793
  const routeSha256 = await sha256(new TextEncoder().encode(JSON.stringify(pairs)));
@@ -23491,7 +23502,9 @@ function changedFile(approved, now) {
23491
23502
  return [...files].find((file) => approved[file] !== now[file]);
23492
23503
  }
23493
23504
  function pinned(rule, hashes, proof) {
23494
- return rule.sha256 === void 0 || rule.routeSha256 === proof.routeSha256 && (rule.chainSha256 === void 0 || rule.chainSha256 === proof.chainSha256) && changedFile(rule.sha256, hashes) === void 0;
23505
+ if (!rule.sha256) return true;
23506
+ if (proof.writableEnvPath && !rule.chainSha256 && !Object.keys(rule.sha256).length) return false;
23507
+ return rule.routeSha256 === proof.routeSha256 && (rule.chainSha256 === void 0 || rule.chainSha256 === proof.chainSha256) && changedFile(rule.sha256, hashes) === void 0;
23495
23508
  }
23496
23509
  function changedManifests(rules, bound3) {
23497
23510
  const changed2 = /* @__PURE__ */ new Set();
@@ -23512,8 +23525,11 @@ function proofOf({ routeSha256, chainSha256 }) {
23512
23525
  function changedDecision(hashes, proof, now, path) {
23513
23526
  return changedFile(hashes, now.hashes) ?? (proof.routeSha256 !== now.routeSha256 || proof.chainSha256 !== now.chainSha256 ? path : void 0);
23514
23527
  }
23528
+ function durableProof(files) {
23529
+ return files.writableEnvPath || Object.keys(files.hashes).length ? proofOf(files) : {};
23530
+ }
23515
23531
  function stampOf(files) {
23516
- return Object.keys(files.hashes).length ? { ...files.hashes, ...proofOf(files) } : files.hashes;
23532
+ return { ...files.hashes, ...durableProof(files) };
23517
23533
  }
23518
23534
  var REPLAY_ID = /^[!-~]{1,256}$/;
23519
23535
  var REPLAY_TAGS_MAX = 64;
@@ -23970,6 +23986,7 @@ var Sudo = class {
23970
23986
  {
23971
23987
  real: (at) => this.real(at),
23972
23988
  trusted: (at) => this.trustedThrough(at, void 0, fs),
23989
+ trustedEnvPath: (at) => this.trusted(at, true),
23973
23990
  read: (at) => fs.readFileBuffer(at)
23974
23991
  },
23975
23992
  snapshots
@@ -24090,13 +24107,12 @@ ${SCRIPT_HELP}
24090
24107
  const cred = credOf(self);
24091
24108
  const [word = "", ...args] = r.argv;
24092
24109
  const argv = [r.path, ...args];
24093
- if (!await this.mayAsk(self, target, r, argv)) {
24094
- const quoted = r.argv.map(quoteWord).join(" ");
24095
- return failed2(
24096
- "EACCES",
24097
- `sudo: ${self.name} may no longer ask to run ${quoted} as ${target.name}`
24098
- );
24099
- }
24110
+ const rules = await this.replayRules(self, target, r, argv);
24111
+ const denied2 = () => failed2(
24112
+ "EACCES",
24113
+ `sudo: ${self.name} may no longer ask to run ${r.argv.map(quoteWord).join(" ")} as ${target.name}`
24114
+ );
24115
+ if (rules?.length === 0) return denied2();
24100
24116
  if (await this.canonical(r.cwd) !== r.cwd) {
24101
24117
  return failed2("EACCES", `sudo: ${r.cwd} changed since it was requested`);
24102
24118
  }
@@ -24125,6 +24141,8 @@ ${SCRIPT_HELP}
24125
24141
  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` : "";
24126
24142
  return failed2("EPERM", requestedText(word) + hint);
24127
24143
  }
24144
+ if (bound3.writableEnvPath && rules && !rules.some((rule) => pinned(rule, bound3.hashes, bound3)))
24145
+ return denied2();
24128
24146
  const now = await this.rootOnly(r.cwd, args);
24129
24147
  const flipped = Object.keys(r.rootOnly).find((at) => r.rootOnly[at] && now[at] !== true);
24130
24148
  if (flipped !== void 0) return failed2("EPERM", `sudo: ${flipped} is no longer root-only`);
@@ -24145,12 +24163,12 @@ ${SCRIPT_HELP}
24145
24163
  );
24146
24164
  return { grant, caller: self, target, tags: r.tags };
24147
24165
  }
24148
- async mayAsk(self, target, r, argv) {
24149
- if (self.uid === 0) return true;
24166
+ async replayRules(self, target, r, argv) {
24167
+ if (self.uid === 0) return void 0;
24150
24168
  const cred = credOf(self);
24151
24169
  const { rules } = await this.policyRules({ cred, pid: 0, stdin: r.stdin });
24152
24170
  const applies = await this.applies(self, cred);
24153
- return rules.some(
24171
+ return rules.filter(
24154
24172
  (rule) => applies(rule.who) && (rule.target === "ALL" || rule.target === target.name) && (rule.cwd === void 0 || rule.cwd === r.cwd) && stdinMatches(rule, r.stdin) && commandMatches(rule.cmnd, argv) && pinned(rule, r.bound, r)
24155
24173
  );
24156
24174
  }
@@ -24216,7 +24234,7 @@ ${SCRIPT_HELP}
24216
24234
  const result = answer2.answer === "once" ? grant() : await this.always(
24217
24235
  self,
24218
24236
  target,
24219
- { cwd, argv, bound: bound3.hashes, ...proof },
24237
+ { cwd, argv, bound: bound3.hashes, ...durableProof(now) },
24220
24238
  shown2,
24221
24239
  grant
24222
24240
  );
@@ -38627,7 +38645,7 @@ function expandDefaults(defaults2, env) {
38627
38645
  return out;
38628
38646
  }
38629
38647
  function targetOf(command, reads) {
38630
- reads?.include(command.manifests);
38648
+ reads?.include(command.manifests, command.envPaths);
38631
38649
  return {
38632
38650
  abi: command.abi,
38633
38651
  command: command.name,
@@ -39495,7 +39513,7 @@ var Launcher = class {
39495
39513
  const at = direct ? file : await this.followCommand(this.fs.resolvePath(cwd, file), reads, parentHops);
39496
39514
  const command = await this.commandAt(at, scope, reads);
39497
39515
  if (!command?.script) return void 0;
39498
- reads?.include(command.manifests);
39516
+ reads?.include(command.manifests, command.envPaths);
39499
39517
  return command;
39500
39518
  }
39501
39519
  async mayRead(reader, path, reads) {