kritya 0.8.70-beta → 0.8.71-beta

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.
@@ -25,6 +25,22 @@ function git(cwd, args, timeout = 15_000) {
25
25
  export function isGitRepo(workspace) {
26
26
  return git(workspace, ["rev-parse", "--is-inside-work-tree"]).ok;
27
27
  }
28
+ /**
29
+ * Tracked files in `workspace` that are local, per-machine settings files
30
+ * (basename `settings.local.json`, typically under a dot-directory config
31
+ * folder). Such files collect approved commands and can carry credentials,
32
+ * so they are meant to stay out of version control entirely; a tracked one
33
+ * is a leak waiting for the next push. Returns [] outside a git repository.
34
+ */
35
+ export function trackedLocalSettingsFiles(workspace) {
36
+ const res = git(workspace, ["ls-files"]);
37
+ if (!res.ok)
38
+ return [];
39
+ return res.out
40
+ .split("\n")
41
+ .map((f) => f.trim())
42
+ .filter((f) => f !== "" && f.split("/").pop() === "settings.local.json");
43
+ }
28
44
  /**
29
45
  * Creates a fresh branch + worktree off the current HEAD so a write subagent
30
46
  * can edit and run commands without ever touching the user's real working
@@ -6,7 +6,7 @@ import { BUILTIN_PROVIDERS, CONFIG_DIR, CONFIG_FILE, legacyGlobalModel, loadConf
6
6
  import { defaultModelFor, contextWindowFor } from "../config/models.js";
7
7
  import { retentionDaysFor } from "../config/retention.js";
8
8
  import { assertJsonWithinLimits } from "../config/jsonSafety.js";
9
- import { isGitRepo } from "../agent/worktree.js";
9
+ import { isGitRepo, trackedLocalSettingsFiles } from "../agent/worktree.js";
10
10
  import { loadHooks } from "../hooks/hooks.js";
11
11
  import { loadProjectMcpServers, missingVars } from "../mcp/servers.js";
12
12
  import { scanSkillsDetailed, skillsDir, userSkillsDir } from "../agent/skills.js";
@@ -235,6 +235,17 @@ function workspaceSection(workspace, config) {
235
235
  checks.push(isGitRepo(workspace)
236
236
  ? ok("git repository")
237
237
  : warn("not a git repository — /commit and isolated write subagents are unavailable"));
238
+ // Local settings files (settings.local.json) hold per-machine state —
239
+ // approved commands, and with them anything the command carried, including
240
+ // credentials. One that git tracks will be shared with everyone who clones
241
+ // the repository, so it gets a warning even though nothing is broken yet.
242
+ if (isGitRepo(workspace)) {
243
+ for (const file of trackedLocalSettingsFiles(workspace)) {
244
+ checks.push(warn(`${file} is tracked by git — local settings files can contain approved ` +
245
+ `commands and credentials and should not be committed; untrack it ` +
246
+ `(git rm --cached) and add it to .gitignore`));
247
+ }
248
+ }
238
249
  // Trust gates the workspace's own settings.json allow rules, hooks, .env and
239
250
  // custom commands. Worth stating explicitly: an untrusted workspace looks
240
251
  // like "my hooks just don't run".
@@ -1,3 +1,4 @@
1
+ import { scanForSecrets } from "../tools/secretScan.js";
1
2
  import { matchesRule } from "./rules.js";
2
3
  /**
3
4
  * Permission policy. Read-only tools never prompt; mutating tools prompt
@@ -22,6 +23,22 @@ function alwaysAllowKey(toolName, args) {
22
23
  const command = String(args.command ?? "").trim();
23
24
  return command ? `shell:${command}` : "shell";
24
25
  }
26
+ /**
27
+ * Whether any string argument of a call carries a secret-shaped value (for
28
+ * shell, the command string itself; for file tools, a path or a content
29
+ * payload). Used to keep such calls out of the "always allow" table: the
30
+ * recorded key for shell *is* the verbatim command, so remembering an
31
+ * approval for a command that embeds a literal credential would keep that
32
+ * credential in the approval table and silently re-run it for the rest of
33
+ * the session. A secret-bearing call can still be approved — once.
34
+ */
35
+ export function argsContainSecret(args) {
36
+ for (const value of Object.values(args)) {
37
+ if (typeof value === "string" && scanForSecrets(value).length > 0)
38
+ return true;
39
+ }
40
+ return false;
41
+ }
25
42
  export class PermissionManager {
26
43
  alwaysAllowed = new Set();
27
44
  allow;
@@ -50,8 +67,14 @@ export class PermissionManager {
50
67
  return !this.allow.some((rule) => matchesRule(rule, tool.name, args, this.workspace));
51
68
  }
52
69
  record(toolName, decision, args = {}) {
53
- if (decision === "always")
54
- this.alwaysAllowed.add(alwaysAllowKey(toolName, args));
70
+ if (decision !== "always")
71
+ return;
72
+ // Never record an "always" decision for a call whose arguments carry a
73
+ // secret-shaped value — see argsContainSecret. The approval stands for
74
+ // this one call; the next identical call prompts again.
75
+ if (argsContainSecret(args))
76
+ return;
77
+ this.alwaysAllowed.add(alwaysAllowKey(toolName, args));
55
78
  }
56
79
  /**
57
80
  * True if this call is pre-approved by an earlier "always allow" choice this
@@ -1,6 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { CONFIG_DIR } from "../config/config.js";
4
+ import { warnUser } from "../config/debug.js";
5
+ import { scanForSecrets } from "../tools/secretScan.js";
4
6
  export function loadRules(workspace, trustWorkspace = true) {
5
7
  const allow = [];
6
8
  const deny = [];
@@ -11,11 +13,33 @@ export function loadRules(workspace, trustWorkspace = true) {
11
13
  for (const { file, includeAllow } of files) {
12
14
  try {
13
15
  const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
16
+ // Settings files are exactly the kind of file that gets shared with a
17
+ // team or committed to a repository, so a rule must never carry a
18
+ // literal credential (e.g. an approved command with a password or a
19
+ // token spelled out in it). Such rules are dropped, not applied, and
20
+ // the warning names only the redacted match — never the value itself.
21
+ const dropped = [];
22
+ const clean = (r) => {
23
+ if (typeof r !== "string")
24
+ return false;
25
+ const matches = scanForSecrets(r);
26
+ if (matches.length === 0)
27
+ return true;
28
+ for (const m of matches)
29
+ dropped.push(`${m.kind} (${m.snippet})`);
30
+ return false;
31
+ };
14
32
  if (includeAllow && Array.isArray(parsed.allow)) {
15
- allow.push(...parsed.allow.filter((r) => typeof r === "string"));
33
+ allow.push(...parsed.allow.filter(clean));
16
34
  }
17
35
  if (Array.isArray(parsed.deny)) {
18
- deny.push(...parsed.deny.filter((r) => typeof r === "string"));
36
+ deny.push(...parsed.deny.filter(clean));
37
+ }
38
+ if (dropped.length > 0) {
39
+ warnUser(`permission rules in ${file}`, new Error(`dropped ${dropped.length} rule(s) containing what looks like a secret ` +
40
+ `(${dropped.join(", ")}). Settings files are often shared or committed, ` +
41
+ `so a literal credential must never be written into a rule — reference ` +
42
+ `the value from the environment instead (e.g. $API_KEY).`));
19
43
  }
20
44
  }
21
45
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kritya",
3
- "version": "0.8.70-beta",
3
+ "version": "0.8.71-beta",
4
4
  "description": "Kritya — Superintelligence at your command line",
5
5
  "type": "module",
6
6
  "publishConfig": {