@exorcist-98/cli 0.3.3 → 0.3.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/README.md CHANGED
@@ -11,7 +11,7 @@ Needs Node 20 or newer.
11
11
  ## Scan a project
12
12
 
13
13
  ```sh
14
- npx -y @exorcist-98/cli@0.3.3 scan .
14
+ npx -y @exorcist-98/cli@0.3.4 scan .
15
15
  ```
16
16
 
17
17
  Every finding shows the file, line, the exact text, how serious it is and how
@@ -39,7 +39,7 @@ request.
39
39
  ## Map the haunted house
40
40
 
41
41
  ```sh
42
- npx -y @exorcist-98/cli@0.3.3 map .
42
+ npx -y @exorcist-98/cli@0.3.4 map .
43
43
  ```
44
44
 
45
45
  For every MCP config in the folder, lists which servers sit in the three rooms
@@ -52,8 +52,8 @@ data. The rules are in `definitions/capabilities.yaml`.
52
52
  ## Disinfect (exorcise)
53
53
 
54
54
  ```sh
55
- npx -y @exorcist-98/cli@0.3.3 exorcise . # dry run: prints a unified diff
56
- npx -y @exorcist-98/cli@0.3.3 exorcise . --write # apply, with a vault backup first
55
+ npx -y @exorcist-98/cli@0.3.4 exorcise . # dry run: prints a unified diff
56
+ npx -y @exorcist-98/cli@0.3.4 exorcise . --write # apply, with a vault backup first
57
57
  ```
58
58
 
59
59
  Only threats with one safe, mechanical fix are repaired: hidden characters
@@ -67,7 +67,7 @@ human"), and `exorcist vault restore <id>` puts every file back byte for byte.
67
67
  ## Protect your MCP servers
68
68
 
69
69
  ```sh
70
- npx -y @exorcist-98/cli@0.3.3 wrap .kiro/settings/mcp.json
70
+ npx -y @exorcist-98/cli@0.3.4 wrap .kiro/settings/mcp.json
71
71
  ```
72
72
 
73
73
  `wrap` puts every server in the file, local or remote, behind the Real-Time
@@ -79,9 +79,9 @@ instruct your agent. `unwrap` restores the file exactly. See
79
79
  ## Share approved tools with your team: exorcist.lock
80
80
 
81
81
  ```sh
82
- npx -y @exorcist-98/cli@0.3.3 lock # write exorcist.lock, then commit it
83
- npx -y @exorcist-98/cli@0.3.3 lock --check # exit 1 if any tool or program changed
84
- npx -y @exorcist-98/cli@0.3.3 lock --check --static # starts nothing: names, programs, URLs only
82
+ npx -y @exorcist-98/cli@0.3.4 lock # write exorcist.lock, then commit it
83
+ npx -y @exorcist-98/cli@0.3.4 lock --check # exit 1 if any tool or program changed
84
+ npx -y @exorcist-98/cli@0.3.4 lock --check --static # starts nothing: names, programs, URLs only
85
85
  ```
86
86
 
87
87
  `exorcist.lock` records the fingerprint of every tool your MCP servers list,
package/dist/index.mjs CHANGED
@@ -22905,12 +22905,30 @@ function envFamilyOwners(name) {
22905
22905
  for (const [re2, owners] of ENV_FAMILIES) if (re2.test(name)) return owners;
22906
22906
  return null;
22907
22907
  }
