@exorcist-98/mcp-server 0.3.6 → 0.3.8
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 +1 -1
- package/definitions/EX-002-ai-instructions.yaml +1 -1
- package/definitions/EX-035-sandbox-mcp-off.yaml +1 -1
- package/definitions/EX-037-hide-action-from-user.yaml +8 -1
- package/definitions/EX-075-unrelated-order.yaml +37 -0
- package/dist/index.mjs +389 -146
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7083,7 +7083,7 @@ var require_compile = __commonJS({
|
|
|
7083
7083
|
const schOrFunc = root.refs[ref];
|
|
7084
7084
|
if (schOrFunc)
|
|
7085
7085
|
return schOrFunc;
|
|
7086
|
-
let _sch =
|
|
7086
|
+
let _sch = resolve11.call(this, root, ref);
|
|
7087
7087
|
if (_sch === void 0) {
|
|
7088
7088
|
const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
7089
7089
|
const { schemaId } = this.opts;
|
|
@@ -7110,7 +7110,7 @@ var require_compile = __commonJS({
|
|
|
7110
7110
|
function sameSchemaEnv(s1, s2) {
|
|
7111
7111
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
7112
7112
|
}
|
|
7113
|
-
function
|
|
7113
|
+
function resolve11(root, ref) {
|
|
7114
7114
|
let sch;
|
|
7115
7115
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
7116
7116
|
ref = sch;
|
|
@@ -7974,7 +7974,7 @@ var require_fast_uri = __commonJS({
|
|
|
7974
7974
|
}
|
|
7975
7975
|
return uri;
|
|
7976
7976
|
}
|
|
7977
|
-
function
|
|
7977
|
+
function resolve11(baseURI, relativeURI, options) {
|
|
7978
7978
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
7979
7979
|
const {
|
|
7980
7980
|
parsed: baseParsed,
|
|
@@ -8010,50 +8010,50 @@ var require_fast_uri = __commonJS({
|
|
|
8010
8010
|
schemelessOptions.skipEscape = true;
|
|
8011
8011
|
return serialize(resolved, schemelessOptions);
|
|
8012
8012
|
}
|
|
8013
|
-
function resolveComponent(base,
|
|
8013
|
+
function resolveComponent(base, relative8, options, skipNormalization) {
|
|
8014
8014
|
const target = {};
|
|
8015
8015
|
if (!skipNormalization) {
|
|
8016
8016
|
base = parse4(serialize(base, options), options);
|
|
8017
|
-
|
|
8017
|
+
relative8 = parse4(serialize(relative8, options), options);
|
|
8018
8018
|
}
|
|
8019
8019
|
options = options || {};
|
|
8020
|
-
if (!options.tolerant &&
|
|
8021
|
-
target.scheme =
|
|
8022
|
-
target.userinfo =
|
|
8023
|
-
target.host =
|
|
8024
|
-
target.port =
|
|
8025
|
-
target.path = removeDotSegments(
|
|
8026
|
-
target.query =
|
|
8020
|
+
if (!options.tolerant && relative8.scheme) {
|
|
8021
|
+
target.scheme = relative8.scheme;
|
|
8022
|
+
target.userinfo = relative8.userinfo;
|
|
8023
|
+
target.host = relative8.host;
|
|
8024
|
+
target.port = relative8.port;
|
|
8025
|
+
target.path = removeDotSegments(relative8.path || "");
|
|
8026
|
+
target.query = relative8.query;
|
|
8027
8027
|
} else {
|
|
8028
|
-
if (
|
|
8029
|
-
target.userinfo =
|
|
8030
|
-
target.host =
|
|
8031
|
-
target.port =
|
|
8032
|
-
target.path = removeDotSegments(
|
|
8033
|
-
target.query =
|
|
8028
|
+
if (relative8.userinfo !== void 0 || relative8.host !== void 0 || relative8.port !== void 0) {
|
|
8029
|
+
target.userinfo = relative8.userinfo;
|
|
8030
|
+
target.host = relative8.host;
|
|
8031
|
+
target.port = relative8.port;
|
|
8032
|
+
target.path = removeDotSegments(relative8.path || "");
|
|
8033
|
+
target.query = relative8.query;
|
|
8034
8034
|
} else {
|
|
8035
|
-
if (!
|
|
8035
|
+
if (!relative8.path) {
|
|
8036
8036
|
target.path = base.path;
|
|
8037
|
-
if (
|
|
8038
|
-
target.query =
|
|
8037
|
+
if (relative8.query !== void 0) {
|
|
8038
|
+
target.query = relative8.query;
|
|
8039
8039
|
} else {
|
|
8040
8040
|
target.query = base.query;
|
|
8041
8041
|
}
|
|
8042
8042
|
} else {
|
|
8043
|
-
if (
|
|
8044
|
-
target.path = removeDotSegments(
|
|
8043
|
+
if (relative8.path[0] === "/") {
|
|
8044
|
+
target.path = removeDotSegments(relative8.path);
|
|
8045
8045
|
} else {
|
|
8046
8046
|
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
8047
8047
|
if (baseHasAuthority && !base.path) {
|
|
8048
|
-
target.path = "/" +
|
|
8048
|
+
target.path = "/" + relative8.path;
|
|
8049
8049
|
} else if (!base.path) {
|
|
8050
|
-
target.path =
|
|
8050
|
+
target.path = relative8.path;
|
|
8051
8051
|
} else {
|
|
8052
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
8052
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative8.path;
|
|
8053
8053
|
}
|
|
8054
8054
|
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
8055
8055
|
}
|
|
8056
|
-
target.query =
|
|
8056
|
+
target.query = relative8.query;
|
|
8057
8057
|
}
|
|
8058
8058
|
target.userinfo = base.userinfo;
|
|
8059
8059
|
target.host = base.host;
|
|
@@ -8061,7 +8061,7 @@ var require_fast_uri = __commonJS({
|
|
|
8061
8061
|
}
|
|
8062
8062
|
target.scheme = base.scheme;
|
|
8063
8063
|
}
|
|
8064
|
-
target.fragment =
|
|
8064
|
+
target.fragment = relative8.fragment;
|
|
8065
8065
|
return target;
|
|
8066
8066
|
}
|
|
8067
8067
|
function equal(uriA, uriB, options) {
|
|
@@ -8365,7 +8365,7 @@ var require_fast_uri = __commonJS({
|
|
|
8365
8365
|
var fastUri = {
|
|
8366
8366
|
SCHEMES,
|
|
8367
8367
|
normalize: normalize3,
|
|
8368
|
-
resolve:
|
|
8368
|
+
resolve: resolve11,
|
|
8369
8369
|
resolveComponent,
|
|
8370
8370
|
equal,
|
|
8371
8371
|
serialize,
|
|
@@ -11810,14 +11810,14 @@ var init_severity_paths = __esm({
|
|
|
11810
11810
|
|
|
11811
11811
|
// ../core/src/walker.ts
|
|
11812
11812
|
import { opendir, stat, open, realpath } from "node:fs/promises";
|
|
11813
|
-
import { join as join5, relative as
|
|
11813
|
+
import { join as join5, relative as relative3, extname, basename as basename3, isAbsolute as isAbsolute3 } from "node:path";
|
|
11814
11814
|
function isAgentFacing(rel, role) {
|
|
11815
11815
|
if (!AGENT_FACING_ROLES.has(role)) return false;
|
|
11816
11816
|
return !(role === "config" && LOCKFILE_NAMES.has(rel.split("/").pop() ?? ""));
|
|
11817
11817
|
}
|
|
11818
11818
|
function classifyFile(rel) {
|
|
11819
11819
|
const norm = rel.replace(/\\/g, "/");
|
|
11820
|
-
const base =
|
|
11820
|
+
const base = basename3(norm);
|
|
11821
11821
|
const ext = extname(norm).toLowerCase();
|
|
11822
11822
|
if (base === "AGENTS.md" || base === "AGENT.md" || base === "CLAUDE.md" || base === "CLAUDE.local.md" || base === "GEMINI.md" || base === ".cursorrules" || base === ".windsurfrules" || base === ".clinerules" || norm.startsWith(".clinerules/") || norm.startsWith(".cursor/rules/") || norm.startsWith(".windsurf/rules/") || norm.startsWith(".amazonq/rules/") || norm === ".github/copilot-instructions.md" || norm.startsWith(".github/instructions/") || norm.startsWith(".github/prompts/") || /^\.claude\/(commands|agents|skills)\//.test(norm) || base === "SKILL.md" || base === "POWER.md" || /^power\/(?:[^/]+\/)*steering\/[^/]+$/.test(norm) || base.startsWith("README") || norm.startsWith(".kiro/steering/")) return "instruction";
|
|
11823
11823
|
if (/^power\/(?:[^/]+\/)*mcp\.json$/.test(norm) || norm.endsWith(".kiro/settings/mcp.json") || norm.endsWith(".cursor/mcp.json") || norm.endsWith(".vscode/mcp.json") || norm.endsWith(".amazonq/mcp.json") || norm.endsWith(".gemini/settings.json") || norm.endsWith(".claude/settings.json") || norm.endsWith(".claude/settings.local.json") || norm === "mcp.json" || norm === ".mcp.json" || base === "claude_desktop_config.json") return "mcp-config";
|
|
@@ -11861,7 +11861,7 @@ async function* walkPathsIn(root, dir) {
|
|
|
11861
11861
|
}
|
|
11862
11862
|
for await (const entry of dh) {
|
|
11863
11863
|
const absPath = join5(dir, entry.name);
|
|
11864
|
-
const rel =
|
|
11864
|
+
const rel = relative3(root, absPath).replace(/\\/g, "/");
|
|
11865
11865
|
if (entry.isDirectory()) {
|
|
11866
11866
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
11867
11867
|
yield { rel, isDirectory: true };
|
|
@@ -11886,7 +11886,7 @@ async function* fileRecord(ctx2, rel, readPath, size, link) {
|
|
|
11886
11886
|
}
|
|
11887
11887
|
if (size > ctx2.maxFileSize) {
|
|
11888
11888
|
if (!agent) {
|
|
11889
|
-
if (!TRUNCATE_ROLES.has(role) || LOCKFILE_NAMES.has(
|
|
11889
|
+
if (!TRUNCATE_ROLES.has(role) || LOCKFILE_NAMES.has(basename3(rel))) {
|
|
11890
11890
|
ctx2.note({ kind: "skipped", rel, reason: "too large", agentFacing: false });
|
|
11891
11891
|
return;
|
|
11892
11892
|
}
|
|
@@ -11917,14 +11917,14 @@ async function* walkDir(ctx2, dir, realDir, chain, isRoot = false) {
|
|
|
11917
11917
|
dh = await opendir(dir);
|
|
11918
11918
|
} catch (err2) {
|
|
11919
11919
|
if (isRoot) throw err2;
|
|
11920
|
-
const rel =
|
|
11920
|
+
const rel = relative3(ctx2.root, dir).replace(/\\/g, "/");
|
|
11921
11921
|
ctx2.note({ kind: "unreadable", rel, reason: reasonOf(err2), agentFacing: true });
|
|
11922
11922
|
return;
|
|
11923
11923
|
}
|
|
11924
11924
|
try {
|
|
11925
11925
|
for await (const entry of dh) {
|
|
11926
11926
|
const absPath = join5(dir, entry.name);
|
|
11927
|
-
const rel =
|
|
11927
|
+
const rel = relative3(ctx2.root, absPath).replace(/\\/g, "/");
|
|
11928
11928
|
if (entry.isDirectory()) {
|
|
11929
11929
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
11930
11930
|
const real = join5(realDir, entry.name);
|
|
@@ -11964,7 +11964,7 @@ async function* walkDir(ctx2, dir, realDir, chain, isRoot = false) {
|
|
|
11964
11964
|
}
|
|
11965
11965
|
}
|
|
11966
11966
|
} catch (err2) {
|
|
11967
|
-
const rel =
|
|
11967
|
+
const rel = relative3(ctx2.root, dir).replace(/\\/g, "/");
|
|
11968
11968
|
ctx2.note({ kind: "unreadable", rel, reason: reasonOf(err2), agentFacing: true });
|
|
11969
11969
|
}
|
|
11970
11970
|
}
|
|
@@ -12006,7 +12006,7 @@ var init_walker = __esm({
|
|
|
12006
12006
|
".nyc_output"
|
|
12007
12007
|
]);
|
|
12008
12008
|
isInside = (root, target) => {
|
|
12009
|
-
const rel =
|
|
12009
|
+
const rel = relative3(root, target);
|
|
12010
12010
|
return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
|
|
12011
12011
|
};
|
|
12012
12012
|
TRUNCATE_ROLES = /* @__PURE__ */ new Set(["docs", "code", "config", "manifest"]);
|
|
@@ -20575,7 +20575,7 @@ var Protocol = class {
|
|
|
20575
20575
|
return;
|
|
20576
20576
|
}
|
|
20577
20577
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
20578
|
-
await new Promise((
|
|
20578
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
|
|
20579
20579
|
options?.signal?.throwIfAborted();
|
|
20580
20580
|
}
|
|
20581
20581
|
} catch (error2) {
|
|
@@ -20592,7 +20592,7 @@ var Protocol = class {
|
|
|
20592
20592
|
*/
|
|
20593
20593
|
request(request, resultSchema, options) {
|
|
20594
20594
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
20595
|
-
return new Promise((
|
|
20595
|
+
return new Promise((resolve11, reject2) => {
|
|
20596
20596
|
const earlyReject = (error2) => {
|
|
20597
20597
|
reject2(error2);
|
|
20598
20598
|
};
|
|
@@ -20670,7 +20670,7 @@ var Protocol = class {
|
|
|
20670
20670
|
if (!parseResult.success) {
|
|
20671
20671
|
reject2(parseResult.error);
|
|
20672
20672
|
} else {
|
|
20673
|
-
|
|
20673
|
+
resolve11(parseResult.data);
|
|
20674
20674
|
}
|
|
20675
20675
|
} catch (error2) {
|
|
20676
20676
|
reject2(error2);
|
|
@@ -20932,12 +20932,12 @@ var Protocol = class {
|
|
|
20932
20932
|
}
|
|
20933
20933
|
} catch {
|
|
20934
20934
|
}
|
|
20935
|
-
return new Promise((
|
|
20935
|
+
return new Promise((resolve11, reject2) => {
|
|
20936
20936
|
if (signal.aborted) {
|
|
20937
20937
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
20938
20938
|
return;
|
|
20939
20939
|
}
|
|
20940
|
-
const timeoutId = setTimeout(
|
|
20940
|
+
const timeoutId = setTimeout(resolve11, interval);
|
|
20941
20941
|
signal.addEventListener("abort", () => {
|
|
20942
20942
|
clearTimeout(timeoutId);
|
|
20943
20943
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -22078,7 +22078,7 @@ var McpServer = class {
|
|
|
22078
22078
|
let task = createTaskResult.task;
|
|
22079
22079
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
22080
22080
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
22081
|
-
await new Promise((
|
|
22081
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
|
|
22082
22082
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
22083
22083
|
if (!updatedTask) {
|
|
22084
22084
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -22742,12 +22742,12 @@ var StdioServerTransport = class {
|
|
|
22742
22742
|
this.onclose?.();
|
|
22743
22743
|
}
|
|
22744
22744
|
send(message) {
|
|
22745
|
-
return new Promise((
|
|
22745
|
+
return new Promise((resolve11) => {
|
|
22746
22746
|
const json2 = serializeMessage(message);
|
|
22747
22747
|
if (this._stdout.write(json2)) {
|
|
22748
|
-
|
|
22748
|
+
resolve11();
|
|
22749
22749
|
} else {
|
|
22750
|
-
this._stdout.once("drain",
|
|
22750
|
+
this._stdout.once("drain", resolve11);
|
|
22751
22751
|
}
|
|
22752
22752
|
});
|
|
22753
22753
|
}
|
|
@@ -22759,7 +22759,7 @@ import { homedir as homedir6 } from "node:os";
|
|
|
22759
22759
|
import { delimiter } from "node:path";
|
|
22760
22760
|
|
|
22761
22761
|
// src/tools.ts
|
|
22762
|
-
import { existsSync as
|
|
22762
|
+
import { existsSync as existsSync5, readFileSync as readFileSync7, realpathSync as realpathSync4, statSync as statSync6 } from "node:fs";
|
|
22763
22763
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
22764
22764
|
|
|
22765
22765
|
// ../shield/src/canonical.ts
|
|
@@ -22788,11 +22788,52 @@ init_zod();
|
|
|
22788
22788
|
|
|
22789
22789
|
// ../shield/src/userkey.ts
|
|
22790
22790
|
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
22791
|
-
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, writeSync } from "node:fs";
|
|
22791
|
+
import { closeSync, constants, existsSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, writeSync } from "node:fs";
|
|
22792
22792
|
import { homedir } from "node:os";
|
|
22793
|
-
import { isAbsolute, join } from "node:path";
|
|
22793
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
22794
22794
|
var KEY_FILE = "shield.key";
|
|
22795
22795
|
var IS_WINDOWS = process.platform === "win32";
|
|
22796
|
+
function userDirOverrideProblem(dir, cwd = process.cwd()) {
|
|
22797
|
+
const real = (p) => {
|
|
22798
|
+
let cur = resolve(p);
|
|
22799
|
+
let rest = "";
|
|
22800
|
+
for (let i = 0; i < 64; i++) {
|
|
22801
|
+
try {
|
|
22802
|
+
return join(realpathSync.native(cur), rest);
|
|
22803
|
+
} catch {
|
|
22804
|
+
}
|
|
22805
|
+
const up = dirname(cur);
|
|
22806
|
+
if (up === cur) break;
|
|
22807
|
+
rest = join(basename(cur), rest);
|
|
22808
|
+
cur = up;
|
|
22809
|
+
}
|
|
22810
|
+
return resolve(p);
|
|
22811
|
+
};
|
|
22812
|
+
const fold2 = (p) => process.platform === "darwin" || IS_WINDOWS ? p.toLowerCase() : p;
|
|
22813
|
+
const d = fold2(real(dir));
|
|
22814
|
+
const c = fold2(real(cwd));
|
|
22815
|
+
if (d === fold2(real(join(homedir(), ".config", "exorcist-98")))) return null;
|
|
22816
|
+
const rel = relative(c, d);
|
|
22817
|
+
if (rel === "" || !rel.startsWith("..") && !isAbsolute(rel)) return "it is inside the current project folder";
|
|
22818
|
+
for (let cur = d, i = 0; i < 64; i++) {
|
|
22819
|
+
if (existsSync(join(cur, ".git"))) return `it is inside a git repository (${cur})`;
|
|
22820
|
+
const up = dirname(cur);
|
|
22821
|
+
if (up === cur) break;
|
|
22822
|
+
cur = up;
|
|
22823
|
+
}
|
|
22824
|
+
let st;
|
|
22825
|
+
try {
|
|
22826
|
+
st = lstatSync(dir);
|
|
22827
|
+
} catch {
|
|
22828
|
+
return null;
|
|
22829
|
+
}
|
|
22830
|
+
if (st.isSymbolicLink()) return "it is a symbolic link";
|
|
22831
|
+
if (!st.isDirectory()) return "it is not a folder";
|
|
22832
|
+
const me = uid();
|
|
22833
|
+
if (!IS_WINDOWS && me !== void 0 && st.uid !== me) return "it is not owned by you";
|
|
22834
|
+
if (!IS_WINDOWS && (st.mode & 63) !== 0) return "other users or your group can open it (a private folder is mode 0700)";
|
|
22835
|
+
return null;
|
|
22836
|
+
}
|
|
22796
22837
|
function userConfigDir(env = process.env) {
|
|
22797
22838
|
const o = env["EXORCIST_USER_DIR"];
|
|
22798
22839
|
if (o && isAbsolute(o)) return o;
|
|
@@ -22800,6 +22841,14 @@ function userConfigDir(env = process.env) {
|
|
|
22800
22841
|
const base = xdg && isAbsolute(xdg) ? xdg : join(homedir(), ".config");
|
|
22801
22842
|
return join(base, "exorcist-98");
|
|
22802
22843
|
}
|
|
22844
|
+
function userDirRefusal(env = process.env, cwd = process.cwd()) {
|
|
22845
|
+
const o = env["EXORCIST_USER_DIR"];
|
|
22846
|
+
const xdg = env["XDG_CONFIG_HOME"];
|
|
22847
|
+
const overridden = o && isAbsolute(o) || xdg && isAbsolute(xdg);
|
|
22848
|
+
if (!overridden) return null;
|
|
22849
|
+
const problem = userDirOverrideProblem(userConfigDir(env), cwd);
|
|
22850
|
+
return problem === null ? null : `the user-level folder ${userConfigDir(env)} (set by EXORCIST_USER_DIR or XDG_CONFIG_HOME) was refused: ${problem}`;
|
|
22851
|
+
}
|
|
22803
22852
|
var uid = () => typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
22804
22853
|
function ensurePrivateDir(dir) {
|
|
22805
22854
|
try {
|
|
@@ -22842,6 +22891,10 @@ function readKeyFile(path) {
|
|
|
22842
22891
|
}
|
|
22843
22892
|
var cache = /* @__PURE__ */ new Map();
|
|
22844
22893
|
function getUserKey(o = {}) {
|
|
22894
|
+
if (o.dir === void 0) {
|
|
22895
|
+
const refused = userDirRefusal();
|
|
22896
|
+
if (refused !== null) return { ok: false, error: refused };
|
|
22897
|
+
}
|
|
22845
22898
|
const dir = o.dir ?? userConfigDir();
|
|
22846
22899
|
const cached2 = cache.get(dir);
|
|
22847
22900
|
if (cached2) return { ok: true, key: cached2 };
|
|
@@ -22954,7 +23007,13 @@ var PolicySchema = external_exports.object({
|
|
|
22954
23007
|
* opt-in that only the USER-LEVEL policy can set. A project policy, signed or not,
|
|
22955
23008
|
* that asks for it is ignored with a note.
|
|
22956
23009
|
*/
|
|
22957
|
-
sessionRelease: external_exports.enum(["os", "terminal", "notification-code"]).optional()
|
|
23010
|
+
sessionRelease: external_exports.enum(["os", "terminal", "notification-code"]).optional(),
|
|
23011
|
+
/**
|
|
23012
|
+
* The event log (m19-log, LG-2). `off` stops the Shield writing events after one final event that says so.
|
|
23013
|
+
* Only the USER-LEVEL policy can set it: a project policy that sets `events` is ignored with a note, and the
|
|
23014
|
+
* environment variable EXORCIST_EVENTS is ignored (an MCP config can set a server's environment).
|
|
23015
|
+
*/
|
|
23016
|
+
events: external_exports.enum(["on", "off"]).optional()
|
|
22958
23017
|
}).strict();
|
|
22959
23018
|
|
|
22960
23019
|
// ../shield/src/approval.ts
|
|
@@ -26265,7 +26324,13 @@ var MatchSchema = external_exports.object({
|
|
|
26265
26324
|
max_length: external_exports.number().int().min(1),
|
|
26266
26325
|
classes: external_exports.array(external_exports.string()).min(1),
|
|
26267
26326
|
severity: external_exports.enum(["critical", "high", "medium", "low"])
|
|
26268
|
-
}).optional()
|
|
26327
|
+
}).optional(),
|
|
26328
|
+
// regex only: for a file whose path matches one of these patterns, the look-behinds of the regex (the order a
|
|
26329
|
+
// concealment must follow within 300 characters of one paragraph) are dropped and replaced by this: an order word
|
|
26330
|
+
// (`order_regex`) anywhere else in the file. Used for instruction files, where an order and its concealment may be
|
|
26331
|
+
// far apart (m19-scan SN-5). Both are needed for the wide reading.
|
|
26332
|
+
wide_paths: external_exports.array(external_exports.string().refine(compiles, "wide_paths entries must be valid regular expressions")).optional(),
|
|
26333
|
+
order_regex: external_exports.string().optional()
|
|
26269
26334
|
}).superRefine((val, ctx2) => {
|
|
26270
26335
|
const hasAny = val.regex !== void 0 || val.unicode_class !== void 0 && val.unicode_class.length > 0 || val.json_path !== void 0 || val.hidden_text === true || val.analysis !== void 0;
|
|
26271
26336
|
if (!hasAny) {
|
|
@@ -26283,7 +26348,7 @@ var MatchSchema = external_exports.object({
|
|
|
26283
26348
|
if ((val.exclude_regex !== void 0 || val.validate !== void 0) && val.regex === void 0 && val.json_path === void 0) {
|
|
26284
26349
|
ctx2.addIssue({ code: external_exports.ZodIssueCode.custom, message: "match.exclude_regex and match.validate need match.regex or match.json_path" });
|
|
26285
26350
|
}
|
|
26286
|
-
for (const key of ["regex", "value_regex", "exclude_regex", "file_regex", "quoted_example_cues", "negated_cues", "decoded_flag_regex"]) {
|
|
26351
|
+
for (const key of ["regex", "value_regex", "exclude_regex", "file_regex", "quoted_example_cues", "negated_cues", "decoded_flag_regex", "order_regex"]) {
|
|
26287
26352
|
const pattern = val[key];
|
|
26288
26353
|
if (pattern !== void 0 && !compiles(pattern)) {
|
|
26289
26354
|
ctx2.addIssue({
|
|
@@ -26296,7 +26361,7 @@ var MatchSchema = external_exports.object({
|
|
|
26296
26361
|
var VirusDefinitionSchema = external_exports.object({
|
|
26297
26362
|
id: external_exports.string().regex(/^EX-\d{3}$/, "id must match EX-NNN"),
|
|
26298
26363
|
title: external_exports.string().min(1, "title must not be empty"),
|
|
26299
|
-
severity: external_exports.enum(["critical", "high", "medium", "low"]),
|
|
26364
|
+
severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
|
|
26300
26365
|
applies_to: external_exports.array(external_exports.string()).min(1, "applies_to must have at least one entry"),
|
|
26301
26366
|
match: MatchSchema,
|
|
26302
26367
|
owasp: external_exports.array(external_exports.string()).min(1, "owasp must have at least one reference"),
|
|
@@ -26349,7 +26414,7 @@ async function loadDefinitions(dir) {
|
|
|
26349
26414
|
init_zod();
|
|
26350
26415
|
import { createHash } from "node:crypto";
|
|
26351
26416
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
26352
|
-
import { basename, isAbsolute as isAbsolute2, join as join3, relative, resolve } from "node:path";
|
|
26417
|
+
import { basename as basename2, isAbsolute as isAbsolute2, join as join3, relative as relative2, resolve as resolve2 } from "node:path";
|
|
26353
26418
|
var ManifestSchema = external_exports.object({
|
|
26354
26419
|
id: external_exports.string(),
|
|
26355
26420
|
kind: external_exports.enum(["mcp-server", "file", "exorcise"]),
|
|
@@ -26359,11 +26424,11 @@ var ManifestSchema = external_exports.object({
|
|
|
26359
26424
|
});
|
|
26360
26425
|
var VAULT_PATH = /^(?:(.*)\/)?\.exorcist\/vault\/([^/]+)\/(.+)$/;
|
|
26361
26426
|
var inside = (dir, p) => {
|
|
26362
|
-
const r =
|
|
26427
|
+
const r = relative2(dir, p);
|
|
26363
26428
|
return r === "" || !r.startsWith("..") && !isAbsolute2(r);
|
|
26364
26429
|
};
|
|
26365
26430
|
function vaultBackupChecker(root) {
|
|
26366
|
-
const absRoot =
|
|
26431
|
+
const absRoot = resolve2(root);
|
|
26367
26432
|
const manifests = /* @__PURE__ */ new Map();
|
|
26368
26433
|
return (rel, bytes) => {
|
|
26369
26434
|
const m = VAULT_PATH.exec(rel.replace(/\\/g, "/"));
|
|
@@ -26385,14 +26450,14 @@ function vaultBackupChecker(root) {
|
|
|
26385
26450
|
const e = manifests.get(key);
|
|
26386
26451
|
if (!e) return null;
|
|
26387
26452
|
const digest = createHash("sha256").update(bytes).digest("hex");
|
|
26388
|
-
const target =
|
|
26453
|
+
const target = resolve2(e.target);
|
|
26389
26454
|
if (e.kind === "exorcise") {
|
|
26390
26455
|
if (target !== project) return null;
|
|
26391
26456
|
const f = e.files?.find((x) => `files/${x.rel}` === inner);
|
|
26392
26457
|
return f && f.sha256 === digest ? { id, kind: e.kind } : null;
|
|
26393
26458
|
}
|
|
26394
26459
|
if (!inside(project, target)) return null;
|
|
26395
|
-
const expected = e.kind === "mcp-server" ? "entry.json" : `files/${
|
|
26460
|
+
const expected = e.kind === "mcp-server" ? "entry.json" : `files/${basename2(target)}`;
|
|
26396
26461
|
return inner === expected && e.sha256 === digest ? { id, kind: e.kind } : null;
|
|
26397
26462
|
};
|
|
26398
26463
|
}
|
|
@@ -26584,6 +26649,30 @@ var EXEC_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
26584
26649
|
"powershell",
|
|
26585
26650
|
"pwsh"
|
|
26586
26651
|
]);
|
|
26652
|
+
var INTERPRETERS = /* @__PURE__ */ new Set([
|
|
26653
|
+
"sh",
|
|
26654
|
+
"bash",
|
|
26655
|
+
"zsh",
|
|
26656
|
+
"fish",
|
|
26657
|
+
"dash",
|
|
26658
|
+
"node",
|
|
26659
|
+
"nodejs",
|
|
26660
|
+
"deno",
|
|
26661
|
+
"bun",
|
|
26662
|
+
"python",
|
|
26663
|
+
"python3",
|
|
26664
|
+
"perl",
|
|
26665
|
+
"ruby",
|
|
26666
|
+
"php",
|
|
26667
|
+
"lua",
|
|
26668
|
+
"tsx",
|
|
26669
|
+
"ts-node",
|
|
26670
|
+
"osascript",
|
|
26671
|
+
"powershell",
|
|
26672
|
+
"pwsh",
|
|
26673
|
+
"env",
|
|
26674
|
+
"xargs"
|
|
26675
|
+
]);
|
|
26587
26676
|
var NETWORK_ALLOW = /^(?:WebFetch|Bash\(\s*(?:curl|wget|ssh|scp|nc|ncat|ftp|rsync|telnet)\b)/;
|
|
26588
26677
|
var WRITE_ALLOW = /^(?:Write|Edit|MultiEdit|NotebookEdit|Bash\(\s*(?:rm|mv|cp|tee|chmod|chown|dd|ln|touch|mkdir|truncate)\b|Bash\(\s*\*+\s*\))/;
|
|
26589
26678
|
var ALLOW_ENTRY = /^(?:Bash|Shell|PowerShell|Run)\(([^)]*)\)$/;
|
|
@@ -26715,7 +26804,7 @@ function readProjectSettings(rel, text) {
|
|
|
26715
26804
|
const arg = (m[1] ?? "").trim();
|
|
26716
26805
|
const wild = /^(.+?)(?::\s*\*+|\s+\*+)$/.exec(arg);
|
|
26717
26806
|
const cmd = (wild ? wild[1] ?? "" : arg).trim();
|
|
26718
|
-
const bareInterpreter = !wild && EXEC_COMMANDS.has(cmd) &&
|
|
26807
|
+
const bareInterpreter = !wild && EXEC_COMMANDS.has(cmd) && INTERPRETERS.has(cmd);
|
|
26719
26808
|
if (wild && EXEC_COMMANDS.has(cmd) || bareInterpreter) add("allow-exec", JSON.stringify(e), e, loud ? "high" : "medium");
|
|
26720
26809
|
}
|
|
26721
26810
|
}
|
|
@@ -30005,6 +30094,62 @@ function getRegex(pattern, flags2) {
|
|
|
30005
30094
|
regexCache.set(key, re2);
|
|
30006
30095
|
return re2;
|
|
30007
30096
|
}
|
|
30097
|
+
function stripLookbehinds(pattern) {
|
|
30098
|
+
let out = "";
|
|
30099
|
+
let i = 0;
|
|
30100
|
+
while (i < pattern.length) {
|
|
30101
|
+
if (pattern.startsWith("(?<=", i)) {
|
|
30102
|
+
let depth = 0;
|
|
30103
|
+
let j = i;
|
|
30104
|
+
let inClass = false;
|
|
30105
|
+
for (; j < pattern.length; j++) {
|
|
30106
|
+
const c = pattern[j];
|
|
30107
|
+
if (c === "\\") {
|
|
30108
|
+
j++;
|
|
30109
|
+
continue;
|
|
30110
|
+
}
|
|
30111
|
+
if (inClass) {
|
|
30112
|
+
if (c === "]") inClass = false;
|
|
30113
|
+
continue;
|
|
30114
|
+
}
|
|
30115
|
+
if (c === "[") inClass = true;
|
|
30116
|
+
else if (c === "(") depth++;
|
|
30117
|
+
else if (c === ")") {
|
|
30118
|
+
depth--;
|
|
30119
|
+
if (depth === 0) break;
|
|
30120
|
+
}
|
|
30121
|
+
}
|
|
30122
|
+
i = j + 1;
|
|
30123
|
+
continue;
|
|
30124
|
+
}
|
|
30125
|
+
if (pattern[i] === "\\") {
|
|
30126
|
+
out += pattern.slice(i, i + 2);
|
|
30127
|
+
i += 2;
|
|
30128
|
+
continue;
|
|
30129
|
+
}
|
|
30130
|
+
out += pattern[i];
|
|
30131
|
+
i++;
|
|
30132
|
+
}
|
|
30133
|
+
return out;
|
|
30134
|
+
}
|
|
30135
|
+
function isWideFile(match, rel) {
|
|
30136
|
+
return match.order_regex !== void 0 && match.wide_paths !== void 0 && match.wide_paths.some((p) => getRegex(p, "i").test(rel));
|
|
30137
|
+
}
|
|
30138
|
+
var MAX_ORDER_HITS = 5e3;
|
|
30139
|
+
function orderSpans(order, text) {
|
|
30140
|
+
const re2 = getRegex(order, "gi");
|
|
30141
|
+
const out = [];
|
|
30142
|
+
re2.lastIndex = 0;
|
|
30143
|
+
let m;
|
|
30144
|
+
while (out.length < MAX_ORDER_HITS && (m = re2.exec(text)) !== null) {
|
|
30145
|
+
if (m[0].length === 0) {
|
|
30146
|
+
re2.lastIndex++;
|
|
30147
|
+
continue;
|
|
30148
|
+
}
|
|
30149
|
+
out.push([m.index, m.index + m[0].length]);
|
|
30150
|
+
}
|
|
30151
|
+
return out;
|
|
30152
|
+
}
|
|
30008
30153
|
function escapeCodePoint(hit) {
|
|
30009
30154
|
const hex = hit.codePoint.toString(16).toUpperCase();
|
|
30010
30155
|
return hit.codePoint > 65535 ? `\\u{${hex}}` : `\\u${hex.padStart(4, "0")}`;
|
|
@@ -30215,12 +30360,19 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
30215
30360
|
fix: def.fix
|
|
30216
30361
|
};
|
|
30217
30362
|
const mine = [];
|
|
30363
|
+
const narrow = [];
|
|
30218
30364
|
if (match.regex) {
|
|
30219
|
-
const
|
|
30365
|
+
const wide = isWideFile(match, file.rel);
|
|
30366
|
+
const re2 = getRegex(wide ? stripLookbehinds(match.regex) : match.regex, "gi");
|
|
30220
30367
|
mine.push(addLogical(re2, norm.plain));
|
|
30221
30368
|
if (vis) mine.push(addLogical(re2, vis.text));
|
|
30369
|
+
if (wide) {
|
|
30370
|
+
const own = getRegex(match.regex, "gi");
|
|
30371
|
+
narrow.push(addLogical(own, norm.plain));
|
|
30372
|
+
if (vis) narrow.push(addLogical(own, vis.text));
|
|
30373
|
+
}
|
|
30222
30374
|
}
|
|
30223
|
-
active.push({ def, base, keep, jobs: mine });
|
|
30375
|
+
active.push({ def, base, keep, jobs: mine, narrow });
|
|
30224
30376
|
}
|
|
30225
30377
|
let results = jobs.length > 0 ? guarded(jobs, limitMs) : [];
|
|
30226
30378
|
const timedOut = /* @__PURE__ */ new Set();
|
|
@@ -30245,10 +30397,10 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
30245
30397
|
}
|
|
30246
30398
|
return out2;
|
|
30247
30399
|
};
|
|
30248
|
-
for (const { def, base, keep, jobs: mine } of active) {
|
|
30400
|
+
for (const { def, base, keep, jobs: mine, narrow } of active) {
|
|
30249
30401
|
const { match } = def;
|
|
30250
30402
|
if (match.regex) {
|
|
30251
|
-
if (mine.some(timedOutLogical)) {
|
|
30403
|
+
if ([...mine, ...narrow].some(timedOutLogical)) {
|
|
30252
30404
|
findings.push({
|
|
30253
30405
|
...base,
|
|
30254
30406
|
severity: agentFacing ? base.severity : "medium",
|
|
@@ -30263,8 +30415,11 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
30263
30415
|
mine.forEach((logicalId, k) => {
|
|
30264
30416
|
const src = k === 0 || !vis ? norm.plain : vis.text;
|
|
30265
30417
|
const toPlain = k === 0 || !vis ? (i) => i : (i) => vis.map[i] ?? i;
|
|
30418
|
+
const orders = isWideFile(match, file.rel) ? orderSpans(match.order_regex, src) : null;
|
|
30419
|
+
const ownHits = narrow.length > 0 ? new Set(matchesOf(narrow[k] ?? -1).map(([i]) => i)) : null;
|
|
30266
30420
|
for (const [index2, text] of matchesOf(logicalId)) {
|
|
30267
30421
|
if (!keep(text)) continue;
|
|
30422
|
+
if (orders && !ownHits?.has(index2) && !orders.some(([s, e]) => e <= index2 || s >= index2 + text.length)) continue;
|
|
30268
30423
|
const at = toPlain(index2);
|
|
30269
30424
|
if (seen.has(at)) continue;
|
|
30270
30425
|
if (!ctx2.allows(def, text, at, src, index2)) continue;
|
|
@@ -30395,7 +30550,7 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
30395
30550
|
const out = lowered.size === 0 ? findings : findings.map((f) => lowered.has(f.ruleId) ? { ...f, severity: "low" } : f);
|
|
30396
30551
|
return sameLineGroups(out, defs);
|
|
30397
30552
|
}
|
|
30398
|
-
var SEVERITY_RANK = { critical: 4, high: 3, medium: 2, low: 1 };
|
|
30553
|
+
var SEVERITY_RANK = { critical: 4, high: 3, medium: 2, low: 1, info: 0 };
|
|
30399
30554
|
function sameLineGroups(findings, defs) {
|
|
30400
30555
|
const groupOf = new Map(defs.filter((d) => d.same_line_group).map((d) => [d.id, d.same_line_group]));
|
|
30401
30556
|
if (groupOf.size === 0) return findings;
|
|
@@ -30845,11 +31000,68 @@ function extractPy(text, budget, out, dyn = []) {
|
|
|
30845
31000
|
if (r.dyn !== null) dyn.push(r.dyn);
|
|
30846
31001
|
if (r.after > 0) after = r.after;
|
|
30847
31002
|
}
|
|
30848
|
-
|
|
31003
|
+
const doc = docstringAfter(text, after, limit);
|
|
31004
|
+
if (lit === null) lit = doc;
|
|
31005
|
+
else if (doc !== null && PY_ARGS_SECTION.test(doc.value)) out.push(toFound(doc));
|
|
30849
31006
|
if (lit) out.push(toFound(lit));
|
|
30850
31007
|
}
|
|
30851
31008
|
}
|
|
30852
31009
|
}
|
|
31010
|
+
var PY_ARGS_SECTION = /^[ \t]*(?:Args|Arguments|Parameters|Params)[ \t]*:/m;
|
|
31011
|
+
var FIELD_KEYS = ["type", "enum", "items", "properties", "format", "default", "minimum", "maximum", "anyOf", "oneOf"];
|
|
31012
|
+
var SCHEMA_WORD = /properties|inputSchema|input_schema|parameters/;
|
|
31013
|
+
var MCP_TEXT = /modelcontextprotocol|FastMCP|McpServer|mcp\.server|inputSchema|input_schema|@mcp\.tool|\.tool\(|registerTool/;
|
|
31014
|
+
var nearSchema = (text, at) => SCHEMA_WORD.test(text.slice(Math.max(0, at - 3e3), at));
|
|
31015
|
+
function extractFieldsTs(text, out, dyn) {
|
|
31016
|
+
const keyBudget = { left: MAX_SITES };
|
|
31017
|
+
for (const at of indexesOf(text, "description", keyBudget)) {
|
|
31018
|
+
if (isIdent(text[at - 1])) continue;
|
|
31019
|
+
const limit = lim(text, at);
|
|
31020
|
+
let j = at + "description".length;
|
|
31021
|
+
if (text[j] === '"' || text[j] === "'") j++;
|
|
31022
|
+
j = skipTrivia(text, j, "ts", limit);
|
|
31023
|
+
if (text[j] !== ":") continue;
|
|
31024
|
+
const open4 = enclosingObject(text, at);
|
|
31025
|
+
if (open4 < 0 || !hasKeyAtTop(text, open4, FIELD_KEYS, limit)) continue;
|
|
31026
|
+
const p = skipTrivia(text, j + 1, "ts", limit);
|
|
31027
|
+
const l = isQuote(text[p]) ? readLiteral(text, p, "ts", limit) : null;
|
|
31028
|
+
if (l) {
|
|
31029
|
+
out.push(toFound(l));
|
|
31030
|
+
if (text[skipTrivia(text, l.next, "ts", limit)] === "+" && nearSchema(text, at)) dyn.push(p);
|
|
31031
|
+
} else if (nearSchema(text, at)) dyn.push(p);
|
|
31032
|
+
}
|
|
31033
|
+
const describeBudget = { left: MAX_SITES };
|
|
31034
|
+
for (const at of indexesOf(text, ".describe(", describeBudget)) {
|
|
31035
|
+
const limit = lim(text, at);
|
|
31036
|
+
const p = skipTrivia(text, at + ".describe(".length, "ts", limit);
|
|
31037
|
+
if (text[p] === ")") continue;
|
|
31038
|
+
const l = isQuote(text[p]) ? readLiteral(text, p, "ts", limit) : null;
|
|
31039
|
+
if (l) {
|
|
31040
|
+
out.push(toFound(l));
|
|
31041
|
+
if (text[skipTrivia(text, l.next, "ts", limit)] === "+") dyn.push(p);
|
|
31042
|
+
} else dyn.push(p);
|
|
31043
|
+
}
|
|
31044
|
+
}
|
|
31045
|
+
function extractFieldsPy(text, out, dyn) {
|
|
31046
|
+
const fieldBudget = { left: MAX_SITES };
|
|
31047
|
+
for (const at of indexesOf(text, "Field(", fieldBudget)) {
|
|
31048
|
+
if (isIdent(text[at - 1])) continue;
|
|
31049
|
+
const { lit, dyn: d } = findKeyString(text, at + 5, "py", lim(text, at), "=");
|
|
31050
|
+
if (lit) out.push(toFound(lit));
|
|
31051
|
+
if (d !== null) dyn.push(d);
|
|
31052
|
+
}
|
|
31053
|
+
const annBudget = { left: MAX_SITES };
|
|
31054
|
+
for (const at of indexesOf(text, "Annotated[", annBudget)) {
|
|
31055
|
+
if (isIdent(text[at - 1])) continue;
|
|
31056
|
+
const limit = lim(text, at);
|
|
31057
|
+
const first = skipTrivia(text, at + "Annotated[".length, "py", limit);
|
|
31058
|
+
const e = skipArgument(text, first, "py", limit);
|
|
31059
|
+
if (e < 0 || text[e] !== ",") continue;
|
|
31060
|
+
const p = skipTrivia(text, e + 1, "py", limit);
|
|
31061
|
+
const l = readPyString(text, p, limit);
|
|
31062
|
+
if (l) out.push(toFound(l));
|
|
31063
|
+
}
|
|
31064
|
+
}
|
|
30853
31065
|
function extractGo(text, budget, out) {
|
|
30854
31066
|
for (const at of indexesOf(text, "WithDescription(", budget)) {
|
|
30855
31067
|
if (isIdent(text[at - 1])) continue;
|
|
@@ -30859,9 +31071,10 @@ function extractGo(text, budget, out) {
|
|
|
30859
31071
|
if (l) out.push(toFound(l));
|
|
30860
31072
|
}
|
|
30861
31073
|
}
|
|
30862
|
-
function extractAll(text, lang) {
|
|
31074
|
+
function extractAll(text, lang, mcpPath = false) {
|
|
30863
31075
|
const out = [];
|
|
30864
31076
|
const dyn = [];
|
|
31077
|
+
const dynFields = [];
|
|
30865
31078
|
const budget = { left: MAX_SITES };
|
|
30866
31079
|
if (lang === "ts") {
|
|
30867
31080
|
extractTs(text, budget, out, dyn);
|
|
@@ -30872,11 +31085,20 @@ function extractAll(text, lang) {
|
|
|
30872
31085
|
extractPyConstructor(text, { left: MAX_SITES }, out, dyn);
|
|
30873
31086
|
} else if (lang === "go") extractGo(text, budget, out);
|
|
30874
31087
|
else extractOther(text, lang, budget, out);
|
|
31088
|
+
if ((lang === "ts" || lang === "py") && (mcpPath || out.length > 0 || dyn.length > 0 || MCP_TEXT.test(text))) {
|
|
31089
|
+
if (lang === "ts") extractFieldsTs(text, out, dynFields);
|
|
31090
|
+
else extractFieldsPy(text, out, dynFields);
|
|
31091
|
+
}
|
|
30875
31092
|
const seen = /* @__PURE__ */ new Set();
|
|
30876
|
-
|
|
31093
|
+
const taken = new Set(dyn);
|
|
31094
|
+
return {
|
|
31095
|
+
found: out.filter((f) => !seen.has(f.offset) && seen.add(f.offset)).sort((a, b) => a.offset - b.offset),
|
|
31096
|
+
dyn: [...taken].sort((a, b) => a - b),
|
|
31097
|
+
dynFields: [...new Set(dynFields)].filter((d) => !taken.has(d)).sort((a, b) => a - b)
|
|
31098
|
+
};
|
|
30877
31099
|
}
|
|
30878
|
-
function extract(text, lang) {
|
|
30879
|
-
return extractAll(text, lang).found;
|
|
31100
|
+
function extract(text, lang, mcpPath = false) {
|
|
31101
|
+
return extractAll(text, lang, mcpPath).found;
|
|
30880
31102
|
}
|
|
30881
31103
|
function enclosingObject(text, at) {
|
|
30882
31104
|
let depth = 0;
|
|
@@ -30997,17 +31219,22 @@ function scanDynamicToolDescriptions(file, text, defs) {
|
|
|
30997
31219
|
const lang = languageOf(file.rel);
|
|
30998
31220
|
if (!def || lang === null || typeof text !== "string" || lang !== "ts" && lang !== "py") return [];
|
|
30999
31221
|
if (!/mcp/i.test(file.rel) && !/modelcontextprotocol|FastMCP|McpServer|mcp\.server/.test(text)) return [];
|
|
31000
|
-
|
|
31222
|
+
const { dyn, dynFields } = extractAll(text, lang, true);
|
|
31223
|
+
const make = (at, span, what) => ({
|
|
31001
31224
|
source: "signature",
|
|
31002
31225
|
ruleId: def.id,
|
|
31003
31226
|
title: def.title,
|
|
31004
31227
|
severity: "medium",
|
|
31005
31228
|
file: file.rel,
|
|
31006
31229
|
...positionOf(text, at),
|
|
31007
|
-
span
|
|
31230
|
+
span,
|
|
31008
31231
|
owasp: def.owasp,
|
|
31009
|
-
fix:
|
|
31010
|
-
})
|
|
31232
|
+
fix: `This ${what} is computed (a variable, a constant from another file, a template or a concatenation), so the scan cannot read what an agent will be told. Write it as one plain string in the registration, or run the server behind the Shield: exorcist wrap <mcp config> (or exorcist init --shield) checks the real text the running server sends and withholds a poisoned tool.`
|
|
31233
|
+
});
|
|
31234
|
+
return [
|
|
31235
|
+
...dyn.map((at) => make(at, "tool description built at run time: not checked", "tool description")),
|
|
31236
|
+
...dynFields.map((at) => make(at, "tool field description built at run time: not checked", "field description of a tool parameter"))
|
|
31237
|
+
];
|
|
31011
31238
|
} catch {
|
|
31012
31239
|
return [];
|
|
31013
31240
|
}
|
|
@@ -31065,7 +31292,7 @@ function scanSourceTools(file, text, defs) {
|
|
|
31065
31292
|
const lang = languageOf(file.rel);
|
|
31066
31293
|
if (!def || lang === null || typeof text !== "string") return [];
|
|
31067
31294
|
const out = [];
|
|
31068
|
-
for (const s of extract(text, lang)) {
|
|
31295
|
+
for (const s of extract(text, lang, /mcp/i.test(file.rel))) {
|
|
31069
31296
|
for (const hit of scanText(s.text, "mcp-config", [def], file.rel)) {
|
|
31070
31297
|
const idx = Math.min(Math.max(indexOfLineCol(s.text, hit.line, hit.col), 0), s.text.length);
|
|
31071
31298
|
if (isQuietHint(hit.span, s.text, idx)) continue;
|
|
@@ -31109,8 +31336,8 @@ function sandboxFindings(text, rel) {
|
|
|
31109
31336
|
return [{
|
|
31110
31337
|
source: "signature",
|
|
31111
31338
|
ruleId: SANDBOX_RULE_ID,
|
|
31112
|
-
title: mcpOff ? "
|
|
31113
|
-
severity: "
|
|
31339
|
+
title: mcpOff ? "MCP sandboxing is off in this project" : "The command sandbox is off in this project",
|
|
31340
|
+
severity: "info",
|
|
31114
31341
|
file: rel,
|
|
31115
31342
|
line,
|
|
31116
31343
|
col,
|
|
@@ -31207,8 +31434,8 @@ function checkPathSegment(name) {
|
|
|
31207
31434
|
}
|
|
31208
31435
|
|
|
31209
31436
|
// ../core/src/lifecycle-scripts.ts
|
|
31210
|
-
import { closeSync as closeSync2, existsSync, lstatSync as lstatSync2, openSync as openSync2, readdirSync, readSync, realpathSync, statSync as statSync2 } from "node:fs";
|
|
31211
|
-
import { isAbsolute as isAbsolute6, join as join8, posix as posix2, relative as
|
|
31437
|
+
import { closeSync as closeSync2, existsSync as existsSync2, lstatSync as lstatSync2, openSync as openSync2, readdirSync, readSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
31438
|
+
import { isAbsolute as isAbsolute6, join as join8, posix as posix2, relative as relative6, resolve as resolve6, sep } from "node:path";
|
|
31212
31439
|
|
|
31213
31440
|
// ../core/src/install-hooks.ts
|
|
31214
31441
|
var INSTALL_HOOKS = [
|
|
@@ -31570,7 +31797,7 @@ function pmActions(e, scripts = /* @__PURE__ */ new Set()) {
|
|
|
31570
31797
|
}
|
|
31571
31798
|
|
|
31572
31799
|
// ../core/src/shell-analyze.ts
|
|
31573
|
-
import { basename as
|
|
31800
|
+
import { basename as basename4, resolve as resolve5 } from "node:path";
|
|
31574
31801
|
|
|
31575
31802
|
// ../core/src/shell-parse.ts
|
|
31576
31803
|
var MAX_COMMAND_CHARS = 65536;
|
|
@@ -32038,15 +32265,15 @@ function parseShell(command, sub = false) {
|
|
|
32038
32265
|
init_zod();
|
|
32039
32266
|
import { readFileSync as readFileSync4, statSync } from "node:fs";
|
|
32040
32267
|
import { homedir as homedir3 } from "node:os";
|
|
32041
|
-
import { isAbsolute as isAbsolute5, join as join7, normalize as normalize2, relative as
|
|
32268
|
+
import { isAbsolute as isAbsolute5, join as join7, normalize as normalize2, relative as relative5, resolve as resolve4 } from "node:path";
|
|
32042
32269
|
|
|
32043
32270
|
// ../core/src/user-dir-guard.ts
|
|
32044
32271
|
import { homedir as homedir2 } from "node:os";
|
|
32045
|
-
import { dirname, isAbsolute as isAbsolute4, join as join6, relative as
|
|
32272
|
+
import { dirname as dirname2, isAbsolute as isAbsolute4, join as join6, relative as relative4, resolve as resolve3 } from "node:path";
|
|
32046
32273
|
function userKeyDirs(env = process.env) {
|
|
32047
32274
|
const out = /* @__PURE__ */ new Set();
|
|
32048
32275
|
const o = env["EXORCIST_USER_DIR"];
|
|
32049
|
-
if (o && isAbsolute4(o)) out.add(
|
|
32276
|
+
if (o && isAbsolute4(o)) out.add(resolve3(o));
|
|
32050
32277
|
const xdg = env["XDG_CONFIG_HOME"];
|
|
32051
32278
|
out.add(join6(xdg && isAbsolute4(xdg) ? xdg : join6(homedir2(), ".config"), "exorcist-98"));
|
|
32052
32279
|
out.add(join6(homedir2(), ".config", "exorcist-98"));
|
|
@@ -32106,13 +32333,13 @@ function insideProject(raw, cwd) {
|
|
|
32106
32333
|
}
|
|
32107
32334
|
if (!isAbsolute5(p)) return true;
|
|
32108
32335
|
if (cwd === void 0) return !raw.startsWith("~");
|
|
32109
|
-
const rel =
|
|
32336
|
+
const rel = relative5(cwd, resolve4(p));
|
|
32110
32337
|
return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
|
|
32111
32338
|
}
|
|
32112
32339
|
function withinProject(raw, cwd) {
|
|
32113
32340
|
if (raw === "" || /[$`~]|:\/\//.test(raw)) return false;
|
|
32114
32341
|
if (cwd === void 0) return !isAbsolute5(raw) && !normalize2(raw).split(/[\\/]/).includes("..");
|
|
32115
|
-
const rel =
|
|
32342
|
+
const rel = relative5(cwd, resolve4(cwd, raw));
|
|
32116
32343
|
return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
|
|
32117
32344
|
}
|
|
32118
32345
|
var anyInside = (list, cwd) => list.split(/[:;]/).some((p) => insideProject(p, cwd));
|
|
@@ -32138,8 +32365,7 @@ function envFamilyOwners(name) {
|
|
|
32138
32365
|
for (const [re2, owners] of ENV_FAMILIES) if (re2.test(name)) return owners;
|
|
32139
32366
|
return null;
|
|
32140
32367
|
}
|
|
32141
|
-
var
|
|
32142
|
-
var PROGRAM_VAR = /(?:EDITOR|PAGER|BROWSER|_CMD|_COMMAND|_HELPER|_PROGRAM|_EXEC|_SHELL|_ARGS(?:_\w+)?)$/u;
|
|
32368
|
+
var PLAIN_VAR = /(?:_LOG|_LOG_LEVEL|_DEBUG|_VERBOSE|_COLOR|_NO_COLOR|_IN_AUTOMATION|_INPUT|_WORKSPACE|_NAMESPACE|_CONTEXT|_REGION|_VAR_[A-Za-z0-9_]+|EDITOR|PAGER|BROWSER|_CLI_ARGS(?:_[a-z]+)?)$/u;
|
|
32143
32369
|
var ENDPOINT_VAR = /(?:_HOST|_URL|_ENDPOINT|_SERVER)$/;
|
|
32144
32370
|
function unlockedValueRisk(name, value, cwd, dynamic) {
|
|
32145
32371
|
const runtime = dynamic || /[$`]/.test(value);
|
|
@@ -32152,12 +32378,11 @@ function unlockedValueRisk(name, value, cwd, dynamic) {
|
|
|
32152
32378
|
}
|
|
32153
32379
|
let v = value.trim();
|
|
32154
32380
|
if (v.startsWith("~")) v = expandTilde(v, cwd) ?? v;
|
|
32155
|
-
const one = `${name} takes one
|
|
32381
|
+
const one = `${name} takes one word here: an absolute path outside the project, or, for a variable that holds a plain value, a name with no dot, slash or tilde`;
|
|
32156
32382
|
if (v === "") return null;
|
|
32157
32383
|
if (/[\s:,;=]/u.test(v)) return one;
|
|
32158
32384
|
if (isAbsolute5(v)) return insideProject(v, cwd) ? say : null;
|
|
32159
|
-
|
|
32160
|
-
return /[./\\~]/u.test(v) ? one : null;
|
|
32385
|
+
return PLAIN_VAR.test(name) && !/[./\\~]/u.test(v) ? null : one;
|
|
32161
32386
|
}
|
|
32162
32387
|
function envAssignRisk(name, value, cwd, dynamic = false, known, prog) {
|
|
32163
32388
|
const owners = envFamilyOwners(name);
|
|
@@ -32631,7 +32856,7 @@ var reject = (reason, fix = FIX_SIMPLE) => {
|
|
|
32631
32856
|
var SYSTEM_DIRS = ["/usr/bin/", "/bin/", "/usr/sbin/", "/sbin/", "/usr/local/bin/", "/usr/local/sbin/", "/opt/homebrew/bin/", "/opt/homebrew/sbin/", "/opt/local/bin/", "/usr/libexec/", "/usr/local/opt/"];
|
|
32632
32857
|
var SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "ksh", "ash", "csh", "tcsh", "fish"]);
|
|
32633
32858
|
var NODE_LIKE = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno"]);
|
|
32634
|
-
var
|
|
32859
|
+
var INTERPRETERS2 = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno", "python", "python3", "ruby", "perl", "php", "lua", "sh", "bash", "zsh", "dash", "ksh"]);
|
|
32635
32860
|
var KNOWN_PROGRAMS = /* @__PURE__ */ new Set([
|
|
32636
32861
|
// shell builtins and plain utilities
|
|
32637
32862
|
"cd",
|
|
@@ -32943,7 +33168,7 @@ var WRAP_SPECS = {
|
|
|
32943
33168
|
var XARGS_SPEC = spec("-a -d -E -e -I -i -L -l -n -P -s --arg-file --delimiter --max-args --max-procs --max-chars --max-lines --eof --replace", "-0 -r -t -p -x --null --no-run-if-empty --verbose --interactive --exit --open-tty");
|
|
32944
33169
|
var SHELL_VALUE_FLAGS = /* @__PURE__ */ new Set(["-o", "+o", "-O", "+O", "--rcfile", "--init-file"]);
|
|
32945
33170
|
function progName(raw) {
|
|
32946
|
-
const b =
|
|
33171
|
+
const b = basename4(raw.replace(/\\/g, "/"));
|
|
32947
33172
|
return b.replace(/\.(exe|cmd|bat|ps1)$/i, "").toLowerCase();
|
|
32948
33173
|
}
|
|
32949
33174
|
var wordsText = (ws) => ws.map((w) => w.text);
|
|
@@ -33063,7 +33288,7 @@ function checkSpecial(prog, f, words2, ctx2) {
|
|
|
33063
33288
|
if (prog === "less" || prog === "more" || prog === "man") {
|
|
33064
33289
|
if (args.some((a) => a.startsWith("--lesskey") || a === "+!" || a.startsWith("+!"))) reject("a pager was given commands to run", FIX_READ_TOOL);
|
|
33065
33290
|
}
|
|
33066
|
-
if (
|
|
33291
|
+
if (INTERPRETERS2.has(prog) || /^python[0-9.]*$/.test(prog)) {
|
|
33067
33292
|
const inlineFlag = (a) => {
|
|
33068
33293
|
if (NODE_LIKE.has(prog) || prog === "nodejs") return a === "-e" || a === "--eval" || a === "-p" || a === "--print" || a === "-pe" || a === "-ep";
|
|
33069
33294
|
if (/^python/.test(prog)) return a === "-c" || /^-[A-Za-z]*c$/.test(a) && a.length <= 4 && a.startsWith("-") && !a.startsWith("--");
|
|
@@ -33248,7 +33473,7 @@ function resolveWords(words2, f, ctx2) {
|
|
|
33248
33473
|
}
|
|
33249
33474
|
pushExec(ctx2, f, words2, raw);
|
|
33250
33475
|
const e = lastExec(ctx2);
|
|
33251
|
-
if (ctx2.mode === "script" && (
|
|
33476
|
+
if (ctx2.mode === "script" && (INTERPRETERS2.has(prog) || /^python/.test(prog))) {
|
|
33252
33477
|
const flags2 = /* @__PURE__ */ new Set(["-e", "-c", "-p", "--eval", "--print", "-r", "-E"]);
|
|
33253
33478
|
const k = e.args.findIndex((a) => flags2.has(a.text));
|
|
33254
33479
|
const flag = e.args[k]?.text;
|
|
@@ -34010,14 +34235,14 @@ function describeHit(h) {
|
|
|
34010
34235
|
}
|
|
34011
34236
|
function readLocalText(pkgDir, rel) {
|
|
34012
34237
|
try {
|
|
34013
|
-
const abs =
|
|
34238
|
+
const abs = resolve6(pkgDir, rel);
|
|
34014
34239
|
const within = (root, p) => {
|
|
34015
|
-
const r =
|
|
34240
|
+
const r = relative6(root, p);
|
|
34016
34241
|
return r !== "" && !r.startsWith("..") && !isAbsolute6(r) && !r.split(sep).includes("..");
|
|
34017
34242
|
};
|
|
34018
|
-
if (!within(pkgDir, abs) || !
|
|
34019
|
-
const real =
|
|
34020
|
-
if (!within(
|
|
34243
|
+
if (!within(pkgDir, abs) || !existsSync2(abs)) return null;
|
|
34244
|
+
const real = realpathSync2(abs);
|
|
34245
|
+
if (!within(realpathSync2(pkgDir), real)) return null;
|
|
34021
34246
|
const st = statSync2(real);
|
|
34022
34247
|
if (!st.isFile() || st.size > MAX_SOURCE_BYTES) return null;
|
|
34023
34248
|
const buf = Buffer.alloc(st.size);
|
|
@@ -34035,7 +34260,7 @@ function readLocalText(pkgDir, rel) {
|
|
|
34035
34260
|
}
|
|
34036
34261
|
|
|
34037
34262
|
// ../core/src/scanner/orchestrator.ts
|
|
34038
|
-
import { dirname as
|
|
34263
|
+
import { dirname as dirname3 } from "node:path";
|
|
34039
34264
|
init_heuristic_engine();
|
|
34040
34265
|
|
|
34041
34266
|
// ../core/src/capabilities.ts
|
|
@@ -34743,7 +34968,7 @@ async function* pathNameFindings(root, def, ignore) {
|
|
|
34743
34968
|
}
|
|
34744
34969
|
}
|
|
34745
34970
|
function lifecycleScanFindings(text, absPath, rel, def) {
|
|
34746
|
-
const dir =
|
|
34971
|
+
const dir = dirname3(absPath);
|
|
34747
34972
|
return lifecycleFindings({ pkgText: text, readLocal: (r) => readLocalText(dir, r) }).map((h) => ({
|
|
34748
34973
|
source: "signature",
|
|
34749
34974
|
ruleId: def.id,
|
|
@@ -34952,7 +35177,7 @@ var FindingSchema = external_exports.object({
|
|
|
34952
35177
|
source: external_exports.enum(["signature", "heuristic"]),
|
|
34953
35178
|
ruleId: external_exports.string(),
|
|
34954
35179
|
title: external_exports.string(),
|
|
34955
|
-
severity: external_exports.enum(["critical", "high", "medium", "low"]),
|
|
35180
|
+
severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
|
|
34956
35181
|
file: external_exports.string(),
|
|
34957
35182
|
// The file name with bidi, zero-width and control characters shown as [U+XXXX] (m18-scanner SC-19).
|
|
34958
35183
|
fileDisplay: external_exports.string().optional(),
|
|
@@ -35191,6 +35416,10 @@ var ENTRIES = {
|
|
|
35191
35416
|
"EX-074": {
|
|
35192
35417
|
headline: "This settings file makes Copilot approve every tool call",
|
|
35193
35418
|
attack: "A committed setting approves all tool calls of the chat agent, so it no longer asks before it runs commands, edits files or reaches the network."
|
|
35419
|
+
},
|
|
35420
|
+
"EX-075": {
|
|
35421
|
+
headline: "This instruction file tells your AI to do something that has nothing to do with the code",
|
|
35422
|
+
attack: "Agents follow their instruction files (steering files, AGENTS.md, CONTRIBUTING.md and the like) without asking. An order there to leave a marker file, skip or weaken a test or a check, run a command that is not a build, test or lint step, or fetch a web address is carried out quietly, even when nothing in the text hides it."
|
|
35194
35423
|
}
|
|
35195
35424
|
};
|
|
35196
35425
|
function plainFor(ruleId, fallbackTitle) {
|
|
@@ -35258,7 +35487,7 @@ var MAX_FILE_BYTES2 = 8 * 1024 * 1024;
|
|
|
35258
35487
|
var OriginStatusSchema = external_exports.enum(["log-s", "blame", "uncommitted", "not-found", "timeout", "error"]);
|
|
35259
35488
|
var TimelineThreatSchema = external_exports.object({
|
|
35260
35489
|
ruleId: external_exports.string(),
|
|
35261
|
-
severity: external_exports.enum(["critical", "high", "medium", "low"]),
|
|
35490
|
+
severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
|
|
35262
35491
|
file: external_exports.string(),
|
|
35263
35492
|
line: external_exports.number().int().positive(),
|
|
35264
35493
|
title: external_exports.string(),
|
|
@@ -35358,7 +35587,7 @@ init_zod();
|
|
|
35358
35587
|
import { createHash as createHash2, createPrivateKey, createPublicKey, generateKeyPairSync, randomBytes as randomBytes3, sign as edSign, verify as edVerify } from "node:crypto";
|
|
35359
35588
|
import { closeSync as closeSync3, fstatSync as fstatSync2, lstatSync as lstatSync3, mkdirSync as mkdirSync2, openSync as openSync3, readFileSync as readFileSync5, readSync as readSync2, readdirSync as readdirSync2, renameSync, rmSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
35360
35589
|
import { homedir as homedir4 } from "node:os";
|
|
35361
|
-
import { basename as
|
|
35590
|
+
import { basename as basename5, join as join11, resolve as resolve7 } from "node:path";
|
|
35362
35591
|
var DEFINITIONS_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
35363
35592
|
MCowBQYDK2VwAyEAn4o+dmOJXIzsygT2CF/3go/1E/bk9Ub16r4hGtJJjhM=
|
|
35364
35593
|
-----END PUBLIC KEY-----
|
|
@@ -35436,7 +35665,7 @@ function parseManifest(manifestBytes) {
|
|
|
35436
35665
|
}
|
|
35437
35666
|
function installedDefinitionsRoot(env = process.env) {
|
|
35438
35667
|
const fromEnv = env["EXORCIST_DEFINITIONS_HOME"];
|
|
35439
|
-
if (fromEnv) return
|
|
35668
|
+
if (fromEnv) return resolve7(fromEnv);
|
|
35440
35669
|
return join11(env["HOME"] || env["USERPROFILE"] || homedir4(), ".exorcist", "definitions");
|
|
35441
35670
|
}
|
|
35442
35671
|
function verifySetFolder(dir, expectedVersion, publicKeyPem) {
|
|
@@ -35445,7 +35674,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
|
|
|
35445
35674
|
const defsDir = join11(dir, "definitions");
|
|
35446
35675
|
for (const [p, kind] of [[join11(dir, MANIFEST_NAME), "file"], [join11(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
|
|
35447
35676
|
const st = lstatSync3(p);
|
|
35448
|
-
if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail2(`${
|
|
35677
|
+
if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail2(`${basename5(p)} is not a plain ${kind === "file" ? "file" : "folder"}`);
|
|
35449
35678
|
}
|
|
35450
35679
|
const manifestBytes = readFileSync5(join11(dir, MANIFEST_NAME));
|
|
35451
35680
|
const bad = verifySignature(manifestBytes, readFileSync5(join11(dir, SIGNATURE_NAME)), publicKeyPem);
|
|
@@ -35474,7 +35703,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
|
|
|
35474
35703
|
}
|
|
35475
35704
|
}
|
|
35476
35705
|
function verifyInstalledSet(dir, publicKeyPem = DEFINITIONS_PUBLIC_KEY) {
|
|
35477
|
-
const name =
|
|
35706
|
+
const name = basename5(dir);
|
|
35478
35707
|
if (!isValidVersion(name)) return fail2(`${printable(name)} is not a version folder`);
|
|
35479
35708
|
return verifySetFolder(dir, name, publicKeyPem);
|
|
35480
35709
|
}
|
|
@@ -35518,6 +35747,20 @@ var BaselineSchema = external_exports.object({
|
|
|
35518
35747
|
init_text_decode();
|
|
35519
35748
|
init_image_text();
|
|
35520
35749
|
|
|
35750
|
+
// ../core/src/home-settings.ts
|
|
35751
|
+
init_zod();
|
|
35752
|
+
var Globs = external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]);
|
|
35753
|
+
var RuleSchema2 = external_exports.object({ capability: external_exports.string(), match: Globs.optional().nullable(), exclude: Globs.optional().nullable(), effect: external_exports.string() }).passthrough();
|
|
35754
|
+
var KiroFileSchema = external_exports.object({ rules: external_exports.array(external_exports.unknown()).optional().nullable(), policies: external_exports.array(external_exports.unknown()).optional().nullable() }).passthrough();
|
|
35755
|
+
var AgentSchema = external_exports.object({
|
|
35756
|
+
permissions: external_exports.object({ rules: external_exports.array(external_exports.unknown()).optional().nullable() }).passthrough().optional().nullable(),
|
|
35757
|
+
toolsSettings: external_exports.record(external_exports.unknown()).optional().nullable()
|
|
35758
|
+
}).passthrough();
|
|
35759
|
+
var HIGH_FLAGS = ["executeAllCommands"];
|
|
35760
|
+
var MEDIUM_FLAGS = ["editFiles", "editFilesExternally", "useMcp", "useBrowser"];
|
|
35761
|
+
var SAFE_FLAGS = ["executeSafeCommands", "readFiles", "readFilesExternally"];
|
|
35762
|
+
var ACTION_FLAGS = /* @__PURE__ */ new Set([...HIGH_FLAGS, ...MEDIUM_FLAGS, ...SAFE_FLAGS]);
|
|
35763
|
+
|
|
35521
35764
|
// ../core/src/kiro-evidence.ts
|
|
35522
35765
|
init_zod();
|
|
35523
35766
|
var KiroEventSchema = external_exports.object({
|
|
@@ -35759,8 +36002,8 @@ var LockSchema = external_exports.object({
|
|
|
35759
36002
|
|
|
35760
36003
|
// ../shield/src/vault.ts
|
|
35761
36004
|
import { createHash as createHash3, randomBytes as randomBytes4 } from "node:crypto";
|
|
35762
|
-
import { closeSync as closeSync4, constants as constants3, copyFileSync, existsSync as
|
|
35763
|
-
import { basename as
|
|
36005
|
+
import { closeSync as closeSync4, constants as constants3, copyFileSync, existsSync as existsSync3, fstatSync as fstatSync3, lstatSync as lstatSync4, mkdirSync as mkdirSync3, openSync as openSync4, readFileSync as readFileSync6, readdirSync as readdirSync3, realpathSync as realpathSync3, rmSync as rmSync2, statSync as statSync4, writeFileSync as writeFileSync2, writeSync as writeSync2 } from "node:fs";
|
|
36006
|
+
import { basename as basename6, dirname as dirname4, isAbsolute as isAbsolute7, join as join12, resolve as resolve8, sep as sep2 } from "node:path";
|
|
35764
36007
|
init_zod();
|
|
35765
36008
|
var SafeRel = external_exports.string().min(1).max(1024).refine(
|
|
35766
36009
|
(p) => !isAbsolute7(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
|
|
@@ -35800,9 +36043,9 @@ var entryText = (e) => {
|
|
|
35800
36043
|
};
|
|
35801
36044
|
function ensureSafeVault(vaultDir) {
|
|
35802
36045
|
const me = typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
35803
|
-
const state =
|
|
36046
|
+
const state = dirname4(vaultDir);
|
|
35804
36047
|
try {
|
|
35805
|
-
mkdirSync3(
|
|
36048
|
+
mkdirSync3(dirname4(state), { recursive: true });
|
|
35806
36049
|
for (const d of [state, vaultDir]) {
|
|
35807
36050
|
const st = lstatSync4(d, { throwIfNoEntry: false });
|
|
35808
36051
|
if (st === void 0) {
|
|
@@ -35829,14 +36072,14 @@ function writeFileSafe(path, text) {
|
|
|
35829
36072
|
}
|
|
35830
36073
|
var insideDir = (child, parent) => child === parent || child.startsWith(parent.endsWith(sep2) ? parent : parent + sep2);
|
|
35831
36074
|
function rootFor(vaultDir, target) {
|
|
35832
|
-
const state =
|
|
35833
|
-
if (
|
|
35834
|
-
const project =
|
|
35835
|
-
return insideDir(
|
|
36075
|
+
const state = dirname4(vaultDir);
|
|
36076
|
+
if (basename6(state) !== ".exorcist") return void 0;
|
|
36077
|
+
const project = dirname4(state);
|
|
36078
|
+
return insideDir(resolve8(target), resolve8(project)) ? resolve8(project) : void 0;
|
|
35836
36079
|
}
|
|
35837
36080
|
function realDirOf(target) {
|
|
35838
36081
|
try {
|
|
35839
|
-
return
|
|
36082
|
+
return realpathSync3(dirname4(target));
|
|
35840
36083
|
} catch {
|
|
35841
36084
|
return void 0;
|
|
35842
36085
|
}
|
|
@@ -35857,12 +36100,12 @@ function writeManifest(vaultDir, e) {
|
|
|
35857
36100
|
`);
|
|
35858
36101
|
}
|
|
35859
36102
|
function listEntries(vaultDir) {
|
|
35860
|
-
if (!
|
|
36103
|
+
if (!existsSync3(vaultDir)) return [];
|
|
35861
36104
|
const key = getUserKey();
|
|
35862
36105
|
const out = [];
|
|
35863
36106
|
for (const name of readdirSync3(vaultDir)) {
|
|
35864
36107
|
const file = join12(vaultDir, name, "manifest.json");
|
|
35865
|
-
if (!
|
|
36108
|
+
if (!existsSync3(file)) continue;
|
|
35866
36109
|
try {
|
|
35867
36110
|
const st = lstatSync4(file);
|
|
35868
36111
|
if (!st.isFile()) continue;
|
|
@@ -35896,7 +36139,7 @@ function readConfig(path) {
|
|
|
35896
36139
|
var writeConfig = (path, cfg) => writeFileSync2(path, `${JSON.stringify(cfg, null, 2)}
|
|
35897
36140
|
`, "utf8");
|
|
35898
36141
|
function quarantineServer(o) {
|
|
35899
|
-
const configPath =
|
|
36142
|
+
const configPath = resolve8(o.configPath);
|
|
35900
36143
|
const cfg = readConfig(configPath);
|
|
35901
36144
|
if (!cfg.ok) return cfg;
|
|
35902
36145
|
const entry = cfg.value.mcpServers?.[o.serverName];
|
|
@@ -36096,8 +36339,8 @@ var MAX_HASHED_BYTES = 64 * 1024 * 1024;
|
|
|
36096
36339
|
var MAX_EVENT_BYTES2 = 16 * 1024 * 1024;
|
|
36097
36340
|
|
|
36098
36341
|
// ../shield/src/locate.ts
|
|
36099
|
-
import { existsSync as
|
|
36100
|
-
import { dirname as
|
|
36342
|
+
import { existsSync as existsSync4, readdirSync as readdirSync4, statSync as statSync5 } from "node:fs";
|
|
36343
|
+
import { dirname as dirname5, isAbsolute as isAbsolute8, join as join13, parse as parse3, resolve as resolve9 } from "node:path";
|
|
36101
36344
|
import { fileURLToPath } from "node:url";
|
|
36102
36345
|
function hasDefinitions(dir) {
|
|
36103
36346
|
try {
|
|
@@ -36109,12 +36352,12 @@ function hasDefinitions(dir) {
|
|
|
36109
36352
|
function findDefinitionsDir(o) {
|
|
36110
36353
|
const env = o.env ?? process.env;
|
|
36111
36354
|
const cwd = o.cwd ?? process.cwd();
|
|
36112
|
-
if (o.explicit) return
|
|
36355
|
+
if (o.explicit) return resolve9(cwd, o.explicit);
|
|
36113
36356
|
const fromEnv = env["EXORCIST_DEFINITIONS"];
|
|
36114
|
-
if (fromEnv) return
|
|
36357
|
+
if (fromEnv) return resolve9(cwd, fromEnv);
|
|
36115
36358
|
const installed = findActiveInstalledSet({ env, ...o.publicKeyPem ? { publicKeyPem: o.publicKeyPem } : {} });
|
|
36116
36359
|
if (installed && hasDefinitions(installed.definitionsDir)) return installed.definitionsDir;
|
|
36117
|
-
const here =
|
|
36360
|
+
const here = dirname5(fileURLToPath(o.callerUrl));
|
|
36118
36361
|
const candidates = [join13(here, "..", "definitions"), join13(here, "..", "..", "..", "definitions"), join13(cwd, "definitions")];
|
|
36119
36362
|
return candidates.find(hasDefinitions) ?? null;
|
|
36120
36363
|
}
|
|
@@ -36149,9 +36392,9 @@ function isWrapped(entry) {
|
|
|
36149
36392
|
|
|
36150
36393
|
// src/tools.ts
|
|
36151
36394
|
import { homedir as homedir5 } from "node:os";
|
|
36152
|
-
import { basename as
|
|
36395
|
+
import { basename as basename7, dirname as dirname6, isAbsolute as isAbsolute9, join as join14, relative as relative7, resolve as resolve10, sep as sep3 } from "node:path";
|
|
36153
36396
|
var quotesWanted = (ctx2, asked) => asked === true && ctx2.noQuotes !== true;
|
|
36154
|
-
var RANK = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
36397
|
+
var RANK = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
|
|
36155
36398
|
var HIDDEN2 = /[\u200B-\u200D\uFEFF\u202A-\u202E\u2066-\u2069\u{E0000}-\u{E007F}]/gu;
|
|
36156
36399
|
var err = (text) => ({ text, isError: true });
|
|
36157
36400
|
function reveal(s) {
|
|
@@ -36161,16 +36404,16 @@ function findDefinitionsDir2(cwd) {
|
|
|
36161
36404
|
return findDefinitionsDir({ callerUrl: import.meta.url, cwd });
|
|
36162
36405
|
}
|
|
36163
36406
|
function resolveInside(cwd, p, roots = [], primary) {
|
|
36164
|
-
const real = (d) =>
|
|
36165
|
-
const extra = roots.filter((r) =>
|
|
36407
|
+
const real = (d) => realpathSync4(d);
|
|
36408
|
+
const extra = roots.filter((r) => existsSync5(r)).map(real);
|
|
36166
36409
|
const first = primary !== void 0 && extra.includes(real(primary)) ? [real(primary)] : [];
|
|
36167
36410
|
const bases = [.../* @__PURE__ */ new Set([...first, real(cwd), ...extra])];
|
|
36168
|
-
const tries = isAbsolute9(p) ? [p] : bases.map((b) =>
|
|
36169
|
-
const found = tries.find((t2) =>
|
|
36411
|
+
const tries = isAbsolute9(p) ? [p] : bases.map((b) => resolve10(b, p));
|
|
36412
|
+
const found = tries.find((t2) => existsSync5(t2));
|
|
36170
36413
|
if (!found) return { ok: false, error: `Path not found: ${p}` };
|
|
36171
|
-
const target =
|
|
36414
|
+
const target = realpathSync4(found);
|
|
36172
36415
|
const base = bases.find((b) => {
|
|
36173
|
-
const rel =
|
|
36416
|
+
const rel = relative7(b, target);
|
|
36174
36417
|
return !rel.startsWith("..") && !isAbsolute9(rel);
|
|
36175
36418
|
});
|
|
36176
36419
|
if (!base) {
|
|
@@ -36202,19 +36445,19 @@ var PROJECT_MARKERS = [
|
|
|
36202
36445
|
"README"
|
|
36203
36446
|
];
|
|
36204
36447
|
function looksLikeProject(dir) {
|
|
36205
|
-
const has = (n) =>
|
|
36448
|
+
const has = (n) => existsSync5(join14(dir, n));
|
|
36206
36449
|
if (has("plugin.json") || has("POWER.md")) return false;
|
|
36207
36450
|
return PROJECT_MARKERS.some(has);
|
|
36208
36451
|
}
|
|
36209
36452
|
var SENSITIVE_IN_HOME = [".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".password-store", join14("Library", "Keychains")];
|
|
36210
36453
|
var SENSITIVE_ABSOLUTE = ["/etc", "/private/etc", "/System", "/var/root", "/root"];
|
|
36211
36454
|
var isWithin = (base, p) => {
|
|
36212
|
-
const rel =
|
|
36455
|
+
const rel = relative7(base, p);
|
|
36213
36456
|
return rel === "" || !rel.startsWith("..") && !isAbsolute9(rel);
|
|
36214
36457
|
};
|
|
36215
36458
|
function sensitiveReason(real, home = homedir5()) {
|
|
36216
|
-
const realHome =
|
|
36217
|
-
if (
|
|
36459
|
+
const realHome = existsSync5(home) ? realpathSync4(home) : home;
|
|
36460
|
+
if (dirname6(real) === real) return "it is the filesystem root";
|
|
36218
36461
|
if (isWithin(real, realHome)) return real === realHome ? "it is the home folder" : "it contains the home folder";
|
|
36219
36462
|
for (const n of SENSITIVE_IN_HOME) {
|
|
36220
36463
|
const s = join14(realHome, n);
|
|
@@ -36244,8 +36487,8 @@ async function resolveAllowed(ctx2, p) {
|
|
|
36244
36487
|
}
|
|
36245
36488
|
let folder;
|
|
36246
36489
|
try {
|
|
36247
|
-
const real =
|
|
36248
|
-
folder = statSync6(real).isDirectory() ? real :
|
|
36490
|
+
const real = realpathSync4(p);
|
|
36491
|
+
folder = statSync6(real).isDirectory() ? real : dirname6(real);
|
|
36249
36492
|
} catch {
|
|
36250
36493
|
return first;
|
|
36251
36494
|
}
|
|
@@ -36277,16 +36520,16 @@ function usableRoots(entries, home) {
|
|
|
36277
36520
|
continue;
|
|
36278
36521
|
}
|
|
36279
36522
|
} else if (/^[a-z][a-z0-9+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) continue;
|
|
36280
|
-
if (!isAbsolute9(path) || !
|
|
36523
|
+
if (!isAbsolute9(path) || !existsSync5(path)) continue;
|
|
36281
36524
|
let real;
|
|
36282
36525
|
try {
|
|
36283
36526
|
if (!statSync6(path).isDirectory()) continue;
|
|
36284
|
-
real =
|
|
36527
|
+
real = realpathSync4(path);
|
|
36285
36528
|
} catch {
|
|
36286
36529
|
continue;
|
|
36287
36530
|
}
|
|
36288
|
-
const realHome =
|
|
36289
|
-
if (real ===
|
|
36531
|
+
const realHome = existsSync5(home) ? realpathSync4(home) : home;
|
|
36532
|
+
if (real === resolve10("/") || real === realHome || dirname6(real) === real) continue;
|
|
36290
36533
|
if (!out.includes(real)) out.push(real);
|
|
36291
36534
|
}
|
|
36292
36535
|
return out;
|
|
@@ -36317,7 +36560,7 @@ function describe(findings, limit, quotes) {
|
|
|
36317
36560
|
}
|
|
36318
36561
|
function summary(findings, files) {
|
|
36319
36562
|
if (findings.length === 0) return `No threats found. Scanned ${plural(files, "file")}.`;
|
|
36320
|
-
const counts = ["critical", "high", "medium", "low"].map((s) => ({ s, n: findings.filter((f) => f.severity === s).length })).filter((c) => c.n > 0).map((c) => `${c.n} ${c.s}`).join(", ");
|
|
36563
|
+
const counts = ["critical", "high", "medium", "low", "info"].map((s) => ({ s, n: findings.filter((f) => f.severity === s).length })).filter((c) => c.n > 0).map((c) => `${c.n} ${c.s}`).join(", ");
|
|
36321
36564
|
const withFindings = new Set(findings.map((f) => f.file)).size;
|
|
36322
36565
|
return `${plural(findings.length, "threat")} in ${plural(withFindings, "file")} (${counts}). Scanned ${plural(files, "file")}.`;
|
|
36323
36566
|
}
|
|
@@ -36329,8 +36572,8 @@ async function scanRepoTool(ctx2, a) {
|
|
|
36329
36572
|
const defs = await loadDefs(ctx2);
|
|
36330
36573
|
if (!defs.ok) return err(defs.error);
|
|
36331
36574
|
const isFile = statSync6(inside2.path).isFile();
|
|
36332
|
-
const root = isFile ?
|
|
36333
|
-
const only = isFile ?
|
|
36575
|
+
const root = isFile ? dirname6(inside2.path) : inside2.path;
|
|
36576
|
+
const only = isFile ? basename7(inside2.path) : null;
|
|
36334
36577
|
const findings = [];
|
|
36335
36578
|
let files = 0;
|
|
36336
36579
|
for await (const ev of scanRepo(root, { definitionsDir: ctx2.definitionsDir })) {
|
|
@@ -36356,7 +36599,7 @@ async function scanMcpConfigTool(ctx2, a) {
|
|
|
36356
36599
|
} catch {
|
|
36357
36600
|
return err(`${a.path} is not valid JSON.`);
|
|
36358
36601
|
}
|
|
36359
|
-
const rel =
|
|
36602
|
+
const rel = relative7(inside2.base, inside2.path);
|
|
36360
36603
|
const findings = scanText(text, "mcp-config", defs.defs, rel);
|
|
36361
36604
|
const servers = Object.entries(config2.mcpServers ?? {});
|
|
36362
36605
|
const local = servers.filter(([, e]) => typeof e["command"] === "string");
|
|
@@ -36405,7 +36648,7 @@ Tell the user. They can undo this with: exorcist vault restore ${r.value.id}`
|
|
|
36405
36648
|
}
|
|
36406
36649
|
|
|
36407
36650
|
// src/index.ts
|
|
36408
|
-
var VERSION = "0.3.
|
|
36651
|
+
var VERSION = "0.3.8";
|
|
36409
36652
|
var ctx = {
|
|
36410
36653
|
cwd: process.cwd(),
|
|
36411
36654
|
approved: [],
|