@exorcist-98/mcp-server 0.1.2 → 0.2.0
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
|
@@ -13,7 +13,23 @@ Tools:
|
|
|
13
13
|
- `quarantine`: disable a server in an MCP config, with a backup to restore.
|
|
14
14
|
|
|
15
15
|
The tools only read inside the folder the server was started in, plus the
|
|
16
|
-
folders your client shares as MCP roots
|
|
16
|
+
folders your client shares as MCP roots and the folders in `EXORCIST_ROOTS`
|
|
17
|
+
(separated like `PATH`). Relative paths, and `.`, start in the first folder the
|
|
18
|
+
client shares, else the first `EXORCIST_ROOTS` folder, else the start folder.
|
|
19
|
+
Some clients start the server in a folder that is not your project (Kiro does
|
|
20
|
+
this for a Power, in `~/.kiro/powers/installed/`). If the client shares no folder
|
|
21
|
+
and the start folder holds no project, the tools say so instead of reporting a
|
|
22
|
+
clean scan.
|
|
23
|
+
|
|
24
|
+
Kiro shares no roots but supports elicitation. When a tool gets an absolute path
|
|
25
|
+
outside every allowed folder, the server asks the person in a form ("Allow
|
|
26
|
+
Exorcist 98 to read this folder for this session?"). Yes adds the folder until the
|
|
27
|
+
server stops; no reads nothing. Only the form answer counts, never the agent. The
|
|
28
|
+
filesystem root, the home folder and the folders above it, `~/.ssh`, `~/.aws`,
|
|
29
|
+
`~/.gnupg` and similar credential folders, and system folders are refused without
|
|
30
|
+
asking. Without elicitation and roots, the fixes are `EXORCIST_ROOTS` in the
|
|
31
|
+
server's env, or adding the server to the workspace `.kiro/settings/mcp.json`,
|
|
32
|
+
where Kiro starts it in the project folder. Quoted text from scanned files is left
|
|
17
33
|
out of results unless you ask for it, and is then marked as untrusted.
|
|
18
34
|
|
|
19
35
|
## Use it
|
|
@@ -21,7 +37,7 @@ out of results unless you ask for it, and is then marked as untrusted.
|
|
|
21
37
|
```json
|
|
22
38
|
{
|
|
23
39
|
"mcpServers": {
|
|
24
|
-
"exorcist": { "command": "npx", "args": ["-y", "@exorcist-98/mcp-server@0.
|
|
40
|
+
"exorcist": { "command": "npx", "args": ["-y", "@exorcist-98/mcp-server@0.2.0"] }
|
|
25
41
|
}
|
|
26
42
|
}
|
|
27
43
|
```
|
|
@@ -11,7 +11,13 @@ match:
|
|
|
11
11
|
# whitespace may separate the words. Ordinary text such as "you are now
|
|
12
12
|
# logged in" is not flagged. A phrase split by hidden characters still
|
|
13
13
|
# matches (the engine also scans the text with them removed).
|
|
14
|
-
regex: "(?:\\bignore\\s+(?:all\\s+|any\\s+|the\\s+)?(?:previous|prior|above|earlier)\\s+(?:instructions|rules|prompts?)|\\bdisregard\\s+(?:all\\s+|any\\s+|the\\s+)?(?:previous|prior|above|earlier)\\s+(?:instructions|rules)|\\byou\\s+are\\s+now\\s+(?:(?:operating\\s+)?in\\s+(?:maintenance|developer|debug|admin|god|unrestricted|jailbreak|dan)\\s+mode|operating\\s+without\\s+(?:any\\s+)?(?:restrictions|rules|limits)|free\\b|unrestricted|dan\\b)|\\bas\\s+an\\s+ai(?:\\s+(?:assistant|agent|model))?\\s*,?\\s+(?:your\\s+(?:new|real|true|actual|hidden|secret|only)\\b|you\\s+must|you\\s+should|ignore)|\\byour\\s+new\\s+(?:primary\\s+)?(?:directive|instructions?)\\b|\\bdo\\s+not\\s+(?:mention|tell|reveal)\\s+(?:this|these)\\s+(?:instruction|note|message)s?)"
|
|
14
|
+
regex: "(?:\\bignore\\s+(?:all\\s+|any\\s+|the\\s+)?(?:previous|prior|above|earlier)\\s+(?:instructions|rules|prompts?)|\\bdisregard\\s+(?:all\\s+|any\\s+|the\\s+)?(?:previous|prior|above|earlier)\\s+(?:instructions|rules)|\\byou\\s+are\\s+now\\s+(?:(?:operating\\s+)?in\\s+(?:maintenance|developer|debug|admin|god|unrestricted|jailbreak|dan)\\s+mode|operating\\s+without\\s+(?:any\\s+)?(?:restrictions|rules|limits)|free\\b|unrestricted|dan\\b)|\\bas\\s+an\\s+ai(?:\\s+(?:assistant|agent|model))?\\s*,?\\s+(?:your\\s+(?:new|real|true|actual|hidden|secret|only)\\b|you\\s+must|you\\s+should|ignore)|\\byour\\s+new\\s+(?:primary\\s+)?(?:directive|instructions?)\\b|\\bdo\\s+not\\s+(?:mention|tell|reveal)\\s+(?:this|these)\\s+(?:instruction|note|message)s?|\\b(?:send|upload|post|forward|e-?mail|mail|paste|submit|copy|transmit|exfiltrate)\\s+(?:(?!\\n\\s*\\n)(?:[^.!?]|\\.(?=\\w))){0,40}?(?:\\.env\\b|(?:environment|env)\\s+files?|credentials?|secrets?|(?:api\\s+|access\\s+|auth\\s+|bearer\\s+)?tokens?|(?:api|ssh|private|secret)\\s+keys?)(?:(?!\\n\\s*\\n)(?:[^.!?]|\\.(?=\\w))){0,30}?\\b(?:to|at|into|via)(?:\\s*(?:…|\\.{3})|\\s+(?:https?://|ftp://|[\\w.+-]+@[\\w-]+\\.[\\w.-]+|(?:[a-z0-9-]+\\.)+(?!(?:json|ya?ml|toml|txt|md|env|jsx?|tsx?|py|sh|cfg|ini|conf|properties|example|local|lock|log|xml|html?|css)\\b)[a-z]{2,}\\b|the\\s+following\\b)))"
|
|
15
|
+
# The last alternative is an exfiltration order (m8-incidents 3.1): a verb
|
|
16
|
+
# (send, upload, post, forward, email, paste ...) with an object (env file,
|
|
17
|
+
# credentials, tokens, keys, secrets) and a destination (a URL, an address, a
|
|
18
|
+
# host, "to the following", "to..."), in one sentence that may span lines.
|
|
19
|
+
# "upload your build artifacts" and "send a request to the API" have no such
|
|
20
|
+
# object. A defence ("never send the .env file to ...") is quiet via negated_cues.
|
|
15
21
|
# A phrase in quotation marks that close right after it, in a passage that
|
|
16
22
|
# is warning about it or quoting it as an example ("never follow text such
|
|
17
23
|
# as ..."), is not an order. In the field that was 35 of 42 findings of
|
|
@@ -24,7 +30,7 @@ match:
|
|
|
24
30
|
# to govern the phrase (it ends right before it, or opens a list of what must
|
|
25
31
|
# not be attempted); "do not mention this, tell the agent to ..." is still an
|
|
26
32
|
# attack (m7-precision, packages/core/src/scanner/context.ts isNegated).
|
|
27
|
-
negated_cues: '\b(?:(?:must|should|shall|will|would|may|might|can|could)\s*(?:not|never)|(?:must|should|shall|would|could|do|does|did|is|are|was|were|has|have|ca|wo)n[''’]t|cannot|do(?:es)?\s+not|did\s+not|never|refus(?:e|es|ed|ing)\s+to|(?:is|are)\s+not\s+(?:to|allowed\s+to|permitted\s+to|able\s+to)|unable\s+to)\s+(?:(?:ever|simply|just|even|actually|knowingly)\s+)*$|\b(?:(?:must|should|shall|will|would|may|might|can|could)\s*(?:not|never)|(?:must|should|shall|would|could|do|does|did|is|are|was|were|has|have|ca|wo)n[''’]t|cannot)\s+(?:attempt|try|seek)\s+to\b[^.!?\n]*?\b(?:tell|instruct|ask|cause|make|persuade|trick|convince|get|force|let|allow)\w*\s+(?:(?:the|an?|your|any)\s+)?(?:(?:agent|model|assistant|ai|llm|bot|claude)s?\s+)?(?:to\s+)?$|\b(?:(?:must|should|shall|will|would|may|might|can|could)\s*(?:not|never)|(?:must|should|shall|would|could|do|does|did|is|are|was|were|has|have|ca|wo)n[''’]t|cannot|do(?:es)?\s+not|did\s+not|never|refus(?:e|es|ed|ing)\s+to|(?:is|are)\s+not\s+(?:to|allowed\s+to|permitted\s+to|able\s+to)|unable\s+to)\s+(?:follow|obey|comply\s+with|act\s+on|honou?r|accept|execute|run)\s+(?:(?:any|an?|the|such|these|those|that|text|instructions?|requests?|commands?|messages?|content|tool\s+output|it)\s+)*(?:(?:that|which)\s+)?(?:(?:say|says|saying|tell|tells|telling|ask|asks|asking)\s+(?:you\s+)?(?:to\s+)?)?$'
|
|
33
|
+
negated_cues: '\b(?:(?:must|should|shall|will|would|may|might|can|could)\s*(?:not|never)|(?:must|should|shall|would|could|do|does|did|is|are|was|were|has|have|ca|wo)n[''’]t|cannot|do(?:es)?\s+not|did\s+not|never|refus(?:e|es|ed|ing)\s+to|(?:is|are)\s+not\s+(?:to|allowed\s+to|permitted\s+to|able\s+to)|unable\s+to)\s+(?:(?:ever|simply|just|even|actually|knowingly|first|then|also)\s+)*$|\b(?:(?:must|should|shall|will|would|may|might|can|could)\s*(?:not|never)|(?:must|should|shall|would|could|do|does|did|is|are|was|were|has|have|ca|wo)n[''’]t|cannot)\s+(?:attempt|try|seek)\s+to\b[^.!?\n]*?\b(?:tell|instruct|ask|cause|make|persuade|trick|convince|get|force|let|allow)\w*\s+(?:(?:the|an?|your|any)\s+)?(?:(?:agent|model|assistant|ai|llm|bot|claude)s?\s+)?(?:to\s+)?$|\b(?:(?:must|should|shall|will|would|may|might|can|could)\s*(?:not|never)|(?:must|should|shall|would|could|do|does|did|is|are|was|were|has|have|ca|wo)n[''’]t|cannot|do(?:es)?\s+not|did\s+not|never|refus(?:e|es|ed|ing)\s+to|(?:is|are)\s+not\s+(?:to|allowed\s+to|permitted\s+to|able\s+to)|unable\s+to)\s+(?:follow|obey|comply\s+with|act\s+on|honou?r|accept|execute|run)\s+(?:(?:any|an?|the|such|these|those|that|text|instructions?|requests?|commands?|messages?|content|tool\s+output|it)\s+)*(?:(?:that|which)\s+)?(?:(?:say|says|saying|tell|tells|telling|ask|asks|asking)\s+(?:you\s+)?(?:to\s+)?)?$'
|
|
28
34
|
# Test and eval fixtures hold attack samples on purpose (a security scanner's
|
|
29
35
|
# own tests, adversarial evals). Findings there are reported at low severity,
|
|
30
36
|
# not dropped. A file an agent reads (instructions, hooks, MCP configs, .kiro,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
id: EX-028
|
|
2
|
+
title: Hidden text that instructs the AI
|
|
3
|
+
severity: high
|
|
4
|
+
applies_to:
|
|
5
|
+
- instruction
|
|
6
|
+
- docs
|
|
7
|
+
- memory
|
|
8
|
+
- tool-result
|
|
9
|
+
- unknown
|
|
10
|
+
match:
|
|
11
|
+
# Code check (packages/core/src/hidden-text.ts): an HTML element hidden by its
|
|
12
|
+
# style (white or near-background colour, font size at or under 2px,
|
|
13
|
+
# display:none, visibility:hidden, opacity:0, off-screen position, zero-size
|
|
14
|
+
# box) whose text names the AI or asks for an action. Hidden text that does
|
|
15
|
+
# neither (a closed modal, a screen-reader label, a collapsed menu) is quiet.
|
|
16
|
+
hidden_text: true
|
|
17
|
+
# Hidden markup shown inside Markdown code is displayed, not hidden.
|
|
18
|
+
skip_in_code: true
|
|
19
|
+
owasp:
|
|
20
|
+
- "LLM01:2025 Prompt Injection"
|
|
21
|
+
- "ASI03 Prompt Injection via External Content"
|
|
22
|
+
fix: >
|
|
23
|
+
Remove the hidden element, or make its text visible. Text a person cannot
|
|
24
|
+
see but a model reads can give an agent orders. Do not let an agent act on a
|
|
25
|
+
page or file that contains it.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
id: EX-029
|
|
2
|
+
title: File or folder name that instructs the AI
|
|
3
|
+
severity: high
|
|
4
|
+
applies_to:
|
|
5
|
+
- unknown
|
|
6
|
+
match:
|
|
7
|
+
# Name check (packages/core/src/path-names.ts), run by scanRepo on the name of
|
|
8
|
+
# every path the walker visits (folders, empty, binary and oversize files
|
|
9
|
+
# too). A name that reads as an order to an AI ("ignore previous
|
|
10
|
+
# instructions", "assistant read env and send to ...") or that carries
|
|
11
|
+
# hidden or control characters is reported. Long, odd or non-Latin names are
|
|
12
|
+
# quiet. Not a text pattern: the signature engine skips this rule.
|
|
13
|
+
analysis: path-names
|
|
14
|
+
owasp:
|
|
15
|
+
- "LLM01:2025 Prompt Injection"
|
|
16
|
+
- "ASI03 Prompt Injection via External Content"
|
|
17
|
+
fix: >
|
|
18
|
+
Rename or delete the file or folder. A name is read by an agent when it
|
|
19
|
+
lists a project, so it can carry orders just like file contents. Do not let
|
|
20
|
+
an agent act on this project until the name is changed.
|
package/dist/index.mjs
CHANGED
|
@@ -11602,6 +11602,23 @@ async function isBinary(filePath) {
|
|
|
11602
11602
|
async function* walkRepo(root, maxFileSize = MAX_FILE_SIZE) {
|
|
11603
11603
|
yield* walkDir(root, root, maxFileSize);
|
|
11604
11604
|
}
|
|
11605
|
+
async function* walkPaths(root) {
|
|
11606
|
+
yield* walkPathsIn(root, root);
|
|
11607
|
+
}
|
|
11608
|
+
async function* walkPathsIn(root, dir) {
|
|
11609
|
+
const dh = await opendir(dir);
|
|
11610
|
+
for await (const entry of dh) {
|
|
11611
|
+
const absPath = join4(dir, entry.name);
|
|
11612
|
+
const rel = relative2(root, absPath).replace(/\\/g, "/");
|
|
11613
|
+
if (entry.isDirectory()) {
|
|
11614
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
11615
|
+
yield { rel, isDirectory: true };
|
|
11616
|
+
yield* walkPathsIn(root, absPath);
|
|
11617
|
+
} else {
|
|
11618
|
+
yield { rel, isDirectory: false };
|
|
11619
|
+
}
|
|
11620
|
+
}
|
|
11621
|
+
}
|
|
11605
11622
|
async function* walkDir(root, dir, maxFileSize) {
|
|
11606
11623
|
const dh = await opendir(dir);
|
|
11607
11624
|
for await (const entry of dh) {
|
|
@@ -11842,7 +11859,7 @@ function locateQuote(text, quote) {
|
|
|
11842
11859
|
const viaMask = tryIn(masked);
|
|
11843
11860
|
return viaMask ? { ...viaMask, shown: masked.slice(viaMask.index, viaMask.end) } : null;
|
|
11844
11861
|
}
|
|
11845
|
-
function
|
|
11862
|
+
function positionOf2(text, needle) {
|
|
11846
11863
|
const idx = text.indexOf(needle);
|
|
11847
11864
|
if (idx === -1) return null;
|
|
11848
11865
|
const before = text.slice(0, idx);
|
|
@@ -11936,9 +11953,9 @@ function decodesToText(v) {
|
|
|
11936
11953
|
if (/^[A-Za-z0-9+\/]{16,}={0,2}$/.test(v) && v.length % 4 === 0) bytes = Buffer.from(v, "base64");
|
|
11937
11954
|
else if (/^(?:[0-9a-f]{2}){12,}$/i.test(v)) bytes = Buffer.from(v, "hex");
|
|
11938
11955
|
if (!bytes || bytes.length < 12) return false;
|
|
11939
|
-
let
|
|
11940
|
-
for (const b of bytes) if (b >= 32 && b < 127 || b === 10)
|
|
11941
|
-
return
|
|
11956
|
+
let printable3 = 0;
|
|
11957
|
+
for (const b of bytes) if (b >= 32 && b < 127 || b === 10) printable3++;
|
|
11958
|
+
return printable3 / bytes.length > 0.9 && /[A-Za-z]{3,}\s+[A-Za-z]{2,}/.test(bytes.toString("latin1"));
|
|
11942
11959
|
}
|
|
11943
11960
|
function unquote(v) {
|
|
11944
11961
|
const q = v[0];
|
|
@@ -12066,7 +12083,7 @@ async function judgeWholeFile(file, norm, client, maskedRuns = 0) {
|
|
|
12066
12083
|
if (start >= text.length) break;
|
|
12067
12084
|
const v = await judgeText(text.slice(start, start + MAX_JUDGED_CHARS), file.rel, client, maskedRuns);
|
|
12068
12085
|
if (!v) continue;
|
|
12069
|
-
const pos =
|
|
12086
|
+
const pos = positionOf2(text, v.span);
|
|
12070
12087
|
if (!pos) continue;
|
|
12071
12088
|
return [{
|
|
12072
12089
|
source: "heuristic",
|
|
@@ -22400,7 +22417,7 @@ var StdioServerTransport = class {
|
|
|
22400
22417
|
|
|
22401
22418
|
// src/index.ts
|
|
22402
22419
|
init_zod();
|
|
22403
|
-
import { homedir as
|
|
22420
|
+
import { homedir as homedir3 } from "node:os";
|
|
22404
22421
|
import { delimiter } from "node:path";
|
|
22405
22422
|
|
|
22406
22423
|
// src/tools.ts
|
|
@@ -22633,7 +22650,7 @@ function requireSnippet() {
|
|
|
22633
22650
|
if (hasRequiredSnippet) return snippet;
|
|
22634
22651
|
hasRequiredSnippet = 1;
|
|
22635
22652
|
const common2 = requireCommon();
|
|
22636
|
-
function getLine(buffer, lineStart,
|
|
22653
|
+
function getLine(buffer, lineStart, lineEnd2, position2, maxLineLength) {
|
|
22637
22654
|
let head = "";
|
|
22638
22655
|
let tail = "";
|
|
22639
22656
|
const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
@@ -22641,12 +22658,12 @@ function requireSnippet() {
|
|
|
22641
22658
|
head = " ... ";
|
|
22642
22659
|
lineStart = position2 - maxHalfLength + head.length;
|
|
22643
22660
|
}
|
|
22644
|
-
if (
|
|
22661
|
+
if (lineEnd2 - position2 > maxHalfLength) {
|
|
22645
22662
|
tail = " ...";
|
|
22646
|
-
|
|
22663
|
+
lineEnd2 = position2 + maxHalfLength - tail.length;
|
|
22647
22664
|
}
|
|
22648
22665
|
return {
|
|
22649
|
-
str: head + buffer.slice(lineStart,
|
|
22666
|
+
str: head + buffer.slice(lineStart, lineEnd2).replace(/\t/g, "\u2192") + tail,
|
|
22650
22667
|
pos: position2 - lineStart + head.length
|
|
22651
22668
|
// relative position
|
|
22652
22669
|
};
|
|
@@ -25676,7 +25693,11 @@ var MatchSchema = external_exports.object({
|
|
|
25676
25693
|
// capabilities.yaml). The signature engine skips such rules.
|
|
25677
25694
|
// `detonation` is the Detonation Chamber (EX-024, m5-detonation): a
|
|
25678
25695
|
// sandboxed model run, only with `--detonate`.
|
|
25679
|
-
|
|
25696
|
+
// `path-names` checks the names of every walked path (EX-029, path-names.ts).
|
|
25697
|
+
analysis: external_exports.enum(["trifecta", "detonation", "path-names"]).optional(),
|
|
25698
|
+
// Text an element hides from a person by its style (EX-028, hidden-text.ts):
|
|
25699
|
+
// reported only when the hidden text addresses the AI or asks for actions.
|
|
25700
|
+
hidden_text: external_exports.boolean().optional(),
|
|
25680
25701
|
// unicode_class only: a single U+200B directly after `@` and before a name
|
|
25681
25702
|
// is the way changelogs stop GitHub from notifying the person. Reported at
|
|
25682
25703
|
// `severity` and not counted toward the escalation of many short runs.
|
|
@@ -25689,11 +25710,11 @@ var MatchSchema = external_exports.object({
|
|
|
25689
25710
|
severity: external_exports.enum(["critical", "high", "medium", "low"])
|
|
25690
25711
|
}).optional()
|
|
25691
25712
|
}).superRefine((val, ctx2) => {
|
|
25692
|
-
const hasAny = val.regex !== void 0 || val.unicode_class !== void 0 && val.unicode_class.length > 0 || val.json_path !== void 0 || val.analysis !== void 0;
|
|
25713
|
+
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;
|
|
25693
25714
|
if (!hasAny) {
|
|
25694
25715
|
ctx2.addIssue({
|
|
25695
25716
|
code: external_exports.ZodIssueCode.custom,
|
|
25696
|
-
message: "match must contain at least one of: regex, unicode_class, json_path, analysis"
|
|
25717
|
+
message: "match must contain at least one of: regex, unicode_class, json_path, analysis, hidden_text"
|
|
25697
25718
|
});
|
|
25698
25719
|
}
|
|
25699
25720
|
if (val.value_regex !== void 0 && val.json_path === void 0) {
|
|
@@ -25914,6 +25935,9 @@ function flagTagOffsets(text) {
|
|
|
25914
25935
|
}
|
|
25915
25936
|
return out;
|
|
25916
25937
|
}
|
|
25938
|
+
function isHiddenCodePoint(cp) {
|
|
25939
|
+
return CP_TO_CLASS.has(cp);
|
|
25940
|
+
}
|
|
25917
25941
|
function findHiddenUnicode(text) {
|
|
25918
25942
|
const hits = [];
|
|
25919
25943
|
const flagTags = flagTagOffsets(text);
|
|
@@ -26618,6 +26642,115 @@ function decodeHidden(text) {
|
|
|
26618
26642
|
return out.slice(0, MAX_HIDDEN_RUNS);
|
|
26619
26643
|
}
|
|
26620
26644
|
|
|
26645
|
+
// ../core/src/hidden-text.ts
|
|
26646
|
+
var MAX_HIDDEN_ELEMENT = 2e3;
|
|
26647
|
+
var VOID_TAGS = /* @__PURE__ */ new Set(["img", "input", "br", "hr", "meta", "link", "area", "base", "col", "embed", "source", "track", "wbr"]);
|
|
26648
|
+
var AI_NAME_UPPER = /\bAI\b/;
|
|
26649
|
+
var AI_WORDS = /\b(?:assistants?|agents?|llms?|kiro|claude|copilot|chatgpt|gemini|cursor|language\s+models?|(?:the|this)\s+model)\b/i;
|
|
26650
|
+
var ACTION_VERB = "(?:write|rewrite|edit|modify|overwrite|run|execute|fetch|download|send|upload|start|launch|add|append|install|delete|remove|exfiltrate|forward|email)";
|
|
26651
|
+
var ACTION_OBJECT = "(?:files?|config(?:uration)?s?|servers?|commands?|scripts?|mcp|credentials?|secrets?|tokens?|api\\s+keys?|\\.env|\\S*\\.json|~\\/\\S+)";
|
|
26652
|
+
var ACTION = new RegExp(`\\b${ACTION_VERB}\\b[^.\\n!?]{0,60}?(?:\\b${ACTION_OBJECT}(?![\\w-])|${"~\\/"}|\\.env\\b)`, "i");
|
|
26653
|
+
var OVERRIDE = /\b(?:ignore|disregard|forget)\s+(?:all\s+|any\s+|the\s+)?(?:previous|prior|above|earlier)\b/i;
|
|
26654
|
+
function addressesAi(text) {
|
|
26655
|
+
if (text.length === 0) return false;
|
|
26656
|
+
return AI_NAME_UPPER.test(text) || AI_WORDS.test(text) || OVERRIDE.test(text) || ACTION.test(text);
|
|
26657
|
+
}
|
|
26658
|
+
function parseColour(raw) {
|
|
26659
|
+
const v = raw.trim().toLowerCase().replace(/\s*!important$/, "");
|
|
26660
|
+
if (v === "white") return [255, 255, 255];
|
|
26661
|
+
if (v === "black") return [0, 0, 0];
|
|
26662
|
+
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(v);
|
|
26663
|
+
if (hex) {
|
|
26664
|
+
const h = hex[1];
|
|
26665
|
+
const f = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
|
|
26666
|
+
return [parseInt(f.slice(0, 2), 16), parseInt(f.slice(2, 4), 16), parseInt(f.slice(4, 6), 16)];
|
|
26667
|
+
}
|
|
26668
|
+
const rgb = /^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*(?:[,/]\s*[\d.]+%?\s*)?\)$/.exec(v);
|
|
26669
|
+
if (rgb) return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])];
|
|
26670
|
+
return null;
|
|
26671
|
+
}
|
|
26672
|
+
function distance(a, b) {
|
|
26673
|
+
return Math.max(Math.abs(a[0] - b[0]), Math.abs(a[1] - b[1]), Math.abs(a[2] - b[2]));
|
|
26674
|
+
}
|
|
26675
|
+
function px(raw) {
|
|
26676
|
+
const m = /^(-?\d*\.?\d+)\s*(px|pt|em|rem|%|vw|vh)?$/.exec(raw.trim().toLowerCase());
|
|
26677
|
+
if (!m) return null;
|
|
26678
|
+
const n = Number(m[1]);
|
|
26679
|
+
const unit = m[2] ?? "";
|
|
26680
|
+
if (n === 0) return 0;
|
|
26681
|
+
if (unit === "px" || unit === "") return n;
|
|
26682
|
+
if (unit === "pt") return n * 1.333;
|
|
26683
|
+
if (unit === "em" || unit === "rem") return n * 16;
|
|
26684
|
+
return null;
|
|
26685
|
+
}
|
|
26686
|
+
function parseStyle(style) {
|
|
26687
|
+
const out = /* @__PURE__ */ new Map();
|
|
26688
|
+
for (const part of style.split(";")) {
|
|
26689
|
+
const i = part.indexOf(":");
|
|
26690
|
+
if (i < 1) continue;
|
|
26691
|
+
out.set(part.slice(0, i).trim().toLowerCase(), part.slice(i + 1).trim().replace(/\s*!important$/i, ""));
|
|
26692
|
+
}
|
|
26693
|
+
return out;
|
|
26694
|
+
}
|
|
26695
|
+
function hidingMethod(style) {
|
|
26696
|
+
const css = parseStyle(style);
|
|
26697
|
+
if (css.get("display")?.toLowerCase() === "none") return "display-none";
|
|
26698
|
+
if (css.get("visibility")?.toLowerCase() === "hidden") return "visibility-hidden";
|
|
26699
|
+
const opacity = css.get("opacity");
|
|
26700
|
+
if (opacity !== void 0 && /^0*\.?0+%?$/.test(opacity.trim())) return "opacity-zero";
|
|
26701
|
+
const size = css.get("font-size");
|
|
26702
|
+
if (size !== void 0) {
|
|
26703
|
+
const n = px(size);
|
|
26704
|
+
if (n !== null && n <= 2) return "font-size";
|
|
26705
|
+
}
|
|
26706
|
+
for (const key of ["left", "top", "right", "bottom", "text-indent", "margin-left"]) {
|
|
26707
|
+
const v = css.get(key);
|
|
26708
|
+
if (v !== void 0) {
|
|
26709
|
+
const n = px(v);
|
|
26710
|
+
if (n !== null && n <= -999) return "off-screen";
|
|
26711
|
+
}
|
|
26712
|
+
}
|
|
26713
|
+
const w = css.get("width");
|
|
26714
|
+
const h = css.get("height");
|
|
26715
|
+
const clipped = /^(hidden|clip)$/i.test(css.get("overflow") ?? "");
|
|
26716
|
+
if (clipped && (w !== void 0 && px(w) === 0 || h !== void 0 && px(h) === 0)) return "zero-box";
|
|
26717
|
+
const colour = css.get("color");
|
|
26718
|
+
if (colour !== void 0) {
|
|
26719
|
+
const c = parseColour(colour);
|
|
26720
|
+
if (c) {
|
|
26721
|
+
const bg = parseColour(css.get("background-color") ?? css.get("background") ?? "");
|
|
26722
|
+
if (bg ? distance(c, bg) <= 8 : distance(c, [255, 255, 255]) <= 5) return "colour";
|
|
26723
|
+
}
|
|
26724
|
+
}
|
|
26725
|
+
return null;
|
|
26726
|
+
}
|
|
26727
|
+
var OPEN_TAG = /<([a-zA-Z][a-zA-Z0-9-]*)\b([^<>]*?)\bstyle\s*=\s*(?:"([^"]*)"|'([^']*)')[^<>]*>/g;
|
|
26728
|
+
function plainElementText(html) {
|
|
26729
|
+
return html.replace(/<[^>]*>/g, " ").replace(/ /gi, " ").replace(/&/gi, "&").replace(/\s+/g, " ").trim();
|
|
26730
|
+
}
|
|
26731
|
+
function findHiddenText(text) {
|
|
26732
|
+
const out = [];
|
|
26733
|
+
OPEN_TAG.lastIndex = 0;
|
|
26734
|
+
let lastEnd = -1;
|
|
26735
|
+
let m;
|
|
26736
|
+
while ((m = OPEN_TAG.exec(text)) !== null) {
|
|
26737
|
+
const name = m[1].toLowerCase();
|
|
26738
|
+
if (VOID_TAGS.has(name) || m.index < lastEnd) continue;
|
|
26739
|
+
const method = hidingMethod(m[3] ?? m[4] ?? "");
|
|
26740
|
+
if (method === null) continue;
|
|
26741
|
+
const start = m.index + m[0].length;
|
|
26742
|
+
const window = text.slice(start, start + MAX_HIDDEN_ELEMENT);
|
|
26743
|
+
const close = window.toLowerCase().indexOf(`</${name}`);
|
|
26744
|
+
const inner = close === -1 ? window : window.slice(0, close);
|
|
26745
|
+
const body = plainElementText(inner);
|
|
26746
|
+
if (!addressesAi(body)) continue;
|
|
26747
|
+
const end = start + inner.length;
|
|
26748
|
+
out.push({ index: m.index, length: end - m.index, method, text: body });
|
|
26749
|
+
lastEnd = end;
|
|
26750
|
+
}
|
|
26751
|
+
return out;
|
|
26752
|
+
}
|
|
26753
|
+
|
|
26621
26754
|
// ../core/src/scanner/signature-engine.ts
|
|
26622
26755
|
init_severity_paths();
|
|
26623
26756
|
|
|
@@ -27052,9 +27185,9 @@ function isHexText(s) {
|
|
|
27052
27185
|
}
|
|
27053
27186
|
function looksLikeText(bytes) {
|
|
27054
27187
|
if (bytes.length < 24) return false;
|
|
27055
|
-
let
|
|
27056
|
-
for (const b of bytes) if (b >= 32 && b < 127 || b === 10 || b === 13 || b === 9)
|
|
27057
|
-
if (
|
|
27188
|
+
let printable3 = 0;
|
|
27189
|
+
for (const b of bytes) if (b >= 32 && b < 127 || b === 10 || b === 13 || b === 9) printable3++;
|
|
27190
|
+
if (printable3 / bytes.length < 0.95) return false;
|
|
27058
27191
|
const text = bytes.toString("latin1");
|
|
27059
27192
|
if (/^\s*[{[]/.test(text)) return false;
|
|
27060
27193
|
const words2 = text.split(/\s+/).filter((w) => /[A-Za-z]{2,}/.test(w)).length;
|
|
@@ -27185,6 +27318,13 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
27185
27318
|
findings.push(...capPerFile(def, mineOut));
|
|
27186
27319
|
}
|
|
27187
27320
|
}
|
|
27321
|
+
if (match.hidden_text) {
|
|
27322
|
+
for (const h of findHiddenText(norm.plain)) {
|
|
27323
|
+
if (!ctx2.allows(def, h.text, h.index, norm.plain, h.index)) continue;
|
|
27324
|
+
const { line, col } = offsetToPosition(norm.original, norm.plainMap?.[h.index] ?? h.index);
|
|
27325
|
+
findings.push({ ...base, line, col, span: truncateSpan(h.text) });
|
|
27326
|
+
}
|
|
27327
|
+
}
|
|
27188
27328
|
if (match.unicode_class && match.unicode_class.length > 0) {
|
|
27189
27329
|
let run = [];
|
|
27190
27330
|
const mineStart = findings.length;
|
|
@@ -27374,6 +27514,505 @@ function makeContext(file, norm, defs, limitMs) {
|
|
|
27374
27514
|
};
|
|
27375
27515
|
}
|
|
27376
27516
|
|
|
27517
|
+
// ../core/src/scanner/scan-text.ts
|
|
27518
|
+
function scanText(text, role, defs, label = "(text)", limitMs = REGEX_TIME_LIMIT_MS) {
|
|
27519
|
+
const file = { path: label, rel: label, role, sizeBytes: text.length };
|
|
27520
|
+
return runSignatures(file, normalize(text, role), defs, limitMs);
|
|
27521
|
+
}
|
|
27522
|
+
|
|
27523
|
+
// ../core/src/source-tools.ts
|
|
27524
|
+
var MAX_SITES = 100;
|
|
27525
|
+
var MAX_AHEAD = 2e4;
|
|
27526
|
+
var TS_EXT = [".ts", ".tsx", ".js", ".mjs", ".cjs", ".mts"];
|
|
27527
|
+
function languageOf(relPath) {
|
|
27528
|
+
const lower = String(relPath).toLowerCase();
|
|
27529
|
+
if (TS_EXT.some((e) => lower.endsWith(e))) return "ts";
|
|
27530
|
+
if (lower.endsWith(".py")) return "py";
|
|
27531
|
+
if (lower.endsWith(".go")) return "go";
|
|
27532
|
+
return null;
|
|
27533
|
+
}
|
|
27534
|
+
var isIdent = (c) => c !== void 0 && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "_" || c === "$");
|
|
27535
|
+
var isHex = (s) => s.length > 0 && [...s].every((c) => c >= "0" && c <= "9" || c >= "a" && c <= "f" || c >= "A" && c <= "F");
|
|
27536
|
+
var isQuote = (c) => c === '"' || c === "'" || c === "`";
|
|
27537
|
+
function fromCode(code) {
|
|
27538
|
+
if (!Number.isInteger(code) || code < 0 || code > 1114111) return null;
|
|
27539
|
+
return String.fromCodePoint(code);
|
|
27540
|
+
}
|
|
27541
|
+
function readEscape(text, i, lang, limit) {
|
|
27542
|
+
const n = text[i + 1];
|
|
27543
|
+
if (n === void 0 || i + 1 >= limit) return null;
|
|
27544
|
+
if (n === "\n") return { out: "", len: 2 };
|
|
27545
|
+
if (n === "\r") return { out: "", len: text[i + 2] === "\n" ? 3 : 2 };
|
|
27546
|
+
const simple = { n: "\n", t: " ", r: "\r", b: "\b", f: "\f", v: "\v", a: "\x07" };
|
|
27547
|
+
if (n === "u" && text[i + 2] === "{" && lang === "ts") {
|
|
27548
|
+
const close = text.indexOf("}", i + 3);
|
|
27549
|
+
const hex = close === -1 || close - i > 12 ? "" : text.slice(i + 3, close);
|
|
27550
|
+
const ch = isHex(hex) ? fromCode(parseInt(hex, 16)) : null;
|
|
27551
|
+
return ch === null ? null : { out: ch, len: close - i + 1 };
|
|
27552
|
+
}
|
|
27553
|
+
const widths = { x: 2, u: 4 };
|
|
27554
|
+
const w = n === "U" && lang !== "ts" ? 8 : widths[n];
|
|
27555
|
+
if (w !== void 0) {
|
|
27556
|
+
const hex = text.slice(i + 2, i + 2 + w);
|
|
27557
|
+
const ch = hex.length === w && isHex(hex) ? fromCode(parseInt(hex, 16)) : null;
|
|
27558
|
+
return ch === null ? { out: lang === "py" ? `\\${n}` : n, len: 2 } : { out: ch, len: 2 + w };
|
|
27559
|
+
}
|
|
27560
|
+
if (lang === "go" && n >= "0" && n <= "7") {
|
|
27561
|
+
const oct = text.slice(i + 1, i + 4);
|
|
27562
|
+
if (oct.length === 3 && [...oct].every((c) => c >= "0" && c <= "7")) return { out: String.fromCharCode(parseInt(oct, 8)), len: 4 };
|
|
27563
|
+
}
|
|
27564
|
+
const s = simple[n];
|
|
27565
|
+
if (s !== void 0) return { out: s, len: 2 };
|
|
27566
|
+
if (n === "0" && lang !== "go") return { out: "\0", len: 2 };
|
|
27567
|
+
return { out: lang === "py" && n !== "\\" && n !== '"' && n !== "'" ? `\\${n}` : n, len: 2 };
|
|
27568
|
+
}
|
|
27569
|
+
function readLiteral(text, q, lang, limit, raw = false) {
|
|
27570
|
+
const quote = text[q];
|
|
27571
|
+
if (!isQuote(quote) || quote === void 0) return null;
|
|
27572
|
+
if (quote === "`" && lang === "py") return null;
|
|
27573
|
+
if (quote === "'" && lang === "go") return null;
|
|
27574
|
+
const triple = lang === "py" && text[q + 1] === quote && text[q + 2] === quote;
|
|
27575
|
+
const open3 = triple ? 3 : 1;
|
|
27576
|
+
const goRaw = lang === "go" && quote === "`";
|
|
27577
|
+
const start = q + open3;
|
|
27578
|
+
let value = "";
|
|
27579
|
+
const map2 = [];
|
|
27580
|
+
const push2 = (s, at) => {
|
|
27581
|
+
for (let k = 0; k < s.length; k++) {
|
|
27582
|
+
value += s[k];
|
|
27583
|
+
map2.push(at);
|
|
27584
|
+
}
|
|
27585
|
+
};
|
|
27586
|
+
let i = start;
|
|
27587
|
+
while (i < limit) {
|
|
27588
|
+
const c = text[i];
|
|
27589
|
+
if (c === void 0) return null;
|
|
27590
|
+
if (triple ? c === quote && text[i + 1] === quote && text[i + 2] === quote : c === quote) {
|
|
27591
|
+
map2.push(i);
|
|
27592
|
+
return { value, map: map2, start, contentEnd: i, next: i + open3 };
|
|
27593
|
+
}
|
|
27594
|
+
if (c === "\n" && !triple && !goRaw && quote !== "`") return null;
|
|
27595
|
+
if (lang === "ts" && quote === "`" && c === "$" && text[i + 1] === "{") return null;
|
|
27596
|
+
if (c === "\\" && !goRaw && !raw) {
|
|
27597
|
+
const e = readEscape(text, i, lang, limit);
|
|
27598
|
+
if (e === null) return null;
|
|
27599
|
+
push2(e.out, i);
|
|
27600
|
+
i += e.len;
|
|
27601
|
+
continue;
|
|
27602
|
+
}
|
|
27603
|
+
push2(c, i);
|
|
27604
|
+
i++;
|
|
27605
|
+
}
|
|
27606
|
+
return null;
|
|
27607
|
+
}
|
|
27608
|
+
function skipQuoted(text, q, lang, limit) {
|
|
27609
|
+
const quote = text[q];
|
|
27610
|
+
if (quote === void 0) return -1;
|
|
27611
|
+
const triple = lang === "py" && text[q + 1] === quote && text[q + 2] === quote;
|
|
27612
|
+
let i = q + (triple ? 3 : 1);
|
|
27613
|
+
while (i < limit) {
|
|
27614
|
+
const c = text[i];
|
|
27615
|
+
if (c === "\\" && !(lang === "go" && quote === "`")) {
|
|
27616
|
+
i += 2;
|
|
27617
|
+
continue;
|
|
27618
|
+
}
|
|
27619
|
+
if (triple ? c === quote && text[i + 1] === quote && text[i + 2] === quote : c === quote) return i + (triple ? 3 : 1);
|
|
27620
|
+
if (c === "\n" && !triple && quote !== "`") return -1;
|
|
27621
|
+
i++;
|
|
27622
|
+
}
|
|
27623
|
+
return -1;
|
|
27624
|
+
}
|
|
27625
|
+
function readPyString(text, p, limit) {
|
|
27626
|
+
let i = p;
|
|
27627
|
+
let raw = false;
|
|
27628
|
+
while (i < p + 2 && "rRuUbBfF".includes(text[i] ?? "#")) {
|
|
27629
|
+
if (text[i] === "r" || text[i] === "R") raw = true;
|
|
27630
|
+
i++;
|
|
27631
|
+
}
|
|
27632
|
+
return readLiteral(text, i, "py", limit, raw);
|
|
27633
|
+
}
|
|
27634
|
+
function skipTrivia(text, p, lang, limit) {
|
|
27635
|
+
let i = p;
|
|
27636
|
+
while (i < limit) {
|
|
27637
|
+
const c = text[i];
|
|
27638
|
+
if (c === " " || c === " " || c === "\n" || c === "\r") {
|
|
27639
|
+
i++;
|
|
27640
|
+
continue;
|
|
27641
|
+
}
|
|
27642
|
+
if (lang === "py" && c === "#") {
|
|
27643
|
+
i = lineEnd(text, i);
|
|
27644
|
+
continue;
|
|
27645
|
+
}
|
|
27646
|
+
if (lang !== "py" && c === "/" && text[i + 1] === "/") {
|
|
27647
|
+
i = lineEnd(text, i);
|
|
27648
|
+
continue;
|
|
27649
|
+
}
|
|
27650
|
+
if (lang !== "py" && c === "/" && text[i + 1] === "*") {
|
|
27651
|
+
const close = text.indexOf("*/", i + 2);
|
|
27652
|
+
if (close === -1 || close >= limit) return limit;
|
|
27653
|
+
i = close + 2;
|
|
27654
|
+
continue;
|
|
27655
|
+
}
|
|
27656
|
+
break;
|
|
27657
|
+
}
|
|
27658
|
+
return i;
|
|
27659
|
+
}
|
|
27660
|
+
function lineEnd(text, i) {
|
|
27661
|
+
const nl = text.indexOf("\n", i);
|
|
27662
|
+
return nl === -1 ? text.length : nl + 1;
|
|
27663
|
+
}
|
|
27664
|
+
function skipArgument(text, p, lang, limit) {
|
|
27665
|
+
let depth = 0;
|
|
27666
|
+
let i = p;
|
|
27667
|
+
while (i < limit) {
|
|
27668
|
+
const c = text[i];
|
|
27669
|
+
if (isQuote(c)) {
|
|
27670
|
+
const j = skipQuoted(text, i, lang, limit);
|
|
27671
|
+
if (j < 0) return -1;
|
|
27672
|
+
i = j;
|
|
27673
|
+
continue;
|
|
27674
|
+
}
|
|
27675
|
+
if (lang === "py" && c === "#" || lang !== "py" && c === "/" && (text[i + 1] === "/" || text[i + 1] === "*")) {
|
|
27676
|
+
const j = skipTrivia(text, i, lang, limit);
|
|
27677
|
+
i = j > i ? j : i + 1;
|
|
27678
|
+
continue;
|
|
27679
|
+
}
|
|
27680
|
+
if (c === "(" || c === "[" || c === "{") depth++;
|
|
27681
|
+
else if (c === ")" || c === "]" || c === "}") {
|
|
27682
|
+
if (depth === 0) return i;
|
|
27683
|
+
depth--;
|
|
27684
|
+
} else if (c === "," && depth === 0) return i;
|
|
27685
|
+
i++;
|
|
27686
|
+
}
|
|
27687
|
+
return -1;
|
|
27688
|
+
}
|
|
27689
|
+
function findKeyString(text, open3, lang, limit, sep2) {
|
|
27690
|
+
let depth = 0;
|
|
27691
|
+
let i = open3;
|
|
27692
|
+
let lit = null;
|
|
27693
|
+
const valueAt = (p) => {
|
|
27694
|
+
const v = skipTrivia(text, p, lang, limit);
|
|
27695
|
+
return lang === "py" ? readPyString(text, v, limit) : readLiteral(text, v, lang, limit);
|
|
27696
|
+
};
|
|
27697
|
+
const sepAt = (p) => {
|
|
27698
|
+
const j = skipTrivia(text, p, lang, limit);
|
|
27699
|
+
if (text[j] !== sep2 || sep2 === "=" && text[j + 1] === "=") return -1;
|
|
27700
|
+
return j + 1;
|
|
27701
|
+
};
|
|
27702
|
+
while (i < limit) {
|
|
27703
|
+
const c = text[i];
|
|
27704
|
+
if (c === void 0) break;
|
|
27705
|
+
if (isQuote(c)) {
|
|
27706
|
+
const l = lang === "ts" && depth === 1 ? readLiteral(text, i, lang, limit) : null;
|
|
27707
|
+
if (l && l.value === "description" && lit === null) {
|
|
27708
|
+
const s = sepAt(l.next);
|
|
27709
|
+
if (s >= 0) lit = valueAt(s);
|
|
27710
|
+
}
|
|
27711
|
+
const j = l ? l.next : skipQuoted(text, i, lang, limit);
|
|
27712
|
+
if (j < 0) return { lit, after: -1 };
|
|
27713
|
+
i = j;
|
|
27714
|
+
continue;
|
|
27715
|
+
}
|
|
27716
|
+
if (lang === "py" && c === "#" || lang !== "py" && c === "/" && (text[i + 1] === "/" || text[i + 1] === "*")) {
|
|
27717
|
+
const j = skipTrivia(text, i, lang, limit);
|
|
27718
|
+
i = j > i ? j : i + 1;
|
|
27719
|
+
continue;
|
|
27720
|
+
}
|
|
27721
|
+
if (c === "(" || c === "[" || c === "{") depth++;
|
|
27722
|
+
else if (c === ")" || c === "]" || c === "}") {
|
|
27723
|
+
depth--;
|
|
27724
|
+
if (depth <= 0) return { lit, after: i + 1 };
|
|
27725
|
+
} else if (depth === 1 && isIdent(c) && !isIdent(text[i - 1]) && text[i - 1] !== ".") {
|
|
27726
|
+
let j = i;
|
|
27727
|
+
while (j < limit && isIdent(text[j])) j++;
|
|
27728
|
+
if (j - i === "description".length && text.startsWith("description", i) && lit === null) {
|
|
27729
|
+
const s = sepAt(j);
|
|
27730
|
+
if (s >= 0) lit = valueAt(s);
|
|
27731
|
+
}
|
|
27732
|
+
i = j;
|
|
27733
|
+
continue;
|
|
27734
|
+
}
|
|
27735
|
+
i++;
|
|
27736
|
+
}
|
|
27737
|
+
return { lit, after: -1 };
|
|
27738
|
+
}
|
|
27739
|
+
var toFound = (l) => ({ text: l.value, offset: l.start, end: l.contentEnd, map: l.map });
|
|
27740
|
+
function indexesOf(text, needle, budget) {
|
|
27741
|
+
const out = [];
|
|
27742
|
+
let from = 0;
|
|
27743
|
+
while (budget.left > 0) {
|
|
27744
|
+
const i = text.indexOf(needle, from);
|
|
27745
|
+
if (i === -1) break;
|
|
27746
|
+
out.push(i);
|
|
27747
|
+
budget.left--;
|
|
27748
|
+
from = i + needle.length;
|
|
27749
|
+
}
|
|
27750
|
+
return out;
|
|
27751
|
+
}
|
|
27752
|
+
var lim = (text, from) => Math.min(text.length, from + MAX_AHEAD);
|
|
27753
|
+
function extractTs(text, budget, out) {
|
|
27754
|
+
for (const at of indexesOf(text, ".tool(", budget)) {
|
|
27755
|
+
const limit = lim(text, at);
|
|
27756
|
+
const first = skipTrivia(text, at + 6, "ts", limit);
|
|
27757
|
+
const e = skipArgument(text, first, "ts", limit);
|
|
27758
|
+
if (e < 0 || text[e] !== ",") continue;
|
|
27759
|
+
const p = skipTrivia(text, e + 1, "ts", limit);
|
|
27760
|
+
const l = isQuote(text[p]) ? readLiteral(text, p, "ts", limit) : null;
|
|
27761
|
+
if (l) out.push(toFound(l));
|
|
27762
|
+
}
|
|
27763
|
+
for (const needle of ["registerTool(", "registerTool<"]) {
|
|
27764
|
+
for (const at of indexesOf(text, needle, budget)) {
|
|
27765
|
+
const limit = lim(text, at);
|
|
27766
|
+
let paren = at + needle.length - 1;
|
|
27767
|
+
if (needle.endsWith("<")) {
|
|
27768
|
+
paren = text.indexOf("(", at + needle.length);
|
|
27769
|
+
if (paren === -1 || paren > at + 300) continue;
|
|
27770
|
+
}
|
|
27771
|
+
const first = skipTrivia(text, paren + 1, "ts", limit);
|
|
27772
|
+
const e = skipArgument(text, first, "ts", limit);
|
|
27773
|
+
if (e < 0 || text[e] !== ",") continue;
|
|
27774
|
+
const p = skipTrivia(text, e + 1, "ts", limit);
|
|
27775
|
+
if (text[p] !== "{") continue;
|
|
27776
|
+
const { lit } = findKeyString(text, p, "ts", limit, ":");
|
|
27777
|
+
if (lit) out.push(toFound(lit));
|
|
27778
|
+
}
|
|
27779
|
+
}
|
|
27780
|
+
}
|
|
27781
|
+
function docstringAfter(text, from, limit) {
|
|
27782
|
+
let i = from;
|
|
27783
|
+
let def = -1;
|
|
27784
|
+
while (i < limit) {
|
|
27785
|
+
const nl = text.indexOf("\n", i);
|
|
27786
|
+
if (nl === -1 || nl + 1 >= limit) return null;
|
|
27787
|
+
let p2 = nl + 1;
|
|
27788
|
+
while (text[p2] === " " || text[p2] === " ") p2++;
|
|
27789
|
+
if (text.startsWith("def ", p2) || text.startsWith("async def ", p2)) {
|
|
27790
|
+
def = p2;
|
|
27791
|
+
break;
|
|
27792
|
+
}
|
|
27793
|
+
if (text.startsWith("class ", p2)) return null;
|
|
27794
|
+
i = nl + 1;
|
|
27795
|
+
}
|
|
27796
|
+
if (def < 0) return null;
|
|
27797
|
+
let depth = 0;
|
|
27798
|
+
let j = def;
|
|
27799
|
+
let colon = -1;
|
|
27800
|
+
while (j < limit) {
|
|
27801
|
+
const c = text[j];
|
|
27802
|
+
if (isQuote(c)) {
|
|
27803
|
+
const k = skipQuoted(text, j, "py", limit);
|
|
27804
|
+
if (k < 0) return null;
|
|
27805
|
+
j = k;
|
|
27806
|
+
continue;
|
|
27807
|
+
}
|
|
27808
|
+
if (c === "#") {
|
|
27809
|
+
j = lineEnd(text, j);
|
|
27810
|
+
continue;
|
|
27811
|
+
}
|
|
27812
|
+
if (c === "(" || c === "[" || c === "{") depth++;
|
|
27813
|
+
else if (c === ")" || c === "]" || c === "}") depth--;
|
|
27814
|
+
else if (c === ":" && depth === 0) {
|
|
27815
|
+
colon = j;
|
|
27816
|
+
break;
|
|
27817
|
+
}
|
|
27818
|
+
j++;
|
|
27819
|
+
}
|
|
27820
|
+
if (colon < 0) return null;
|
|
27821
|
+
const p = skipTrivia(text, colon + 1, "py", limit);
|
|
27822
|
+
return readPyString(text, p, limit);
|
|
27823
|
+
}
|
|
27824
|
+
function extractPy(text, budget, out) {
|
|
27825
|
+
for (const name of ["@mcp.tool", "@server.tool", "@app.tool"]) {
|
|
27826
|
+
for (const at of indexesOf(text, name, budget)) {
|
|
27827
|
+
let b = at - 1;
|
|
27828
|
+
while (b >= 0 && (text[b] === " " || text[b] === " ")) b--;
|
|
27829
|
+
if (b >= 0 && text[b] !== "\n") continue;
|
|
27830
|
+
const nameEnd = at + name.length;
|
|
27831
|
+
if (isIdent(text[nameEnd]) || text[nameEnd] === ".") continue;
|
|
27832
|
+
const limit = lim(text, at);
|
|
27833
|
+
let after = nameEnd;
|
|
27834
|
+
let lit = null;
|
|
27835
|
+
if (text[nameEnd] === "(") {
|
|
27836
|
+
const r = findKeyString(text, nameEnd, "py", limit, "=");
|
|
27837
|
+
lit = r.lit;
|
|
27838
|
+
if (r.after > 0) after = r.after;
|
|
27839
|
+
}
|
|
27840
|
+
lit ??= docstringAfter(text, after, limit);
|
|
27841
|
+
if (lit) out.push(toFound(lit));
|
|
27842
|
+
}
|
|
27843
|
+
}
|
|
27844
|
+
}
|
|
27845
|
+
function extractGo(text, budget, out) {
|
|
27846
|
+
for (const at of indexesOf(text, "WithDescription(", budget)) {
|
|
27847
|
+
if (isIdent(text[at - 1])) continue;
|
|
27848
|
+
const limit = lim(text, at);
|
|
27849
|
+
const p = skipTrivia(text, at + "WithDescription(".length, "go", limit);
|
|
27850
|
+
const l = text[p] === '"' || text[p] === "`" ? readLiteral(text, p, "go", limit) : null;
|
|
27851
|
+
if (l) out.push(toFound(l));
|
|
27852
|
+
}
|
|
27853
|
+
}
|
|
27854
|
+
function extract(text, lang) {
|
|
27855
|
+
const out = [];
|
|
27856
|
+
const budget = { left: MAX_SITES };
|
|
27857
|
+
if (lang === "ts") extractTs(text, budget, out);
|
|
27858
|
+
else if (lang === "py") extractPy(text, budget, out);
|
|
27859
|
+
else extractGo(text, budget, out);
|
|
27860
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27861
|
+
return out.filter((f) => !seen.has(f.offset) && seen.add(f.offset)).sort((a, b) => a.offset - b.offset);
|
|
27862
|
+
}
|
|
27863
|
+
function positionOf(text, offset) {
|
|
27864
|
+
let line = 1;
|
|
27865
|
+
let lastNl = -1;
|
|
27866
|
+
let i = text.indexOf("\n");
|
|
27867
|
+
while (i !== -1 && i < offset) {
|
|
27868
|
+
line++;
|
|
27869
|
+
lastNl = i;
|
|
27870
|
+
i = text.indexOf("\n", i + 1);
|
|
27871
|
+
}
|
|
27872
|
+
return { line, col: offset - lastNl };
|
|
27873
|
+
}
|
|
27874
|
+
function indexOfLineCol(s, line, col) {
|
|
27875
|
+
let start = 0;
|
|
27876
|
+
for (let l = 1; l < line; l++) {
|
|
27877
|
+
const nl = s.indexOf("\n", start);
|
|
27878
|
+
if (nl === -1) return 0;
|
|
27879
|
+
start = nl + 1;
|
|
27880
|
+
}
|
|
27881
|
+
return start + col - 1;
|
|
27882
|
+
}
|
|
27883
|
+
var ORDER_HINT = /^(?:before using this tool|(?:prior to|before) (?:invoking|calling|running|using) (?:this|any|the))\b/i;
|
|
27884
|
+
var SENSITIVE_TARGET = /~\/\.ssh|id_rsa|\.env\b|\bcredentials?\b|\bprivate key\b|\bapi[ _-]?key\b|\btoken\b|\bpassword\b/i;
|
|
27885
|
+
var CONCEALMENT = /\b(?:do not|don't|dont) (?:tell|inform|mention|notify)\b|\bwithout (?:telling|informing|notifying|asking)\b|\b(?:secret|hidden|silently)\b/i;
|
|
27886
|
+
var SEND_VERB = /\b(?:send|upload|forward|exfiltrate|post|include|attach)(?:s|es|ed|ing)?\b/i;
|
|
27887
|
+
var URL_OR_HOST = /https?:\/\/|\bwww\.|\b[a-z0-9-]+(?:\.[a-z0-9-]+)*\.(?:com|net|org|io|dev|xyz|invalid|test|example)\b/i;
|
|
27888
|
+
var SENTENCE_WINDOW = 500;
|
|
27889
|
+
function sentenceAround(whole, from, to) {
|
|
27890
|
+
const isEnd = (i) => {
|
|
27891
|
+
const c = whole.charAt(i);
|
|
27892
|
+
if (c === "\n") return true;
|
|
27893
|
+
return (c === "." || c === "!" || c === "?") && (i + 1 >= whole.length || /\s/.test(whole.charAt(i + 1)));
|
|
27894
|
+
};
|
|
27895
|
+
let start = Math.min(from, whole.length);
|
|
27896
|
+
const lo = Math.max(0, start - SENTENCE_WINDOW);
|
|
27897
|
+
while (start > lo && !isEnd(start - 1)) start--;
|
|
27898
|
+
let end = Math.max(Math.min(to, whole.length), start);
|
|
27899
|
+
const hi = Math.min(whole.length, end + SENTENCE_WINDOW);
|
|
27900
|
+
while (end < hi && !isEnd(end)) end++;
|
|
27901
|
+
return whole.slice(start, end);
|
|
27902
|
+
}
|
|
27903
|
+
function isSuspiciousSentence(sentence) {
|
|
27904
|
+
if (CONCEALMENT.test(sentence) || SENSITIVE_TARGET.test(sentence)) return true;
|
|
27905
|
+
return SEND_VERB.test(sentence) && URL_OR_HOST.test(sentence);
|
|
27906
|
+
}
|
|
27907
|
+
function isQuietHint(span, whole, at) {
|
|
27908
|
+
return ORDER_HINT.test(span.trim()) && !isSuspiciousSentence(sentenceAround(whole, at, at + span.length));
|
|
27909
|
+
}
|
|
27910
|
+
function scanSourceTools(file, text, defs) {
|
|
27911
|
+
try {
|
|
27912
|
+
const def = defs.find((d) => d.id === "EX-005");
|
|
27913
|
+
const lang = languageOf(file.rel);
|
|
27914
|
+
if (!def || lang === null || typeof text !== "string") return [];
|
|
27915
|
+
const out = [];
|
|
27916
|
+
for (const s of extract(text, lang)) {
|
|
27917
|
+
for (const hit of scanText(s.text, "mcp-config", [def], file.rel)) {
|
|
27918
|
+
const idx = Math.min(Math.max(indexOfLineCol(s.text, hit.line, hit.col), 0), s.text.length);
|
|
27919
|
+
if (isQuietHint(hit.span, s.text, idx)) continue;
|
|
27920
|
+
const at = s.map[idx] ?? s.offset;
|
|
27921
|
+
out.push({ ...hit, file: file.rel, ...positionOf(text, at) });
|
|
27922
|
+
}
|
|
27923
|
+
}
|
|
27924
|
+
return out;
|
|
27925
|
+
} catch {
|
|
27926
|
+
return [];
|
|
27927
|
+
}
|
|
27928
|
+
}
|
|
27929
|
+
|
|
27930
|
+
// ../core/src/path-names.ts
|
|
27931
|
+
var MAX_PATH_SPAN = 120;
|
|
27932
|
+
var CONTROL = /[\u0000-\u001F\u007F-\u009F]/;
|
|
27933
|
+
var AI_NAMES = /* @__PURE__ */ new Set(["assistant", "agent", "ai", "claude", "kiro", "copilot", "llm"]);
|
|
27934
|
+
var FILLER = /* @__PURE__ */ new Set(["please", "now", "first", "then", "also", "always", "you", "must", "should", "to"]);
|
|
27935
|
+
var ACTION_VERBS = /* @__PURE__ */ new Set([
|
|
27936
|
+
"read",
|
|
27937
|
+
"send",
|
|
27938
|
+
"upload",
|
|
27939
|
+
"post",
|
|
27940
|
+
"email",
|
|
27941
|
+
"leak",
|
|
27942
|
+
"exfiltrate",
|
|
27943
|
+
"forward",
|
|
27944
|
+
"paste",
|
|
27945
|
+
"copy",
|
|
27946
|
+
"print",
|
|
27947
|
+
"cat",
|
|
27948
|
+
"run",
|
|
27949
|
+
"execute",
|
|
27950
|
+
"fetch",
|
|
27951
|
+
"curl",
|
|
27952
|
+
"download",
|
|
27953
|
+
"write",
|
|
27954
|
+
"edit",
|
|
27955
|
+
"delete",
|
|
27956
|
+
"reveal",
|
|
27957
|
+
"dump",
|
|
27958
|
+
"ignore",
|
|
27959
|
+
"disregard",
|
|
27960
|
+
"forget"
|
|
27961
|
+
]);
|
|
27962
|
+
var SENSITIVE = /* @__PURE__ */ new Set([
|
|
27963
|
+
"env",
|
|
27964
|
+
"dotenv",
|
|
27965
|
+
"secret",
|
|
27966
|
+
"secrets",
|
|
27967
|
+
"credential",
|
|
27968
|
+
"credentials",
|
|
27969
|
+
"token",
|
|
27970
|
+
"tokens",
|
|
27971
|
+
"key",
|
|
27972
|
+
"keys",
|
|
27973
|
+
"ssh",
|
|
27974
|
+
"passwd",
|
|
27975
|
+
"password",
|
|
27976
|
+
"passwords",
|
|
27977
|
+
"apikey"
|
|
27978
|
+
]);
|
|
27979
|
+
var OVERRIDE2 = /^(?:(?:please|now|first|you must|always) )?(?:ignore|disregard|forget|override) (?:all |any |the |your |every )?(?:previous|prior|above|earlier|preceding|system) (?:instructions?|rules|prompts?|context|guidelines|directives)\b/;
|
|
27980
|
+
function nameWords(name) {
|
|
27981
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s._+\-]+/).map((w) => w.toLowerCase()).filter((w) => w.length > 0);
|
|
27982
|
+
}
|
|
27983
|
+
function escapePathSpan(name) {
|
|
27984
|
+
let out = "";
|
|
27985
|
+
let count = 0;
|
|
27986
|
+
for (const ch of name) {
|
|
27987
|
+
const cp = ch.codePointAt(0) ?? 0;
|
|
27988
|
+
const shown = isHiddenCodePoint(cp) || CONTROL.test(ch) || cp === 8232 || cp === 8233 ? `[U+${cp.toString(16).toUpperCase().padStart(4, "0")}]` : ch;
|
|
27989
|
+
if (count >= MAX_PATH_SPAN) return `${out}\u2026`;
|
|
27990
|
+
out += shown;
|
|
27991
|
+
count++;
|
|
27992
|
+
}
|
|
27993
|
+
return out;
|
|
27994
|
+
}
|
|
27995
|
+
function readsAsInstruction(words2) {
|
|
27996
|
+
if (words2.length < 3) return false;
|
|
27997
|
+
if (OVERRIDE2.test(words2.join(" "))) return true;
|
|
27998
|
+
if (words2.length < 4) return false;
|
|
27999
|
+
const verbs = words2.filter((w) => ACTION_VERBS.has(w));
|
|
28000
|
+
const hasSensitive = words2.some((w) => SENSITIVE.has(w));
|
|
28001
|
+
const aiNamed = words2.some((w) => AI_NAMES.has(w));
|
|
28002
|
+
if (aiNamed && verbs.length >= 1 && hasSensitive) return true;
|
|
28003
|
+
const lead = words2.filter((w, i) => !(FILLER.has(w) && words2.slice(0, i).every((p) => FILLER.has(p))));
|
|
28004
|
+
const first = lead[0];
|
|
28005
|
+
return first !== void 0 && ACTION_VERBS.has(first) && verbs.length >= 2 && hasSensitive;
|
|
28006
|
+
}
|
|
28007
|
+
function checkPathSegment(name) {
|
|
28008
|
+
if (name.length === 0) return null;
|
|
28009
|
+
if (CONTROL.test(name) || findHiddenUnicode(name).length > 0) {
|
|
28010
|
+
return { kind: "hidden-chars", span: escapePathSpan(name) };
|
|
28011
|
+
}
|
|
28012
|
+
if (readsAsInstruction(nameWords(name))) return { kind: "instruction", span: escapePathSpan(name) };
|
|
28013
|
+
return null;
|
|
28014
|
+
}
|
|
28015
|
+
|
|
27377
28016
|
// ../core/src/scanner/orchestrator.ts
|
|
27378
28017
|
init_heuristic_engine();
|
|
27379
28018
|
|
|
@@ -28005,6 +28644,34 @@ async function trifectaReport(root, configs, rules, defs) {
|
|
|
28005
28644
|
});
|
|
28006
28645
|
return { map: { configs: maps }, findings, notes: note ? [note] : [] };
|
|
28007
28646
|
}
|
|
28647
|
+
async function* pathNameFindings(root, def) {
|
|
28648
|
+
const seen = /* @__PURE__ */ new Set();
|
|
28649
|
+
try {
|
|
28650
|
+
for await (const p of walkPaths(root)) {
|
|
28651
|
+
const segments = p.rel.split("/");
|
|
28652
|
+
for (let i = 0; i < segments.length; i++) {
|
|
28653
|
+
const prefix = segments.slice(0, i + 1).join("/");
|
|
28654
|
+
if (seen.has(prefix)) continue;
|
|
28655
|
+
seen.add(prefix);
|
|
28656
|
+
const hit = checkPathSegment(segments[i] ?? "");
|
|
28657
|
+
if (!hit) continue;
|
|
28658
|
+
yield {
|
|
28659
|
+
source: "signature",
|
|
28660
|
+
ruleId: def.id,
|
|
28661
|
+
title: def.title,
|
|
28662
|
+
severity: def.severity,
|
|
28663
|
+
file: prefix,
|
|
28664
|
+
line: 1,
|
|
28665
|
+
col: 1,
|
|
28666
|
+
span: hit.span,
|
|
28667
|
+
owasp: def.owasp,
|
|
28668
|
+
fix: def.fix
|
|
28669
|
+
};
|
|
28670
|
+
}
|
|
28671
|
+
}
|
|
28672
|
+
} catch {
|
|
28673
|
+
}
|
|
28674
|
+
}
|
|
28008
28675
|
async function* scanRepo(root, options) {
|
|
28009
28676
|
const defs = await loadDefinitions(options.definitionsDir);
|
|
28010
28677
|
const canaries = loadCanariesFile(canariesPath(root));
|
|
@@ -28055,7 +28722,8 @@ async function* scanRepo(root, options) {
|
|
|
28055
28722
|
const sigs = runSignatures(file, norm, defs);
|
|
28056
28723
|
const heurs = options.bedrockClient ? await runHeuristics(file, norm, sigs, options.bedrockClient) : [];
|
|
28057
28724
|
const traps = canaryFindings(text, file.rel, records, ex022);
|
|
28058
|
-
|
|
28725
|
+
const sourceTools = (file.role === "code" || file.role === "unknown") && languageOf(file.rel) !== null ? scanSourceTools(file, text, defs) : [];
|
|
28726
|
+
let deduped = deduplicate([...sigs, ...heurs, ...traps, ...sourceTools]);
|
|
28059
28727
|
if (checkVault && deduped.length > 0 && file.rel.includes(".exorcist/vault/")) {
|
|
28060
28728
|
const backup = checkVault(file.rel, await readFile3(file.path));
|
|
28061
28729
|
if (backup) deduped = deduped.map((f) => asBackupFinding(f, backup));
|
|
@@ -28083,6 +28751,13 @@ async function* scanRepo(root, options) {
|
|
|
28083
28751
|
yield { type: "error", file: "capabilities.yaml", message: capabilities.error };
|
|
28084
28752
|
}
|
|
28085
28753
|
}
|
|
28754
|
+
const ex029 = defs.find((d) => d.id === "EX-029" && d.enabled !== false && d.match.analysis === "path-names");
|
|
28755
|
+
if (ex029) {
|
|
28756
|
+
for await (const finding of pathNameFindings(root, ex029)) {
|
|
28757
|
+
findingsTotal++;
|
|
28758
|
+
yield { type: "finding", finding };
|
|
28759
|
+
}
|
|
28760
|
+
}
|
|
28086
28761
|
yield {
|
|
28087
28762
|
type: "done",
|
|
28088
28763
|
stats: {
|
|
@@ -28094,12 +28769,6 @@ async function* scanRepo(root, options) {
|
|
|
28094
28769
|
};
|
|
28095
28770
|
}
|
|
28096
28771
|
|
|
28097
|
-
// ../core/src/scanner/scan-text.ts
|
|
28098
|
-
function scanText(text, role, defs, label = "(text)", limitMs = REGEX_TIME_LIMIT_MS) {
|
|
28099
|
-
const file = { path: label, rel: label, role, sizeBytes: text.length };
|
|
28100
|
-
return runSignatures(file, normalize(text, role), defs, limitMs);
|
|
28101
|
-
}
|
|
28102
|
-
|
|
28103
28772
|
// ../core/src/reporters/json-reporter.ts
|
|
28104
28773
|
init_zod();
|
|
28105
28774
|
|
|
@@ -28170,6 +28839,11 @@ var FindingSchema = external_exports.object({
|
|
|
28170
28839
|
owasp: external_exports.array(external_exports.string()),
|
|
28171
28840
|
fix: external_exports.string()
|
|
28172
28841
|
}).passthrough();
|
|
28842
|
+
var SuppressedSchema = external_exports.object({
|
|
28843
|
+
baseline: external_exports.number().int().nonnegative(),
|
|
28844
|
+
inline: external_exports.array(external_exports.object({ ruleId: external_exports.string(), file: external_exports.string(), line: external_exports.number(), reason: external_exports.string() })),
|
|
28845
|
+
rejected: external_exports.array(external_exports.object({ ruleId: external_exports.string(), file: external_exports.string(), line: external_exports.number(), cause: external_exports.string() }))
|
|
28846
|
+
});
|
|
28173
28847
|
var ScanReportSchema = external_exports.object({
|
|
28174
28848
|
version: external_exports.literal("1"),
|
|
28175
28849
|
createdAt: external_exports.string().datetime(),
|
|
@@ -28178,7 +28852,9 @@ var ScanReportSchema = external_exports.object({
|
|
|
28178
28852
|
scanner: external_exports.object({ name: external_exports.string(), version: external_exports.string() }).optional(),
|
|
28179
28853
|
target: external_exports.string().optional(),
|
|
28180
28854
|
stats: ScanStatsSchema,
|
|
28181
|
-
findings: external_exports.array(FindingSchema)
|
|
28855
|
+
findings: external_exports.array(FindingSchema),
|
|
28856
|
+
// Findings hidden by the baseline or inline directives. Optional (m9).
|
|
28857
|
+
suppressed: SuppressedSchema.optional()
|
|
28182
28858
|
});
|
|
28183
28859
|
|
|
28184
28860
|
// ../core/src/plain.ts
|
|
@@ -28275,6 +28951,14 @@ var ENTRIES = {
|
|
|
28275
28951
|
headline: "Together, these tool servers can leak your secrets",
|
|
28276
28952
|
attack: 'Each tool server looks harmless alone. But one agent session that can read private data, read text anyone can write (a web page, an issue, an email) and send data somewhere can be told by that text to copy your secrets out. This is the "lethal trifecta".'
|
|
28277
28953
|
},
|
|
28954
|
+
"EX-028": {
|
|
28955
|
+
headline: "Text you cannot see is giving your AI orders",
|
|
28956
|
+
attack: "A page or file contains text that is styled to be invisible (white, tiny, off-screen or hidden) but a model still reads it. Here it talks to the AI or tells it to write, run, fetch or send something. This is how a web page can try to steer an agent that was only asked to summarise it."
|
|
28957
|
+
},
|
|
28958
|
+
"EX-029": {
|
|
28959
|
+
headline: "A file or folder name is giving your AI orders",
|
|
28960
|
+
attack: 'The name of a file or folder reads like an instruction ("ignore previous instructions...") or hides invisible characters. An agent that lists the project reads every name, so a name alone can steer it.'
|
|
28961
|
+
},
|
|
28278
28962
|
"EX-027": {
|
|
28279
28963
|
headline: "Your AI read untrusted text and private data, and now wants to send something out",
|
|
28280
28964
|
attack: "Earlier in this session your AI read text anyone can write (a web page, an issue, a message) and then private data (a secrets file, a key). Each step looked harmless. Sending data out now is exactly how a prompt injection steals it, so the Shield holds the call until you say yes."
|
|
@@ -28299,6 +28983,11 @@ function plainFor(ruleId, fallbackTitle) {
|
|
|
28299
28983
|
};
|
|
28300
28984
|
}
|
|
28301
28985
|
|
|
28986
|
+
// ../core/src/plural.ts
|
|
28987
|
+
function plural(n, one, many = `${one}s`) {
|
|
28988
|
+
return `${n} ${n === 1 ? one : many}`;
|
|
28989
|
+
}
|
|
28990
|
+
|
|
28302
28991
|
// ../core/src/exorcise.ts
|
|
28303
28992
|
init_walker();
|
|
28304
28993
|
var RULE_CLASSES = {
|
|
@@ -28398,7 +29087,11 @@ var AllowedReadsSchema = external_exports.object({ version: external_exports.lit
|
|
|
28398
29087
|
init_walker();
|
|
28399
29088
|
var MAX_SCAN_BYTES = 10 * 1048576;
|
|
28400
29089
|
|
|
29090
|
+
// ../core/src/gate.ts
|
|
29091
|
+
init_walker();
|
|
29092
|
+
|
|
28401
29093
|
// ../core/src/index.ts
|
|
29094
|
+
init_walker();
|
|
28402
29095
|
init_heuristic_engine();
|
|
28403
29096
|
init_walker();
|
|
28404
29097
|
|
|
@@ -28560,6 +29253,20 @@ init_zod();
|
|
|
28560
29253
|
var NpmLatest = external_exports.object({ version: external_exports.string().max(100) });
|
|
28561
29254
|
var PypiProject = external_exports.object({ info: external_exports.object({ version: external_exports.string().max(100) }) });
|
|
28562
29255
|
|
|
29256
|
+
// ../core/src/baseline.ts
|
|
29257
|
+
init_zod();
|
|
29258
|
+
var BASELINE_VERSION = 1;
|
|
29259
|
+
var BaselineEntrySchema = external_exports.object({
|
|
29260
|
+
ruleId: external_exports.string().min(1),
|
|
29261
|
+
file: external_exports.string().min(1),
|
|
29262
|
+
fingerprint: external_exports.string().regex(/^[0-9a-f]{32}$/),
|
|
29263
|
+
line: external_exports.number().int().min(0)
|
|
29264
|
+
}).strict();
|
|
29265
|
+
var BaselineSchema = external_exports.object({
|
|
29266
|
+
version: external_exports.literal(BASELINE_VERSION),
|
|
29267
|
+
entries: external_exports.array(BaselineEntrySchema)
|
|
29268
|
+
}).strict();
|
|
29269
|
+
|
|
28563
29270
|
// ../shield/src/paraphrase.ts
|
|
28564
29271
|
var W = String.raw`[\s\W_]{0,3}`;
|
|
28565
29272
|
var words = (...ws) => ws.join(`${W}`);
|
|
@@ -28592,7 +29299,7 @@ var SET_ASIDE = any(
|
|
|
28592
29299
|
"(?:do\\W{0,3}not|don'?t|stop|no\\W{0,3}longer)\\W{0,3}(?:follow(?:ing)?|obey(?:ing)?|listen(?:ing)?\\W{0,3}to|heed(?:ing)?|honou?r(?:ing)?)"
|
|
28593
29300
|
);
|
|
28594
29301
|
var PREVIOUS = any("previous", "prior", "earlier", "above", "preceding", "foregoing", "original", "initial", "system", "developer", "your", "all");
|
|
28595
|
-
var
|
|
29302
|
+
var FILLER2 = any("the", "any", "every", "of", "old", "existing", "current", "default", "these", "those", "such", "other");
|
|
28596
29303
|
var ORDERS = any(
|
|
28597
29304
|
"instructions?",
|
|
28598
29305
|
"directions?",
|
|
@@ -28621,8 +29328,8 @@ var BEFORE = any(
|
|
|
28621
29328
|
"the\\W{0,3}(?:conversation|chat)\\W{0,3}so\\W{0,3}far",
|
|
28622
29329
|
"your\\W{0,3}(?:task|job|instructions)"
|
|
28623
29330
|
);
|
|
28624
|
-
var
|
|
28625
|
-
new RegExp(`\\b${SET_ASIDE}${W}(?:${
|
|
29331
|
+
var OVERRIDE3 = [
|
|
29332
|
+
new RegExp(`\\b${SET_ASIDE}${W}(?:${FILLER2}${W}){0,2}${PREVIOUS}${W}(?:${any(FILLER2, PREVIOUS)}${W}){0,2}${ORDERS}\\b`, "i"),
|
|
28626
29333
|
new RegExp(`\\b${SET_ASIDE}${W}${BEFORE}`, "i"),
|
|
28627
29334
|
new RegExp(`\\b${any("new", "updated", "revised", "real", "actual", "true", "secret", "hidden", "important", "priority", "urgent", "override")}${W}${any("instructions?", "task", "objective", "directives?", "mission", "orders?", "goal")}${W}(?:is|are|:|for\\W{0,3}(?:you|the\\W{0,3}(?:assistant|ai|agent|model)))`, "i"),
|
|
28628
29335
|
new RegExp(`\\b${words("your", any("real", "actual", "true", "new", "only"), any("task", "job", "goal", "purpose", "instructions?", "mission"))}${W}(?:is|are|now)\\b`, "i"),
|
|
@@ -28636,7 +29343,7 @@ var CONCEAL = [
|
|
|
28636
29343
|
new RegExp(`\\b${any("silently", "quietly", "covertly", "secretly", "discreetly", "invisibly", "in\\W{0,3}the\\W{0,3}background", "behind\\W{0,3}the\\W{0,3}scenes")}${W}${any("send", "upload", "post", "run", "execute", "call", "forward", "copy", "include", "attach", "email", "transmit")}`, "i"),
|
|
28637
29344
|
new RegExp(`\\b${any("the\\W{0,3}user\\W{0,3}(?:must|should)\\W{0,3}not\\W{0,3}(?:know|see|find\\W{0,3}out)", "hide\\W{0,3}(?:this|it)\\W{0,3}from")}`, "i")
|
|
28638
29345
|
];
|
|
28639
|
-
var
|
|
29346
|
+
var SENSITIVE2 = any(
|
|
28640
29347
|
"\\.env\\b",
|
|
28641
29348
|
"env(?:ironment)?\\W{0,3}(?:file|variables?|vars)",
|
|
28642
29349
|
"credentials?",
|
|
@@ -28668,8 +29375,8 @@ var SENSITIVE = any(
|
|
|
28668
29375
|
"system\\W{0,3}prompt"
|
|
28669
29376
|
);
|
|
28670
29377
|
var SEND = any("send", "post", "upload", "transmit", "forward", "e-?mail", "share", "exfiltrate", "leak", "submit", "paste", "copy", "include", "attach", "append", "embed", "encode", "write", "dump", "print", "reveal", "output", "return", "read");
|
|
28671
|
-
var
|
|
28672
|
-
new RegExp(`\\b${SEND}${W}(?:(?:the|all|any|every|your|my|their|of|full|entire|contents?|values?)${W}){0,4}${
|
|
29378
|
+
var ACTION2 = [
|
|
29379
|
+
new RegExp(`\\b${SEND}${W}(?:(?:the|all|any|every|your|my|their|of|full|entire|contents?|values?)${W}){0,4}${SENSITIVE2}`, "i"),
|
|
28673
29380
|
new RegExp(`\\b${any("run", "execute", "exec", "eval", "invoke", "type", "enter", "paste")}${W}(?:this|the\\W{0,3}following|these)?${W}?(?:command|script|code|line)?s?${W}?[:\`'"]?${W}?${any("curl", "wget", "bash", "sh\\W{0,3}-c", "zsh", "powershell", "iex", "invoke-expression", "rm\\W{0,3}-rf", "chmod", "base64\\W{0,3}-d", "nc\\W", "ncat", "python\\W{0,3}-c", "node\\W{0,3}-e", "eval")}`, "i"),
|
|
28674
29381
|
new RegExp(`\\b${any("curl", "wget")}\\b[^\\n]{0,120}\\|\\s*(?:ba|z)?sh\\b`, "i"),
|
|
28675
29382
|
new RegExp(`\\b${any("call", "use", "invoke", "trigger")}${W}(?:the${W})?[\\w.-]{2,40}${W}tool${W}${any("with", "to\\W{0,3}send", "to\\W{0,3}upload", "to\\W{0,3}delete", "to\\W{0,3}write")}`, "i"),
|
|
@@ -29033,7 +29740,8 @@ function isWrapped(entry) {
|
|
|
29033
29740
|
}
|
|
29034
29741
|
|
|
29035
29742
|
// src/tools.ts
|
|
29036
|
-
import {
|
|
29743
|
+
import { homedir as homedir2 } from "node:os";
|
|
29744
|
+
import { basename as basename5, dirname as dirname3, isAbsolute as isAbsolute4, join as join10, relative as relative3, resolve as resolve5, sep } from "node:path";
|
|
29037
29745
|
var quotesWanted = (ctx2, asked) => asked === true && ctx2.noQuotes !== true;
|
|
29038
29746
|
var RANK = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
29039
29747
|
var HIDDEN2 = /[\u200B-\u200D\uFEFF\u202A-\u202E\u2066-\u2069\u{E0000}-\u{E007F}]/gu;
|
|
@@ -29044,21 +29752,110 @@ function reveal(s) {
|
|
|
29044
29752
|
function findDefinitionsDir2(cwd) {
|
|
29045
29753
|
return findDefinitionsDir({ callerUrl: import.meta.url, cwd });
|
|
29046
29754
|
}
|
|
29047
|
-
function resolveInside(cwd, p, roots = []) {
|
|
29048
|
-
const
|
|
29755
|
+
function resolveInside(cwd, p, roots = [], primary) {
|
|
29756
|
+
const real = (d) => realpathSync(d);
|
|
29757
|
+
const extra = roots.filter((r) => existsSync3(r)).map(real);
|
|
29758
|
+
const first = primary !== void 0 && extra.includes(real(primary)) ? [real(primary)] : [];
|
|
29759
|
+
const bases = [.../* @__PURE__ */ new Set([...first, real(cwd), ...extra])];
|
|
29049
29760
|
const tries = isAbsolute4(p) ? [p] : bases.map((b) => resolve5(b, p));
|
|
29050
29761
|
const found = tries.find((t) => existsSync3(t));
|
|
29051
29762
|
if (!found) return { ok: false, error: `Path not found: ${p}` };
|
|
29052
|
-
const
|
|
29763
|
+
const target = realpathSync(found);
|
|
29053
29764
|
const base = bases.find((b) => {
|
|
29054
|
-
const rel = relative3(b,
|
|
29765
|
+
const rel = relative3(b, target);
|
|
29055
29766
|
return !rel.startsWith("..") && !isAbsolute4(rel);
|
|
29056
29767
|
});
|
|
29057
29768
|
if (!base) {
|
|
29058
29769
|
const where = bases.length > 1 ? `the project folder (${bases[0]}) or the folders your client shared` : `the project folder (${bases[0]})`;
|
|
29059
|
-
return { ok: false, error: `"${p}" is outside ${where}. Only paths inside ${bases.length > 1 ? "them" : "it"} can be used.` };
|
|
29770
|
+
return { ok: false, outside: true, error: `"${p}" is outside ${where}. Only paths inside ${bases.length > 1 ? "them" : "it"} can be used.` };
|
|
29771
|
+
}
|
|
29772
|
+
return { ok: true, path: target, base };
|
|
29773
|
+
}
|
|
29774
|
+
var PROJECT_MARKERS = [
|
|
29775
|
+
".git",
|
|
29776
|
+
".kiro",
|
|
29777
|
+
".claude",
|
|
29778
|
+
".cursor",
|
|
29779
|
+
".vscode",
|
|
29780
|
+
".mcp.json",
|
|
29781
|
+
"mcp.json",
|
|
29782
|
+
"package.json",
|
|
29783
|
+
"pyproject.toml",
|
|
29784
|
+
"requirements.txt",
|
|
29785
|
+
"Cargo.toml",
|
|
29786
|
+
"go.mod",
|
|
29787
|
+
"pom.xml",
|
|
29788
|
+
"build.gradle",
|
|
29789
|
+
"Gemfile",
|
|
29790
|
+
"composer.json",
|
|
29791
|
+
"AGENTS.md",
|
|
29792
|
+
"CLAUDE.md",
|
|
29793
|
+
"README.md",
|
|
29794
|
+
"README"
|
|
29795
|
+
];
|
|
29796
|
+
function looksLikeProject(dir) {
|
|
29797
|
+
const has = (n) => existsSync3(join10(dir, n));
|
|
29798
|
+
if (has("plugin.json") || has("POWER.md")) return false;
|
|
29799
|
+
return PROJECT_MARKERS.some(has);
|
|
29800
|
+
}
|
|
29801
|
+
var SENSITIVE_IN_HOME = [".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".password-store", join10("Library", "Keychains")];
|
|
29802
|
+
var SENSITIVE_ABSOLUTE = ["/etc", "/private/etc", "/System", "/var/root", "/root"];
|
|
29803
|
+
var isWithin = (base, p) => {
|
|
29804
|
+
const rel = relative3(base, p);
|
|
29805
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
|
|
29806
|
+
};
|
|
29807
|
+
function sensitiveReason(real, home = homedir2()) {
|
|
29808
|
+
const realHome = existsSync3(home) ? realpathSync(home) : home;
|
|
29809
|
+
if (dirname3(real) === real) return "it is the filesystem root";
|
|
29810
|
+
if (isWithin(real, realHome)) return real === realHome ? "it is the home folder" : "it contains the home folder";
|
|
29811
|
+
for (const n of SENSITIVE_IN_HOME) {
|
|
29812
|
+
const s = join10(realHome, n);
|
|
29813
|
+
if (isWithin(s, real) || isWithin(real, s)) return `it holds credentials or settings (${n.split(sep)[0]})`;
|
|
29814
|
+
}
|
|
29815
|
+
for (const s of SENSITIVE_ABSOLUTE) if (isWithin(s, real)) return "it is a system folder";
|
|
29816
|
+
return null;
|
|
29817
|
+
}
|
|
29818
|
+
var printable2 = (s) => s.replace(/[\u0000-\u001F\u007F-\u009F\u200B-\u200F\u2028\u2029\u202A-\u202E\u2066-\u2069\uFEFF\u{E0000}-\u{E007F}]/gu, (c) => `[U+${(c.codePointAt(0) ?? 0).toString(16).toUpperCase().padStart(4, "0")}]`);
|
|
29819
|
+
function approvalMessage(folder) {
|
|
29820
|
+
const shown = printable2(folder);
|
|
29821
|
+
const where = shown.length > 300 ? `${shown.slice(0, 300)}...` : shown;
|
|
29822
|
+
return `Allow Exorcist 98 to read the folder ${where} for this session? It can scan the files in it, and disable MCP servers in its config files only if you ask. The permission ends when the server stops.`;
|
|
29823
|
+
}
|
|
29824
|
+
var FIXES = "Either set EXORCIST_ROOTS to the absolute path of the project folder in the env of the exorcist MCP server, or add the exorcist server to the workspace .kiro/settings/mcp.json, where Kiro starts it in the project folder.";
|
|
29825
|
+
function noProjectError(ctx2, p, inside2) {
|
|
29826
|
+
if (inside2.outside || isAbsolute4(p) || (ctx2.roots?.length ?? 0) > 0 || looksLikeProject(ctx2.cwd)) return null;
|
|
29827
|
+
const how = ctx2.ask ? "Call the tool again with the absolute path of the project folder; the person will be asked to allow it for this session. Other fixes: set EXORCIST_ROOTS to that folder in the env of the exorcist MCP server, or add the exorcist server to the workspace .kiro/settings/mcp.json, where Kiro starts it in the project folder." : FIXES;
|
|
29828
|
+
return `No project folder is known, so "${p}" was not scanned. This server was started in ${ctx2.cwd}, which is not a project, and the client did not share a workspace folder (MCP roots). Nothing was checked. ${how} Do not report this as a clean scan.`;
|
|
29829
|
+
}
|
|
29830
|
+
async function resolveAllowed(ctx2, p) {
|
|
29831
|
+
const first = resolveInside(ctx2.cwd, p, ctx2.roots, ctx2.base);
|
|
29832
|
+
if (first.ok || !first.outside || !isAbsolute4(p)) return first;
|
|
29833
|
+
const noRoots = (ctx2.roots?.length ?? 0) === 0;
|
|
29834
|
+
if (!ctx2.ask) {
|
|
29835
|
+
return noRoots && !looksLikeProject(ctx2.cwd) ? { ...first, error: `${first.error} No project folder is known. ${FIXES}` } : first;
|
|
29836
|
+
}
|
|
29837
|
+
let folder;
|
|
29838
|
+
try {
|
|
29839
|
+
const real = realpathSync(p);
|
|
29840
|
+
folder = statSync4(real).isDirectory() ? real : dirname3(real);
|
|
29841
|
+
} catch {
|
|
29842
|
+
return first;
|
|
29843
|
+
}
|
|
29844
|
+
const refused = sensitiveReason(folder, ctx2.home);
|
|
29845
|
+
if (refused) return { ok: false, outside: true, error: `${printable2(folder)} cannot be allowed: ${refused}.` };
|
|
29846
|
+
let yes = false;
|
|
29847
|
+
try {
|
|
29848
|
+
yes = await ctx2.ask(folder) === true;
|
|
29849
|
+
} catch {
|
|
29850
|
+
yes = false;
|
|
29060
29851
|
}
|
|
29061
|
-
|
|
29852
|
+
if (!yes) {
|
|
29853
|
+
return { ok: false, outside: true, error: `The person did not allow Exorcist 98 to read ${printable2(folder)}, so nothing was read. Do not ask again unless the user requests it.` };
|
|
29854
|
+
}
|
|
29855
|
+
ctx2.approved = [...ctx2.approved ?? [], folder];
|
|
29856
|
+
ctx2.roots = [...ctx2.roots ?? [], folder];
|
|
29857
|
+
ctx2.base ??= folder;
|
|
29858
|
+
return resolveInside(ctx2.cwd, p, ctx2.roots, ctx2.base);
|
|
29062
29859
|
}
|
|
29063
29860
|
function usableRoots(entries, home) {
|
|
29064
29861
|
const out = [];
|
|
@@ -29111,12 +29908,15 @@ function describe(findings, limit, quotes) {
|
|
|
29111
29908
|
return lines.join("\n");
|
|
29112
29909
|
}
|
|
29113
29910
|
function summary(findings, files) {
|
|
29114
|
-
if (findings.length === 0) return `No threats found
|
|
29911
|
+
if (findings.length === 0) return `No threats found. Scanned ${plural(files, "file")}.`;
|
|
29115
29912
|
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(", ");
|
|
29116
|
-
|
|
29913
|
+
const withFindings = new Set(findings.map((f) => f.file)).size;
|
|
29914
|
+
return `${plural(findings.length, "threat")} in ${plural(withFindings, "file")} (${counts}). Scanned ${plural(files, "file")}.`;
|
|
29117
29915
|
}
|
|
29118
29916
|
async function scanRepoTool(ctx2, a) {
|
|
29119
|
-
const inside2 =
|
|
29917
|
+
const inside2 = await resolveAllowed(ctx2, a.path);
|
|
29918
|
+
const none = noProjectError(ctx2, a.path, inside2);
|
|
29919
|
+
if (none) return err(none);
|
|
29120
29920
|
if (!inside2.ok) return err(inside2.error);
|
|
29121
29921
|
const defs = await loadDefs(ctx2);
|
|
29122
29922
|
if (!defs.ok) return err(defs.error);
|
|
@@ -29134,7 +29934,9 @@ async function scanRepoTool(ctx2, a) {
|
|
|
29134
29934
|
return { text: [summary(findings, files), quotes ? UNTRUSTED : "", describe(findings, limit, quotes)].filter(Boolean).join("\n") };
|
|
29135
29935
|
}
|
|
29136
29936
|
async function scanMcpConfigTool(ctx2, a) {
|
|
29137
|
-
const inside2 =
|
|
29937
|
+
const inside2 = await resolveAllowed(ctx2, a.path);
|
|
29938
|
+
const none = noProjectError(ctx2, a.path, inside2);
|
|
29939
|
+
if (none) return err(none);
|
|
29138
29940
|
if (!inside2.ok) return err(inside2.error);
|
|
29139
29941
|
if (!statSync4(inside2.path).isFile()) return err(`${a.path} is a folder. Give the path of an MCP config file.`);
|
|
29140
29942
|
const defs = await loadDefs(ctx2);
|
|
@@ -29177,13 +29979,15 @@ async function explainFindingTool(ctx2, a) {
|
|
|
29177
29979
|
return { text: lines.join("\n") };
|
|
29178
29980
|
}
|
|
29179
29981
|
async function quarantineTool(ctx2, a) {
|
|
29180
|
-
const inside2 =
|
|
29982
|
+
const inside2 = await resolveAllowed(ctx2, a.config);
|
|
29983
|
+
const none = noProjectError(ctx2, a.config, inside2);
|
|
29984
|
+
if (none) return err(none);
|
|
29181
29985
|
if (!inside2.ok) return err(inside2.error);
|
|
29182
29986
|
const r = quarantineServer({
|
|
29183
29987
|
configPath: inside2.path,
|
|
29184
29988
|
serverName: a.server,
|
|
29185
29989
|
reason: a.reason?.slice(0, 200) ?? "quarantined from an AI agent request",
|
|
29186
|
-
vaultDir: join10(
|
|
29990
|
+
vaultDir: join10(inside2.base, ".exorcist", "vault")
|
|
29187
29991
|
});
|
|
29188
29992
|
if (!r.ok) return err(r.error);
|
|
29189
29993
|
return {
|
|
@@ -29193,17 +29997,42 @@ Tell the user. They can undo this with: exorcist vault restore ${r.value.id}`
|
|
|
29193
29997
|
}
|
|
29194
29998
|
|
|
29195
29999
|
// src/index.ts
|
|
29196
|
-
var VERSION = "0.
|
|
30000
|
+
var VERSION = "0.2.0";
|
|
29197
30001
|
var ctx = {
|
|
29198
30002
|
cwd: process.cwd(),
|
|
30003
|
+
approved: [],
|
|
29199
30004
|
definitionsDir: findDefinitionsDir2(process.cwd()) ?? "",
|
|
29200
30005
|
noQuotes: process.env["EXORCIST_MCP_NO_QUOTES"] === "1"
|
|
29201
30006
|
};
|
|
29202
30007
|
var reply = (r) => ({ content: [{ type: "text", text: r.text }], ...r.isError ? { isError: true } : {} });
|
|
29203
30008
|
var server = new McpServer({ name: "exorcist", version: VERSION });
|
|
30009
|
+
var canAsk = () => {
|
|
30010
|
+
const e = server.server.getClientCapabilities()?.elicitation;
|
|
30011
|
+
return e !== void 0 && (e.form !== void 0 || e.url === void 0);
|
|
30012
|
+
};
|
|
30013
|
+
async function askPerson(folder) {
|
|
30014
|
+
try {
|
|
30015
|
+
const r = await server.server.elicitInput(
|
|
30016
|
+
{
|
|
30017
|
+
mode: "form",
|
|
30018
|
+
message: approvalMessage(folder),
|
|
30019
|
+
requestedSchema: {
|
|
30020
|
+
type: "object",
|
|
30021
|
+
properties: { allow: { type: "boolean", title: "Allow for this session", description: "Yes lets Exorcist 98 read this folder until the server stops. No reads nothing.", default: false } },
|
|
30022
|
+
required: ["allow"]
|
|
30023
|
+
}
|
|
30024
|
+
},
|
|
30025
|
+
{ timeout: 12e4 }
|
|
30026
|
+
);
|
|
30027
|
+
return r.action === "accept" && r.content?.["allow"] === true;
|
|
30028
|
+
} catch {
|
|
30029
|
+
return false;
|
|
30030
|
+
}
|
|
30031
|
+
}
|
|
29204
30032
|
var clientRoots = null;
|
|
29205
30033
|
async function refreshRoots() {
|
|
29206
30034
|
const fromEnv = (process.env["EXORCIST_ROOTS"] ?? "").split(delimiter);
|
|
30035
|
+
const home = homedir3();
|
|
29207
30036
|
let fromClient = [];
|
|
29208
30037
|
if (server.server.getClientCapabilities()?.roots) {
|
|
29209
30038
|
if (clientRoots === null) {
|
|
@@ -29215,13 +30044,17 @@ async function refreshRoots() {
|
|
|
29215
30044
|
}
|
|
29216
30045
|
fromClient = clientRoots;
|
|
29217
30046
|
}
|
|
29218
|
-
ctx.
|
|
30047
|
+
const approved = ctx.approved ?? [];
|
|
30048
|
+
ctx.base = usableRoots(fromClient, home)[0] ?? usableRoots(fromEnv, home)[0] ?? approved[0];
|
|
30049
|
+
ctx.roots = usableRoots([...fromEnv, ...fromClient, ...approved], home);
|
|
29219
30050
|
}
|
|
29220
30051
|
server.server.setNotificationHandler(RootsListChangedNotificationSchema, async () => {
|
|
29221
30052
|
clientRoots = null;
|
|
29222
30053
|
});
|
|
29223
30054
|
var withRoots = (fn) => async (a) => {
|
|
29224
30055
|
await refreshRoots();
|
|
30056
|
+
if (canAsk()) ctx.ask = askPerson;
|
|
30057
|
+
else delete ctx.ask;
|
|
29225
30058
|
return fn(ctx, a);
|
|
29226
30059
|
};
|
|
29227
30060
|
server.registerTool(
|
|
@@ -29230,7 +30063,7 @@ server.registerTool(
|
|
|
29230
30063
|
title: "Scan a folder for attacks on AI agents",
|
|
29231
30064
|
description: "Scan a folder or file inside the project for hidden instructions, poisoned tool descriptions, dangerous hooks and leaked secrets. Returns plain-language findings with file and line. Quoted text is left out unless includeQuotes is true.",
|
|
29232
30065
|
inputSchema: {
|
|
29233
|
-
path: external_exports.string().min(1).describe(
|
|
30066
|
+
path: external_exports.string().min(1).describe('Folder or file to scan, relative to the project folder (use "." for the whole project)'),
|
|
29234
30067
|
maxFindings: external_exports.number().int().min(1).max(100).optional().describe("How many findings to list (default 25)"),
|
|
29235
30068
|
includeQuotes: external_exports.boolean().optional().describe("Include the matched text, revealed and marked untrusted")
|
|
29236
30069
|
},
|