22908
- function envAssignRisk(name, value, cwd, dynamic = false, known) {
22908
+ var PATH_VAR = /(?:CONFIG|_FILES?|_DIR|_HOME|_PATH|_PLUGINS?|CACHEDIR|_CERT\w*|_CA\w*)$/;
22909
+ var ENDPOINT_VAR = /(?:_HOST|_URL|_ENDPOINT|_SERVER)$/;
22910
+ function unlockedValueRisk(name, value, cwd, dynamic) {
22911
+ const runtime = dynamic || /[$`]/.test(value);
22912
+ const say = `${name} is set to a path inside the project, or to a value built at run time, and a tool config can name a program to run or a daemon to reach`;
22913
+ if (runtime) return say;
22914
+ if (PATH_VAR.test(name) && anyInside(value, cwd)) return say;
22915
+ for (const part of value.split(/[\s:,;=]+/u)) {
22916
+ if (part !== "" && (/^[./~]/u.test(part) || part.includes("/")) && insideProject(part, cwd)) return say;
22917
+ }
22918
+ if (ENDPOINT_VAR.test(name)) {
22919
+ const m = /^(?:unix|npipe|file):\/\/(.*)$/.exec(value);
22920
+ const target = m === null ? value : m[1];
22921
+ if ((m !== null || /^[./~]/.test(target)) && insideProject(target, cwd)) return say;
22922
+ }
22923
+ return null;
22924
+ }
22925
+ function envAssignRisk(name, value, cwd, dynamic = false, known, prog) {
22909
22926
  const owners = envFamilyOwners(name);
22910
22927
  if (owners !== null) {
22911
22928
  if (name === "HELM_PLUGINS") return "HELM_PLUGINS names a folder of helm plugins, which are programs, and the guard always refuses it. The person can run it in their own terminal";
22912
22929
  const list2 = known ?? userKnownPrograms();
22913
- if (owners.some((o) => list2.has(o))) return null;
22930
+ const unlocked = prog === void 0 ? owners.some((o) => list2.has(o)) : owners.includes(prog) && list2.has(prog);
22931
+ if (unlocked) return unlockedValueRisk(name, value, cwd, dynamic);
22914
22932
  return `${name} belongs to the environment of ${owners[0]}, and its variables change what the tool runs or trusts (config files, plugins, endpoints, certificates, helpers). The guard refuses them whatever the value. To allow it, add "${owners[0]}" to the list of programs in your own user config, ${KNOWN_PROGRAMS_HINT} (a list inside a repository is never read)`;
22915
22933
  }
22916
22934
  if (!RISK_ENV.test(name)) return null;
@@ -23082,7 +23100,7 @@ function route(tool, args, c) {
23082
23100
  const bad = entry.check?.(parsed.pos, parsed.opts, c) ?? null;
23083
23101
  if (bad !== null) return blocked(n, `${n} ${key}`, bad);
23084
23102
  if (entry.stop !== void 0) {
23085
- const ep = parsed.opts.find((o) => o.name === "--entrypoint")?.value;
23103
+ const ep = parsed.opts.filter((o) => o.name === "--entrypoint").pop()?.value;
23086
23104
  const inner = [...ep === void 0 ? [] : [ep], ...parsed.rest ?? []];
23087
23105
  return inner.length === 0 ? plain : { kind: "follow", words: inner };
23088
23106
  }
@@ -23163,8 +23181,8 @@ var KUBE_NEVER = /* @__PURE__ */ new Map([
23163
23181
  ["--server", "was given a server address, and the request would carry your credentials to it"]
23164
23182
  ]);
23165
23183
  var tableOutputOnly = (_pos, opts) => {
23166
- const o = opts.find((x) => x.name === "-o" || x.name === "--output");
23167
- return o === void 0 || o.value !== void 0 && ["wide", "name"].includes(t(o.value)) ? null : "was asked for an output format other than the plain table (wide or name), and yaml, json and templates return secret values";
23184
+ const outs = opts.filter((x) => x.name === "-o" || x.name === "--output");
23185
+ return outs.every((o) => o.value !== void 0 && ["wide", "name"].includes(t(o.value).replace(/^=/, ""))) ? null : "was asked for an output format other than the plain table (wide or name), and yaml, json and templates return secret values";
23168
23186
  };
23169
23187
  var KUBECTL_TOOL = {
23170
23188
  name: "kubectl",
@@ -23310,11 +23328,11 @@ var TOOLS = {
23310
23328
  };
23311
23329
  function devToolPlan(prog, args, ctx = {}) {
23312
23330
  const c = { env: ctx.env ?? {}, known: ctx.known ?? userKnownPrograms(), ...ctx.cwd === void 0 ? {} : { cwd: ctx.cwd } };
23313
- if (c.known.has(prog)) return plain;
23314
23331
  for (const [k, v] of Object.entries(c.env)) {
23315
- const risk = envAssignRisk(k, v, c.cwd, false, c.known);
23332
+ const risk = envAssignRisk(k, v, c.cwd, false, c.known, prog);
23316
23333
  if (risk !== null) return blocked(prog, prog, `was given ${risk}`);
23317
23334
  }
23335
+ if (c.known.has(prog)) return plain;
23318
23336
  const unreadable = args.find((w) => w.dynamic || w.glob);
23319
23337
  if (unreadable !== void 0) return blocked(prog, prog, "was given a word built at run time (a variable, a substitution or a pattern), and the guard cannot read what it will be");
23320
23338
  switch (prog) {
@@ -23856,7 +23874,8 @@ function resolveWords(words2, f, ctx) {
23856
23874
  const env = { ...f.env };
23857
23875
  let i = skipFlags(words2, 1, WRAP_SPECS[prog], prog, prog === "env" || prog === "sudo" || prog === "doas" ? env : void 0);
23858
23876
  if (prog === "env" || prog === "sudo" || prog === "doas") {
23859
- for (const [k, v] of Object.entries(env)) if (f.env[k] !== v) checkAssign(ctx, k, v, /[$`]/.test(v));
23877
+ const inner = words2[i] !== void 0 && !words2[i]?.dynamic && !words2[i]?.glob ? progName(words2[i].text) : void 0;
23878
+ for (const [k, v] of Object.entries(env)) if (f.env[k] !== v) checkAssign(ctx, k, v, /[$`]/.test(v), inner);
23860
23879
  }
23861
23880
  if (prog === "timeout") {
23862
23881
  if (words2[i] === void 0 || words2[i]?.dynamic) reject("timeout has no fixed duration");
@@ -24031,9 +24050,14 @@ function producedText(e) {
24031
24050
  }
24032
24051
  var ENV_DECLARERS = /* @__PURE__ */ new Set(["export", "declare", "typeset", "readonly", "local"]);
24033
24052
  var ASSIGN_WORD = /^([A-Za-z_][A-Za-z0-9_]*)=([\s\S]*)$/;
24034
- function checkAssign(ctx, name, value, dynamic) {
24053
+ function literalProg(words2) {
24054
+ const w = words2[0];
24055
+ if (w === void 0 || w.dynamic || w.glob || ENV_DECLARERS.has(w.text)) return void 0;
24056
+ return progName(w.text);
24057
+ }
24058
+ function checkAssign(ctx, name, value, dynamic, prog) {
24035
24059
  if (ctx.mode !== "agent") return;
24036
- const why = envAssignRisk(name, value, ctx.cwd, dynamic);
24060
+ const why = envAssignRisk(name, value, ctx.cwd, dynamic, void 0, prog);
24037
24061
  if (why !== null) reject(`${why}. If you trust it, the person can run it in their own terminal`, FIX_SIMPLE);
24038
24062
  }
24039
24063
  function resolveCommands(commands, ctx, via, baseEnv) {
@@ -24043,7 +24067,7 @@ function resolveCommands(commands, ctx, via, baseEnv) {
24043
24067
  for (const c of commands) {
24044
24068
  const env = { ...persist };
24045
24069
  for (const a of c.assigns) {
24046
- checkAssign(ctx, a.name, a.value.text, a.value.dynamic);
24070
+ checkAssign(ctx, a.name, a.value.text, a.value.dynamic, literalProg(c.words));
24047
24071
  env[a.name] = a.value.text;
24048
24072
  }
24049
24073
  let stdinText = null;
@@ -25753,7 +25777,7 @@ async function* scanRepo(root, options) {
25753
25777
  init_zod();
25754
25778
 
25755
25779
  // ../core/src/version.ts
25756
- var SCANNER_VERSION = "0.3.3";
25780
+ var SCANNER_VERSION = "0.3.4";
25757
25781
 
25758
25782
  // ../core/src/reporters/json-reporter.ts
25759
25783
  var ScanStatsSchema = external_exports.object({
@@ -38404,7 +38428,7 @@ unwrap Put the original file back byte for byte, if it was not edited since
38404
38428
 
38405
38429
  Options (wrap):
38406
38430
  --bin <command> Command that runs the shield (default: exorcist)
38407
- --bin-arg <arg> Argument before "shield" (repeatable), e.g. --bin npx --bin-arg -y --bin-arg @exorcist-98/cli@0.3.3
38431
+ --bin-arg <arg> Argument before "shield" (repeatable), e.g. --bin npx --bin-arg -y --bin-arg @exorcist-98/cli@0.3.4
38408
38432
  --dir <folder> State folder (default: ${DEFAULT_DIR})
38409
38433
  --dry-run Show the result without writing the file
38410
38434
  `;
@@ -40478,8 +40502,8 @@ function reviewerAgentForProject(mcpCommand) {
40478
40502
  }
40479
40503
 
40480
40504
  // src/commands/init.ts
40481
- var DEFAULT_BIN = "npx -y @exorcist-98/cli@0.3.3";
40482
- var DEFAULT_MCP_BIN = "npx -y @exorcist-98/mcp-server@0.3.3";
40505
+ var DEFAULT_BIN = "npx -y @exorcist-98/cli@0.3.4";
40506
+ var DEFAULT_MCP_BIN = "npx -y @exorcist-98/mcp-server@0.3.4";
40483
40507
  var MISSING_FROM_DEFAULT_BIN = /* @__PURE__ */ new Set();
40484
40508
  var INIT_HELP = `Usage: exorcist init [folder] [--kiro] [--shield] [--sandbox] [--no-agent] [--force]
40485
40509
  [--bin <command>] [--mcp-bin <command>]
@@ -40848,7 +40872,7 @@ ${INIT_HELP}`);
40848
40872
  "then reconnect MCP servers in the MCP panel so they start through the Shield."
40849
40873
  ];
40850
40874
  if (isDefaultBin) {
40851
- lines.push("Commands run through npx (@exorcist-98/cli@0.3.3). If Kiro cannot start a wrapped server or a hook cannot find npx,");
40875
+ lines.push("Commands run through npx (@exorcist-98/cli@0.3.4). If Kiro cannot start a wrapped server or a hook cannot find npx,");
40852
40876
  lines.push('rerun with --bin "<absolute path to node> <absolute path to the exorcist CLI>" and --force.');
40853
40877
  }
40854
40878
  io.out(lines.join("\n"));
@@ -48231,7 +48255,7 @@ var RawToolsPage = external_exports.object({ tools: external_exports.array(exter
48231
48255
  var firstLine2 = (err) => (err instanceof Error ? err.message : String(err)).split("\n")[0]?.slice(0, 300) ?? "unknown error";
48232
48256
  async function listTools(o) {
48233
48257
  const transport = new StdioClientTransport({ command: o.command, args: o.args, env: o.env, cwd: o.cwd, stderr: "ignore" });
48234
- const client = new Client({ name: "exorcist-lock", version: "0.3.3" }, { capabilities: {} });
48258
+ const client = new Client({ name: "exorcist-lock", version: "0.3.4" }, { capabilities: {} });
48235
48259
  let timer;
48236
48260
  const timedOut = new Promise((res) => {
48237
48261
  timer = setTimeout(() => res({ ok: false, error: `it did not list its tools within ${o.timeoutMs} ms.` }), o.timeoutMs);
@@ -49129,7 +49153,7 @@ ${VAULT_HELP}`);
49129
49153
  }
49130
49154
 
49131
49155
  // src/index.ts
49132
- var VERSION = "0.3.3";
49156
+ var VERSION = "0.3.4";
49133
49157
  var HELP = `Exorcist 98 ${VERSION}: antivirus for AI coding agents
49134
49158
 
49135
49159
  Usage: exorcist <command> [options]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exorcist-98/cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Exorcist 98: antivirus for AI coding agents. Scan repos, shield MCP servers, quarantine threats.",