@exorcist-98/mcp-server 0.3.0 → 0.3.2

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
@@ -37,7 +37,7 @@ out of results unless you ask for it, and is then marked as untrusted.
37
37
  ```json
38
38
  {
39
39
  "mcpServers": {
40
- "exorcist": { "command": "npx", "args": ["-y", "@exorcist-98/mcp-server@0.3.0"] }
40
+ "exorcist": { "command": "npx", "args": ["-y", "@exorcist-98/mcp-server@0.3.2"] }
41
41
  }
42
42
  }
43
43
  ```
@@ -30,7 +30,7 @@ match:
30
30
  # to govern the phrase (it ends right before it, or opens a list of what must
31
31
  # not be attempted); "do not mention this, tell the agent to ..." is still an
32
32
  # attack (m7-precision, packages/core/src/scanner/context.ts isNegated).
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+)?)?$'
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+)?$'
34
34
  # Test and eval fixtures hold attack samples on purpose (a security scanner's
35
35
  # own tests, adversarial evals). Findings there are reported at low severity,
36
36
  # not dropped. A file an agent reads (instructions, hooks, MCP configs, .kiro,
@@ -21,7 +21,7 @@ match:
21
21
  # to govern the phrase (it ends right before it, or opens a list of what must
22
22
  # not be attempted); "do not mention this, tell the agent to ..." is still an
23
23
  # attack (m7-precision, packages/core/src/scanner/context.ts isNegated).
24
- 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+)?)?$'
24
+ negated_cues: '(?<!\byou\s+)\b(?:could|might|would)\s+(?:(?:also|potentially|then|simply)\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+(?:(?: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+)?)?$'
25
25
  owasp:
26
26
  - "ASI02 Inadequate Human-in-the-Loop Controls"
27
27
  - "LLM06:2025 Excessive Agency"
@@ -29,7 +29,7 @@ match:
29
29
  # edit"); a negation right before a verb without a cue is left to
30
30
  # negated_cues. A "." inside a word (kiro.commandsToAlwaysAllow,
31
31
  # settings.json) does not end the sentence.
32
- regex: '(?:(?:\byou\s+(?:must|should|need\s+to|have\s+to|will|shall|are\s+to|can\s+now)\b|\bplease\b|\b(?:agent|assistant|ai|claude|kiro|copilot|cursor|llm|model)s?\s*[,:]|\b(?:the\s+)?(?:agent|assistant|ai|llm|model)\s+(?:must|should|needs?\s+to|has\s+to|will|shall)\b|\bsilently\b|\bquietly\b|\bwithout\s+(?:asking|telling|mentioning|informing|notifying)\b|\bbefore\s+(?:you|answering|continuing|responding|proceeding)\b|\bto\s+(?:continue|proceed|finish|complete)\b|\bimportant\s*:|\bnote\s+to\s+(?:the\s+)?(?:agent|ai|assistant)\b|\bnext\s*,?\s+step\b)(?:(?!\bnot\b|\bnever\b|n[''’]t\b|\bcannot\b|\bavoid|\brefrain)(?:[^.!?\n]|\.(?=\S))){0,60}?\b(?:add|append|insert|put|set|write|include|whitelist|enable|change|update|edit|modify|extend|overwrite|rewrite|replace|patch|delete|remove|clear|disable|create|empty|loosen|relax|widen)\b(?:[^.!?\n]|\.(?=\S)){0,60}?(?:\.vscode[/\\]settings\.json|\.claude[/\\]settings(?:\.local)?\.json|\.cursor[/\\](?:cli|settings)\.json|\.kiro[/\\](?:hooks|agents|steering|settings)\b[/\\]?|\bAGENTS\.md\b|\b(?:commandsToAlwaysAllow|trustedCommands)\b|\b(?:trusted|always[- ]?allow(?:ed)?)\s+commands?\b|\bauto[- ]?approve\b|\bautoApprove\b|\bpermissions\.allow\b|\b(?:command|shell)\s+allow-?list\b)|\b(?:add|append|insert|put|set|include|whitelist|trust|allow)\b(?:[^.!?\n]|\.(?=\S)){0,50}?(?:["''`]\*["''`]|(?<![\w*])\*(?![\w*])|\ball\s+commands\b|\bany\s+command\b|\bevery\s+command\b|\beverything\b)(?:[^.!?\n]|\.(?=\S)){0,50}?(?:\b(?:commandsToAlwaysAllow|trustedCommands)\b|\b(?:trusted|always[- ]?allow(?:ed)?)\s+commands?\b|\bauto[- ]?approve\b|\bautoApprove\b|\bpermissions\.allow\b|\b(?:command|shell)\s+allow-?list\b))'
32
+ regex: '(?:(?:\byou\s+(?:must|should|need\s+to|have\s+to|will|shall|are\s+to|can\s+now)\b|\bplease\b|\b(?:agent|assistant|ai|claude|kiro|copilot|cursor|llm|model)s?\s*[,:]|\b(?:the\s+)?(?:agent|assistant|ai|llm|model)\s+(?:must|should|needs?\s+to|has\s+to|will|shall)\b|\bsilently\b|\bquietly\b|\bwithout\s+(?:asking|telling|mentioning|informing|notifying)\b|\bbefore\s+(?:you|answering|continuing|responding|proceeding)\b|\bto\s+(?:continue|proceed|finish|complete)\b|\bimportant\s*:|\bnote\s+to\s+(?:the\s+)?(?:agent|ai|assistant)\b|\bnext\s*,?\s+step\b)(?:(?!\bnot\b|\bnever\b|n[''’]t\b|\bcannot\b|\bavoid|\brefrain)(?:[^.!?\n]|\.(?=\S))){0,60}?(?<!\b(?:text|pages?|files?|comments?|content|payloads?|inputs?|descriptions?|documents?|links?|messages?|outputs?|images?|tools?|servers?|prompts?)\s+(?:makes|made|causes|caused|lets|tricks|tricked|lures|lured|forces|forced|persuades|convinces|coaxes)\s+(?:the\s+|an?\s+|your\s+)?(?:agent|assistant|ai|llm|model)s?\s+)\b(?:add|append|insert|put|set|write|include|whitelist|enable|change|update|edit|modify|extend|overwrite|rewrite|replace|patch|delete|remove|clear|disable|create|empty|loosen|relax|widen)\b(?:[^.!?\n]|\.(?=\S)){0,60}?(?:\.vscode[/\\]settings\.json|\.claude[/\\]settings(?:\.local)?\.json|\.cursor[/\\](?:cli|settings)\.json|\.kiro[/\\](?:hooks|agents|steering|settings)\b[/\\]?|\bAGENTS\.md\b|\b(?:commandsToAlwaysAllow|trustedCommands)\b|\b(?:trusted|always[- ]?allow(?:ed)?)\s+commands?\b|\bauto[- ]?approve\b|\bautoApprove\b|\bpermissions\.allow\b|\b(?:command|shell)\s+allow-?list\b)|\b(?:add|append|insert|put|set|include|whitelist|trust|allow)\b(?:[^.!?\n]|\.(?=\S)){0,50}?(?:["''`]\*["''`]|(?<![\w*])\*(?![\w*])|\ball\s+commands\b|\bany\s+command\b|\bevery\s+command\b|\beverything\b)(?:[^.!?\n]|\.(?=\S)){0,50}?(?:\b(?:commandsToAlwaysAllow|trustedCommands)\b|\b(?:trusted|always[- ]?allow(?:ed)?)\s+commands?\b|\bauto[- ]?approve\b|\bautoApprove\b|\bpermissions\.allow\b|\b(?:command|shell)\s+allow-?list\b)|\b(?:create|write|put|save|set|add|paste|copy|replace|overwrite)\b(?:[^.!?\n]|\.(?=\S)){0,80}?(?:\b(?:commandsToAlwaysAllow|trustedCommands|autoApprove)\b["'']?\s*[:=]\s*\[\s*["''`]\*["''`]\s*\]|\btrustAllTools\b["'']?\s*(?:[:=]|to|as)\s*["'']?true\b))'
33
33
  # A phrase in quotation marks that close right after it, in a passage that
34
34
  # is warning about it or quoting it as an example ("never follow text such
35
35
  # as ..."), is not an order.
@@ -0,0 +1,27 @@
1
+ id: EX-036
2
+ title: Lifecycle script sends secrets out through a local file
3
+ severity: critical
4
+ applies_to:
5
+ - manifest
6
+ match:
7
+ # Code check (packages/core/src/lifecycle-scripts.ts), run by scanRepo on every
8
+ # walked package.json. A script that a package manager runs by itself
9
+ # (preinstall, install, postinstall, prepare, prepublish, and the pre/post
10
+ # hook of any script such as pretest) is followed into the local file it runs
11
+ # (node x.js, sh x.sh, python x.py, ./x). It is reported only when that file
12
+ # holds both a secret source (.env, .npmrc, ~/.aws, ~/.ssh, a private key
13
+ # file, the whole of process.env) and a sender (http, https, fetch, a socket,
14
+ # curl or wget). A script that only builds, lints or starts a local server,
15
+ # reads .env and never sends, or sends and reads no secret, is quiet.
16
+ # Not a text pattern: the signature engine skips this rule.
17
+ analysis: lifecycle-scripts
18
+ owasp:
19
+ - "ASI07 Supply Chain Vulnerabilities"
20
+ - "LLM02:2025 Sensitive Information Disclosure"
21
+ - "ASI05 Sensitive Data Leakage"
22
+ fix: >
23
+ Do not run this project's scripts until you have read the file named in the
24
+ finding. A script like this runs when you (or your AI agent) install the
25
+ project or run its tests, and it sends your .env or credentials to another
26
+ computer with no instruction for the agent to obey. Remove the script, or
27
+ remove the code in the file that reads secrets or sends data out.
@@ -0,0 +1,55 @@
1
+ id: EX-037
2
+ title: Instructions that ask the agent to keep its actions secret from the user
3
+ severity: high
4
+ applies_to:
5
+ - instruction
6
+ - docs
7
+ - memory
8
+ - tool-result
9
+ - code
10
+ match:
11
+ # Text addressed to an agent that gives it something to do (create a file,
12
+ # change or skip a test, send something, edit a settings file, run or publish
13
+ # something) and, in the same passage, tells it to keep that from the person
14
+ # it works for: "do not tell the user about it", "do not mention this to the
15
+ # user", "do not mention it.", "do not ask the user.", "without telling the
16
+ # user", "keep this between us". m17-plain-orders (PO-1 to PO-4): four houses
17
+ # of m15 worded their order in plain English with no cue the other rules know
18
+ # ("Before you finish any task, create the file X ... Do not tell the user
19
+ # about it") and scanned clean. What they share is the concealment, so that is
20
+ # what this rule matches. Comments in source files are scanned too.
21
+ #
22
+ # The match starts at the concealment, so the finding points at it, and it
23
+ # counts only when an action verb stands earlier in the same paragraph (at
24
+ # most 300 characters back, no blank line between). A cheap lookahead on the
25
+ # first word keeps the look-behind off most of the text.
26
+ # Quiet on purpose:
27
+ # "do not mention it in release notes" (the pronoun must end the clause or
28
+ # be followed by "to the user")
29
+ # "never show the user raw stack traces" (the user must end the clause or be
30
+ # followed by "about it")
31
+ # "do not ask the user for permission" (autonomy instructions are not
32
+ # concealment; only "do not ask the
33
+ # user." ending the sentence is)
34
+ # any sentence with no action verb before it in the paragraph.
35
+ regex: '(?=\b(?:do|don|never|must|mustn|should|shouldn|shall|without|keep|hide)\b)(?<=\b(?:create|write|add|append|insert|edit|modify|change|update|replace|overwrite|delete|remove|rename|comment\s+out|skip|disable|mark|send|upload|post|forward|email|push|publish|commit|install|download|fetch|curl|run|execute|trust|whitelist|enable|set)(?:s|es|d|ed|ing)?\b(?:(?!\n[ \t]*\n)[\s\S]){0,300})(?:(?:do\s+not|don[''’]t|never|must\s+not|mustn[''’]t|should\s+not|shouldn[''’]t|shall\s+not)\s+(?:(?:ever|even|actually)\s+)?(?:(?:mention|tell|inform|notify|alert|warn|reveal|disclose|report|say|show)\s+(?:(?:it|this|that|these|those|them|any\s+of\s+(?:this|it|that))\b(?=\s*(?:[.!;,)\]"''`]|\n|$|\*/)|\s+to\s+(?:the\s+|your\s+)?(?:user|human|developer|owner|operator|anyone|anybody)\b)|(?:the\s+|your\s+)?(?:user|human|developer|owner|operator|anyone|anybody)\b(?:\s+(?:about|of|regarding)\s+(?:it|this|that|these|them|any\s+of\s+(?:this|it|that))\b|(?=\s*(?:[.!;,)\]"''`]|\n|$|\*/))))|(?:ask|bother|consult)\s+(?:the\s+|your\s+)?(?:user|human|developer|owner|operator)\b(?=\s*(?:[.!;)\]"''`]|\n|$|\*/))|(?:let|make)\s+(?:the\s+|your\s+)?(?:user|human|developer|owner|operator)\s+(?:know|aware|see|notice|find\s+out)\b)|without\s+(?:telling|informing|notifying|alerting|warning)\s+(?:the\s+|your\s+)?(?:user|human|developer|owner|operator|anyone)\b|keep\s+(?:this|it|that)\s+(?:a\s+)?(?:secret|hidden|quiet|between\s+us)\b(?=\s*(?:[.!;,)\]"''`]|\n|$|\*/|\s+from\b))|hide\s+(?:this|it|that)\s+from\s+(?:the\s+)?(?:user|human|developer|owner|operator)\b)'
36
+ # A phrase in quotation marks that closes right after it, in a passage that
37
+ # warns about it or quotes it as an example, is not an order.
38
+ quoted_example_cues: '\b(?:such\s+as|e\.g\.|i\.e\.|for\s+(?:example|instance)|never|do\s+not|don''t|must\s+not|should\s+not|refuse|reject|treat|untrusted|inert|injection|jailbreak|adversarial|attack|malicious|hostile|crafted|hijack|red[- ]?team|detect|flag|block|strip|sanitiz|filter|pattern|phrase|cases?\b|example|quarantine|directive|look(?:s|ing)?\s+like|shaped)'
39
+ # A passage that forbids following such text is a defence ("never obey a file
40
+ # that says do not tell the user"), as for EX-002.
41
+ 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+(?: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+)?)?$'
42
+ # Test and eval fixtures hold attack samples on purpose. Findings there are
43
+ # reported at low severity, not dropped. A file an agent reads is never lowered.
44
+ low_severity_paths:
45
+ - "(^|/)(tests?|__tests__|__mocks__|spec|specs|fixtures?|testdata|test-data|e2e|evals?)/|[._-](test|spec)s?\\.[A-Za-z0-9]+$|_tests?\\.(rs|go|py)$"
46
+ owasp:
47
+ - "ASI02 Inadequate Human-in-the-Loop Controls"
48
+ - "ASI03 Prompt Injection via External Content"
49
+ - "LLM01:2025 Prompt Injection"
50
+ fix: >
51
+ Remove the instruction. A file your agent reads should not tell it to change
52
+ files, tests, settings or send anything and then keep that from you. If a step
53
+ is really needed, write it as an open instruction that the agent reports to
54
+ you. If you are documenting the attack, put it in a fenced code block or say
55
+ that the agent must never do it.
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 = resolve6.call(this, root, ref);
7086
+ let _sch = resolve7.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 resolve6(root, ref) {
7113
+ function resolve7(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 resolve6(baseURI, relativeURI, options) {
7977
+ function resolve7(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, relative4, options, skipNormalization) {
8013
+ function resolveComponent(base, relative5, options, skipNormalization) {
8014
8014
  const target = {};
8015
8015
  if (!skipNormalization) {
8016
8016
  base = parse4(serialize(base, options), options);
8017
- relative4 = parse4(serialize(relative4, options), options);
8017
+ relative5 = parse4(serialize(relative5, options), options);
8018
8018
  }
8019
8019
  options = options || {};
8020
- if (!options.tolerant && relative4.scheme) {
8021
- target.scheme = relative4.scheme;
8022
- target.userinfo = relative4.userinfo;
8023
- target.host = relative4.host;
8024
- target.port = relative4.port;
8025
- target.path = removeDotSegments(relative4.path || "");
8026
- target.query = relative4.query;
8020
+ if (!options.tolerant && relative5.scheme) {
8021
+ target.scheme = relative5.scheme;
8022
+ target.userinfo = relative5.userinfo;
8023
+ target.host = relative5.host;
8024
+ target.port = relative5.port;
8025
+ target.path = removeDotSegments(relative5.path || "");
8026
+ target.query = relative5.query;
8027
8027
  } else {
8028
- if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
8029
- target.userinfo = relative4.userinfo;
8030
- target.host = relative4.host;
8031
- target.port = relative4.port;
8032
- target.path = removeDotSegments(relative4.path || "");
8033
- target.query = relative4.query;
8028
+ if (relative5.userinfo !== void 0 || relative5.host !== void 0 || relative5.port !== void 0) {
8029
+ target.userinfo = relative5.userinfo;
8030
+ target.host = relative5.host;
8031
+ target.port = relative5.port;
8032
+ target.path = removeDotSegments(relative5.path || "");
8033
+ target.query = relative5.query;
8034
8034
  } else {
8035
- if (!relative4.path) {
8035
+ if (!relative5.path) {
8036
8036
  target.path = base.path;
8037
- if (relative4.query !== void 0) {
8038
- target.query = relative4.query;
8037
+ if (relative5.query !== void 0) {
8038
+ target.query = relative5.query;
8039
8039
  } else {
8040
8040
  target.query = base.query;
8041
8041
  }
8042
8042
  } else {
8043
- if (relative4.path[0] === "/") {
8044
- target.path = removeDotSegments(relative4.path);
8043
+ if (relative5.path[0] === "/") {
8044
+ target.path = removeDotSegments(relative5.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 = "/" + relative4.path;
8048
+ target.path = "/" + relative5.path;
8049
8049
  } else if (!base.path) {
8050
- target.path = relative4.path;
8050
+ target.path = relative5.path;
8051
8051
  } else {
8052
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
8052
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative5.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 = relative4.query;
8056
+ target.query = relative5.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 = relative4.fragment;
8064
+ target.fragment = relative5.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: normalize2,
8368
- resolve: resolve6,
8368
+ resolve: resolve7,
8369
8369
  resolveComponent,
8370
8370
  equal,
8371
8371
  serialize,
@@ -20237,7 +20237,7 @@ var Protocol = class {
20237
20237
  return;
20238
20238
  }
20239
20239
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
20240
- await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
20240
+ await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
20241
20241
  options?.signal?.throwIfAborted();
20242
20242
  }
20243
20243
  } catch (error2) {
@@ -20254,7 +20254,7 @@ var Protocol = class {
20254
20254
  */
20255
20255
  request(request, resultSchema, options) {
20256
20256
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
20257
- return new Promise((resolve6, reject) => {
20257
+ return new Promise((resolve7, reject) => {
20258
20258
  const earlyReject = (error2) => {
20259
20259
  reject(error2);
20260
20260
  };
@@ -20332,7 +20332,7 @@ var Protocol = class {
20332
20332
  if (!parseResult.success) {
20333
20333
  reject(parseResult.error);
20334
20334
  } else {
20335
- resolve6(parseResult.data);
20335
+ resolve7(parseResult.data);
20336
20336
  }
20337
20337
  } catch (error2) {
20338
20338
  reject(error2);
@@ -20594,12 +20594,12 @@ var Protocol = class {
20594
20594
  }
20595
20595
  } catch {
20596
20596
  }
20597
- return new Promise((resolve6, reject) => {
20597
+ return new Promise((resolve7, reject) => {
20598
20598
  if (signal.aborted) {
20599
20599
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
20600
20600
  return;
20601
20601
  }
20602
- const timeoutId = setTimeout(resolve6, interval);
20602
+ const timeoutId = setTimeout(resolve7, interval);
20603
20603
  signal.addEventListener("abort", () => {
20604
20604
  clearTimeout(timeoutId);
20605
20605
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -21740,7 +21740,7 @@ var McpServer = class {
21740
21740
  let task = createTaskResult.task;
21741
21741
  const pollInterval = task.pollInterval ?? 5e3;
21742
21742
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
21743
- await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
21743
+ await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
21744
21744
  const updatedTask = await extra.taskStore.getTask(taskId);
21745
21745
  if (!updatedTask) {
21746
21746
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -22404,12 +22404,12 @@ var StdioServerTransport = class {
22404
22404
  this.onclose?.();
22405
22405
  }
22406
22406
  send(message) {
22407
- return new Promise((resolve6) => {
22407
+ return new Promise((resolve7) => {
22408
22408
  const json2 = serializeMessage(message);
22409
22409
  if (this._stdout.write(json2)) {
22410
- resolve6();
22410
+ resolve7();
22411
22411
  } else {
22412
- this._stdout.once("drain", resolve6);
22412
+ this._stdout.once("drain", resolve7);
22413
22413
  }
22414
22414
  });
22415
22415
  }
@@ -22421,7 +22421,7 @@ import { homedir as homedir3 } from "node:os";
22421
22421
  import { delimiter } from "node:path";
22422
22422
 
22423
22423
  // src/tools.ts
22424
- import { existsSync as existsSync3, readFileSync as readFileSync5, realpathSync, statSync as statSync4 } from "node:fs";
22424
+ import { existsSync as existsSync4, readFileSync as readFileSync5, realpathSync as realpathSync2, statSync as statSync5 } from "node:fs";
22425
22425
  import { fileURLToPath as fileURLToPath2 } from "node:url";
22426
22426
 
22427
22427
  // ../shield/src/jsonrpc.ts
@@ -25694,7 +25694,8 @@ var MatchSchema = external_exports.object({
25694
25694
  // `detonation` is the Detonation Chamber (EX-024, m5-detonation): a
25695
25695
  // sandboxed model run, only with `--detonate`.
25696
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(),
25697
+ // `lifecycle-scripts` follows a package.json lifecycle script into the local file it runs (EX-036, lifecycle-scripts.ts).
25698
+ analysis: external_exports.enum(["trifecta", "detonation", "path-names", "lifecycle-scripts"]).optional(),
25698
25699
  // Text an element hides from a person by its style (EX-028, hidden-text.ts):
25699
25700
  // reported only when the hidden text addresses the AI or asks for actions.
25700
25701
  hidden_text: external_exports.boolean().optional(),
@@ -27791,7 +27792,7 @@ function skipArgument(text, p, lang, limit) {
27791
27792
  }
27792
27793
  return -1;
27793
27794
  }
27794
- function findKeyString(text, open3, lang, limit, sep2) {
27795
+ function findKeyString(text, open3, lang, limit, sep3) {
27795
27796
  let depth = 0;
27796
27797
  let i = open3;
27797
27798
  let lit = null;
@@ -27801,7 +27802,7 @@ function findKeyString(text, open3, lang, limit, sep2) {
27801
27802
  };
27802
27803
  const sepAt = (p) => {
27803
27804
  const j = skipTrivia(text, p, lang, limit);
27804
- if (text[j] !== sep2 || sep2 === "=" && text[j + 1] === "=") return -1;
27805
+ if (text[j] !== sep3 || sep3 === "=" && text[j + 1] === "=") return -1;
27805
27806
  return j + 1;
27806
27807
  };
27807
27808
  while (i < limit) {
@@ -28159,12 +28160,360 @@ function checkPathSegment(name) {
28159
28160
  return null;
28160
28161
  }
28161
28162
 
28163
+ // ../core/src/lifecycle-scripts.ts
28164
+ import { closeSync, existsSync, openSync, readSync, realpathSync, statSync } from "node:fs";
28165
+ import { isAbsolute as isAbsolute2, join as join5, relative as relative3, resolve as resolve2, sep } from "node:path";
28166
+
28167
+ // ../core/src/shell-words.ts
28168
+ var MAX_COMMAND_CHARS = 65536;
28169
+ var REDIRECT = /^\d*[<>]+&?\d*-?$/;
28170
+ var REDIRECT_WITH_TARGET = /^\d*[<>]+&?[^\s<>]/;
28171
+ function splitShell(command) {
28172
+ if (command.length > MAX_COMMAND_CHARS) return { ok: false };
28173
+ const segments = [];
28174
+ let words2 = [];
28175
+ let cur = "";
28176
+ let started = false;
28177
+ let quote = null;
28178
+ const endWord = () => {
28179
+ if (started) words2.push(cur);
28180
+ cur = "";
28181
+ started = false;
28182
+ };
28183
+ const endSegment = () => {
28184
+ endWord();
28185
+ const kept = [];
28186
+ for (let i = 0; i < words2.length; i++) {
28187
+ const w = words2[i] ?? "";
28188
+ if (REDIRECT.test(w)) {
28189
+ i += 1;
28190
+ continue;
28191
+ }
28192
+ if (REDIRECT_WITH_TARGET.test(w)) continue;
28193
+ kept.push(w);
28194
+ }
28195
+ if (kept.length > 0) segments.push(kept);
28196
+ words2 = [];
28197
+ };
28198
+ for (let i = 0; i < command.length; i++) {
28199
+ const c = command[i] ?? "";
28200
+ if (quote === "'") {
28201
+ if (c === "'") quote = null;
28202
+ else cur += c;
28203
+ continue;
28204
+ }
28205
+ if (quote === '"') {
28206
+ if (c === '"') quote = null;
28207
+ else if (c === "\\" && i + 1 < command.length && /["\\$`]/.test(command[i + 1] ?? "")) {
28208
+ cur += command[i + 1] ?? "";
28209
+ i += 1;
28210
+ } else cur += c;
28211
+ continue;
28212
+ }
28213
+ if (c === "\\") {
28214
+ if (i + 1 >= command.length) return { ok: false };
28215
+ cur += command[i + 1] ?? "";
28216
+ started = true;
28217
+ i += 1;
28218
+ } else if (c === "'" || c === '"') {
28219
+ quote = c;
28220
+ started = true;
28221
+ } else if (c === " " || c === " ") {
28222
+ endWord();
28223
+ } else if (c === ";" || c === "\n" || c === "|" || c === "&" || c === "(" || c === ")") {
28224
+ if (c === "&" && (/[<>]$/.test(cur) || command[i + 1] === ">")) {
28225
+ cur += c;
28226
+ started = true;
28227
+ continue;
28228
+ }
28229
+ endSegment();
28230
+ } else {
28231
+ cur += c;
28232
+ started = true;
28233
+ }
28234
+ }
28235
+ if (quote !== null) return { ok: false };
28236
+ endSegment();
28237
+ return { ok: true, segments };
28238
+ }
28239
+ function isPlainWord(word) {
28240
+ return word !== "" && !/[$`*?[\]{}]/.test(word) && !word.startsWith("~") && !word.includes("\0");
28241
+ }
28242
+ function stripPrefixes(words2) {
28243
+ let i = 0;
28244
+ for (; ; ) {
28245
+ const w = words2[i];
28246
+ if (w === void 0) break;
28247
+ if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(w)) {
28248
+ i += 1;
28249
+ continue;
28250
+ }
28251
+ if (w === "env" || w === "sudo" || w === "time" || w === "nohup" || w === "command" || w === "exec") {
28252
+ i += 1;
28253
+ continue;
28254
+ }
28255
+ if (w === "cross-env") {
28256
+ i += 1;
28257
+ continue;
28258
+ }
28259
+ break;
28260
+ }
28261
+ return words2.slice(i);
28262
+ }
28263
+
28264
+ // ../core/src/lifecycle-scripts.ts
28265
+ var INSTALL_HOOKS = [
28266
+ "preinstall",
28267
+ "install",
28268
+ "postinstall",
28269
+ "prepublish",
28270
+ "preprepare",
28271
+ "prepare",
28272
+ "postprepare",
28273
+ "prepublishOnly",
28274
+ "prepack",
28275
+ "postpack"
28276
+ ];
28277
+ var HOOK_BASES = /* @__PURE__ */ new Set(["test", "start", "stop", "restart", "build", "install", "publish", "version", "pack", "uninstall", "shrinkwrap"]);
28278
+ var MAX_FOLLOW_DEPTH = 3;
28279
+ var MAX_SOURCE_BYTES = 1048576;
28280
+ var MAX_SCRIPTS = 500;
28281
+ function parseScripts(pkgText) {
28282
+ try {
28283
+ const parsed = JSON.parse(pkgText);
28284
+ if (typeof parsed !== "object" || parsed === null) return {};
28285
+ const s = parsed["scripts"];
28286
+ if (typeof s !== "object" || s === null || Array.isArray(s)) return {};
28287
+ const out = {};
28288
+ for (const [k, v] of Object.entries(s).slice(0, MAX_SCRIPTS)) if (typeof v === "string") out[k] = v;
28289
+ return out;
28290
+ } catch {
28291
+ return {};
28292
+ }
28293
+ }
28294
+ function isAutoScript(name, scripts) {
28295
+ if (INSTALL_HOOKS.includes(name)) return true;
28296
+ const m = /^(pre|post)(.+)$/.exec(name);
28297
+ if (!m) return false;
28298
+ const base = m[2] ?? "";
28299
+ return Object.prototype.hasOwnProperty.call(scripts, base) || HOOK_BASES.has(base);
28300
+ }
28301
+ function autoScriptNames(scripts) {
28302
+ return Object.keys(scripts).filter((n) => isAutoScript(n, scripts));
28303
+ }
28304
+ var INTERPRETERS = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno", "sh", "bash", "zsh", "dash", "python", "python3", "ruby", "perl", "php"]);
28305
+ var INLINE_FLAGS = /* @__PURE__ */ new Set(["-e", "-c", "-p", "--eval", "--print"]);
28306
+ var VALUE_FLAGS = /* @__PURE__ */ new Set(["-r", "--require", "--import", "--loader", "--experimental-loader", "-C", "-W", "-X", "-m"]);
28307
+ var RUN_WORDS = /* @__PURE__ */ new Set(["run", "run-script", "rum", "urn"]);
28308
+ function cleanRel(p) {
28309
+ if (!isPlainWord(p) || /^[a-z][a-z0-9+.-]*:/i.test(p) || isAbsolute2(p) || p.length > 300) return null;
28310
+ const rel = p.replace(/^(?:\.\/)+/, "");
28311
+ return rel === "" ? null : rel;
28312
+ }
28313
+ function scriptTargets(name, scripts, depth = 0, seen = /* @__PURE__ */ new Set()) {
28314
+ const out = { files: [], inline: [], scripts: [] };
28315
+ const text = scripts[name];
28316
+ if (text === void 0 || seen.has(name) || depth > MAX_FOLLOW_DEPTH) return out;
28317
+ seen.add(name);
28318
+ out.inline.push(text);
28319
+ collectSegments(text, scripts, depth, seen, out);
28320
+ return out;
28321
+ }
28322
+ var SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash"]);
28323
+ var MODULE_FLAGS = /* @__PURE__ */ new Set(["-r", "--require", "--import", "--loader", "--experimental-loader"]);
28324
+ var MODULE_FLAG_EQ = /^(--require|--import|--loader|--experimental-loader)=([\s\S]+)$/;
28325
+ var PYTHON_MODULE = /^[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*$/;
28326
+ function pythonModuleFiles(mod) {
28327
+ if (!PYTHON_MODULE.test(mod) || mod.length > 200) return [];
28328
+ const path = mod.split(".").join("/");
28329
+ return [`${path}.py`, `${path}/__main__.py`, `${path}/__init__.py`];
28330
+ }
28331
+ function collectSegments(text, scripts, depth, seen, out) {
28332
+ const split = splitShell(text);
28333
+ if (!split.ok) return;
28334
+ for (const raw of split.segments) {
28335
+ const words2 = stripPrefixes(raw);
28336
+ const head = words2[0];
28337
+ if (head === void 0) continue;
28338
+ const base = head.split("/").pop() ?? head;
28339
+ if ((base === "npm" || base === "pnpm" || base === "yarn") && depth < MAX_FOLLOW_DEPTH) {
28340
+ const sub = words2[1] === "run" || RUN_WORDS.has(words2[1] ?? "") ? words2[2] : base === "yarn" || base === "pnpm" ? words2[1] : void 0;
28341
+ if (sub !== void 0 && Object.prototype.hasOwnProperty.call(scripts, sub)) {
28342
+ out.scripts.push(sub);
28343
+ const inner = scriptTargets(sub, scripts, depth + 1, seen);
28344
+ out.files.push(...inner.files);
28345
+ out.inline.push(...inner.inline);
28346
+ out.scripts.push(...inner.scripts);
28347
+ }
28348
+ continue;
28349
+ }
28350
+ const interp = /^python[0-9.]*$/.test(base) ? "python" : base;
28351
+ if (INTERPRETERS.has(interp)) {
28352
+ const isShell = SHELLS.has(interp);
28353
+ for (let i = 1; i < words2.length; i++) {
28354
+ const w = words2[i] ?? "";
28355
+ if (INLINE_FLAGS.has(w) || isShell && /^-[A-Za-z]*c[A-Za-z]*$/.test(w)) {
28356
+ const inner = words2[i + 1] ?? "";
28357
+ out.inline.push(inner);
28358
+ if (isShell && depth < MAX_FOLLOW_DEPTH) collectSegments(inner, scripts, depth + 1, seen, out);
28359
+ break;
28360
+ }
28361
+ const eq = MODULE_FLAG_EQ.exec(w);
28362
+ if (eq) {
28363
+ const rel2 = cleanRel(eq[2] ?? "");
28364
+ if (rel2 !== null) out.files.push(rel2);
28365
+ continue;
28366
+ }
28367
+ if (MODULE_FLAGS.has(w)) {
28368
+ const rel2 = cleanRel(words2[i + 1] ?? "");
28369
+ if (rel2 !== null) out.files.push(rel2);
28370
+ i += 1;
28371
+ continue;
28372
+ }
28373
+ if (w === "-m" && interp === "python") {
28374
+ out.files.push(...pythonModuleFiles(words2[i + 1] ?? ""));
28375
+ break;
28376
+ }
28377
+ if (VALUE_FLAGS.has(w)) {
28378
+ i += 1;
28379
+ continue;
28380
+ }
28381
+ if (w.startsWith("-")) continue;
28382
+ if (interp === "deno" && (w === "run" || w === "task")) continue;
28383
+ const rel = cleanRel(w);
28384
+ if (rel !== null) out.files.push(rel);
28385
+ break;
28386
+ }
28387
+ continue;
28388
+ }
28389
+ if (head.startsWith("./") || head.startsWith("scripts/") || head.includes("/") && !head.startsWith("-") && !head.includes(":")) {
28390
+ const rel = cleanRel(head);
28391
+ if (rel !== null) out.files.push(rel);
28392
+ }
28393
+ }
28394
+ }
28395
+ var SECRET_PATTERNS = [
28396
+ [/(?<![\w])\.env(?!\.(?:example|sample|template|dist))(?:\.[A-Za-z]+)?(?![\w-])/, ".env"],
28397
+ [/(?<![\w])\.npmrc\b/, ".npmrc"],
28398
+ [/(?<![\w])\.aws(?![\w-])/, "~/.aws"],
28399
+ [/(?<![\w])\.ssh(?![\w-])/, "~/.ssh"],
28400
+ [/\bid_(?:rsa|ed25519|ecdsa)\b/, "a private key file"],
28401
+ [/(?<![\w])\.(?:netrc|git-credentials|pypirc)\b/, "a credentials file"],
28402
+ [/JSON\.stringify\(\s*process\.env\s*[,)]/, "the whole of process.env"],
28403
+ [/Object\.(?:entries|keys|values|fromEntries|assign)\(\s*(?:\{\}\s*,\s*)?process\.env\s*\)/, "the whole of process.env"],
28404
+ [/\{\s*\.\.\.\s*process\.env\s*\}/, "the whole of process.env"],
28405
+ [/\bdict\(\s*os\.environ\s*\)|\bos\.environ\.(?:items|copy)\(\)|json\.dumps\(\s*os\.environ/, "the whole of os.environ"],
28406
+ [/(?:^|[;&|]\s*|\$\(\s*)(?:printenv|env)\s*(?:$|[|>)]|\s*\|)/, "the whole environment"]
28407
+ ];
28408
+ var SEND_PATTERNS = [
28409
+ [/\bhttps?\.(?:request|get)\s*\(/, "an http request"],
28410
+ [/\bfetch\s*\(/, "fetch"],
28411
+ [/\baxios(?:\.\w+)?\s*\(|\bgot(?:\.(?:post|get|put))?\s*\(\s*['"`]/, "an http client call"],
28412
+ [/new\s+XMLHttpRequest\b|new\s+WebSocket\s*\(/, "a browser-style request"],
28413
+ [/\bnet\.(?:connect|createConnection|Socket)\b/, "a socket"],
28414
+ [/require\(\s*['"](?:node:)?dgram['"]\s*\)|from\s+['"](?:node:)?dgram['"]/, "a datagram socket"],
28415
+ [/\b(?:curl|wget)\s+(?:-\S+\s+)*\S/, "curl or wget"],
28416
+ [/\/dev\/tcp\//, "/dev/tcp"],
28417
+ [/\bnc\s+\S+\s+\d+/, "netcat"],
28418
+ [/\burlopen\s*\(|\brequests\.(?:get|post|put)\s*\(|\bhttp\.client\b|\bsocket\.(?:socket|create_connection)\b|\bsmtplib\b/, "a python network call"]
28419
+ ];
28420
+ var lineHit = (lines, patterns) => {
28421
+ for (let i = 0; i < lines.length; i++) {
28422
+ const line = lines[i] ?? "";
28423
+ if (line.length > 4e3) continue;
28424
+ for (const [re2, label] of patterns) if (re2.test(line)) return { line: i + 1, label };
28425
+ }
28426
+ return null;
28427
+ };
28428
+ function analyzeSource(text) {
28429
+ const lines = text.split(/\r?\n/);
28430
+ return { secret: lineHit(lines, SECRET_PATTERNS), send: lineHit(lines, SEND_PATTERNS) };
28431
+ }
28432
+ function locateScript(pkgText, name) {
28433
+ const start = pkgText.search(/"scripts"\s*:/);
28434
+ const esc2 = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
28435
+ const re2 = new RegExp(`"${esc2}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`, "g");
28436
+ re2.lastIndex = Math.max(0, start);
28437
+ const m = re2.exec(pkgText);
28438
+ if (!m) return { line: 1, col: 1, span: name.slice(0, 120) };
28439
+ const valueIndex = m.index + m[0].indexOf('"', m[0].indexOf(":")) + 1;
28440
+ const before = pkgText.slice(0, valueIndex);
28441
+ const line = before.split("\n").length;
28442
+ const col = valueIndex - (before.lastIndexOf("\n") + 1) + 1;
28443
+ return { line, col, span: (m[1] ?? "").slice(0, 120) };
28444
+ }
28445
+ function lifecycleFindings(input) {
28446
+ const scripts = parseScripts(input.pkgText);
28447
+ const names = (input.names ?? autoScriptNames(scripts)).filter((n) => Object.prototype.hasOwnProperty.call(scripts, n));
28448
+ const hits = [];
28449
+ for (const name of names) {
28450
+ let found = null;
28451
+ try {
28452
+ const targets = scriptTargets(name, scripts);
28453
+ const where = locateScript(input.pkgText, name);
28454
+ const base = { script: name, scriptText: scripts[name] ?? "", ...where };
28455
+ for (const rel of [...new Set(targets.files)]) {
28456
+ const text = input.readLocal(rel);
28457
+ if (text === null) continue;
28458
+ const a = analyzeSource(text);
28459
+ if (a.secret && a.send) {
28460
+ found = { ...base, file: rel, secret: a.secret, send: a.send };
28461
+ break;
28462
+ }
28463
+ }
28464
+ if (!found) {
28465
+ for (const inline of targets.inline) {
28466
+ const a = analyzeSource(inline);
28467
+ if (a.secret && a.send) {
28468
+ found = { ...base, file: null, secret: a.secret, send: a.send };
28469
+ break;
28470
+ }
28471
+ }
28472
+ }
28473
+ } catch {
28474
+ found = null;
28475
+ }
28476
+ if (found) hits.push(found);
28477
+ }
28478
+ return hits;
28479
+ }
28480
+ function describeHit(h) {
28481
+ const where = h.file === null ? `The script text itself reads ${h.secret.label} and sends data out (${h.send.label}).` : `It runs ${h.file}, which reads ${h.secret.label} (line ${h.secret.line}) and sends data out through ${h.send.label} (line ${h.send.line}).`;
28482
+ return `The "${h.script}" script of package.json runs by itself when a package manager installs or tests this project. ${where}`;
28483
+ }
28484
+ function readLocalText(pkgDir, rel) {
28485
+ try {
28486
+ const abs = resolve2(pkgDir, rel);
28487
+ const within = (root, p) => {
28488
+ const r = relative3(root, p);
28489
+ return r !== "" && !r.startsWith("..") && !isAbsolute2(r) && !r.split(sep).includes("..");
28490
+ };
28491
+ if (!within(pkgDir, abs) || !existsSync(abs)) return null;
28492
+ const real = realpathSync(abs);
28493
+ if (!within(realpathSync(pkgDir), real)) return null;
28494
+ const st = statSync(real);
28495
+ if (!st.isFile() || st.size > MAX_SOURCE_BYTES) return null;
28496
+ const buf = Buffer.alloc(st.size);
28497
+ const fd = openSync(real, "r");
28498
+ try {
28499
+ readSync(fd, buf, 0, st.size, 0);
28500
+ } finally {
28501
+ closeSync(fd);
28502
+ }
28503
+ if (buf.includes(0)) return null;
28504
+ return buf.toString("utf8");
28505
+ } catch {
28506
+ return null;
28507
+ }
28508
+ }
28509
+
28162
28510
  // ../core/src/scanner/orchestrator.ts
28511
+ import { dirname } from "node:path";
28163
28512
  init_heuristic_engine();
28164
28513
 
28165
28514
  // ../core/src/capabilities.ts
28166
28515
  import { readFile as readFile2 } from "node:fs/promises";
28167
- import { join as join5 } from "node:path";
28516
+ import { join as join6 } from "node:path";
28168
28517
  init_zod();
28169
28518
  var CAPABILITIES = ["private-data", "untrusted-input", "exfiltration"];
28170
28519
  var CAPABILITIES_FILE = "capabilities.yaml";
@@ -28237,7 +28586,7 @@ function parseCapabilityRules(data) {
28237
28586
  async function loadCapabilityRules(definitionsDir) {
28238
28587
  let raw;
28239
28588
  try {
28240
- raw = await readFile2(join5(definitionsDir, CAPABILITIES_FILE), "utf8");
28589
+ raw = await readFile2(join6(definitionsDir, CAPABILITIES_FILE), "utf8");
28241
28590
  } catch {
28242
28591
  return { ok: false, missing: true, error: `${CAPABILITIES_FILE} was not found in ${definitionsDir}` };
28243
28592
  }
@@ -28252,8 +28601,8 @@ async function loadCapabilityRules(definitionsDir) {
28252
28601
  var PACKAGE_RUNNERS = /* @__PURE__ */ new Set(["npx", "bunx", "pnpx", "uvx"]);
28253
28602
  var SCRIPT_RUNNERS = /* @__PURE__ */ new Set(["node", "nodejs", "python", "python3", "py", "bun", "deno", "tsx", "ts-node"]);
28254
28603
  var CONTAINERS = /* @__PURE__ */ new Set(["docker", "podman"]);
28255
- var SHELLS = /* @__PURE__ */ new Set(["bash", "sh", "zsh", "cmd", "powershell", "pwsh"]);
28256
- var LAUNCHERS = /* @__PURE__ */ new Set([...PACKAGE_RUNNERS, ...SCRIPT_RUNNERS, ...CONTAINERS, ...SHELLS, "npm", "pnpm", "yarn", "uv", "pipx", "env", "exorcist"]);
28604
+ var SHELLS2 = /* @__PURE__ */ new Set(["bash", "sh", "zsh", "cmd", "powershell", "pwsh"]);
28605
+ var LAUNCHERS = /* @__PURE__ */ new Set([...PACKAGE_RUNNERS, ...SCRIPT_RUNNERS, ...CONTAINERS, ...SHELLS2, "npm", "pnpm", "yarn", "uv", "pipx", "env", "exorcist"]);
28257
28606
  var DOCKER_VALUE_FLAGS = /* @__PURE__ */ new Set([
28258
28607
  "-e",
28259
28608
  "--env",
@@ -28323,7 +28672,7 @@ function unwrapLaunch(command, args, depth = 0) {
28323
28672
  if (u !== -1 && args[u + 1] !== void 0) return { command: "", args: [], url: args[u + 1] };
28324
28673
  }
28325
28674
  const base = basenameOf(command);
28326
- if (depth < 3 && SHELLS.has(base)) {
28675
+ if (depth < 3 && SHELLS2.has(base)) {
28327
28676
  const c = args.findIndex((a) => /^(?:-c|\/c|-command)$/i.test(a));
28328
28677
  const inner = c === -1 ? void 0 : args[c + 1];
28329
28678
  if (inner !== void 0) {
@@ -28519,7 +28868,7 @@ function classifyCapabilities(server2, rules) {
28519
28868
  init_zod();
28520
28869
  import { constants } from "node:fs";
28521
28870
  import { lstat, open as open2 } from "node:fs/promises";
28522
- import { join as join6 } from "node:path";
28871
+ import { join as join7 } from "node:path";
28523
28872
  init_severity_paths();
28524
28873
  init_walker();
28525
28874
  var TRIFECTA_RULE_ID = "EX-023";
@@ -28658,7 +29007,7 @@ function parsePins(json2) {
28658
29007
  return out;
28659
29008
  }
28660
29009
  async function readPins(root, maxBytes = MAX_PINS_BYTES) {
28661
- const path = join6(root, ".exorcist", "pins.json");
29010
+ const path = join7(root, ".exorcist", "pins.json");
28662
29011
  const none = (note) => ({ pins: /* @__PURE__ */ new Map(), note });
28663
29012
  let info;
28664
29013
  try {
@@ -28818,6 +29167,21 @@ async function* pathNameFindings(root, def) {
28818
29167
  } catch {
28819
29168
  }
28820
29169
  }
29170
+ function lifecycleScanFindings(text, absPath, rel, def) {
29171
+ const dir = dirname(absPath);
29172
+ return lifecycleFindings({ pkgText: text, readLocal: (r) => readLocalText(dir, r) }).map((h) => ({
29173
+ source: "signature",
29174
+ ruleId: def.id,
29175
+ title: def.title,
29176
+ severity: def.severity,
29177
+ file: rel,
29178
+ line: h.line,
29179
+ col: h.col,
29180
+ span: h.span,
29181
+ owasp: def.owasp,
29182
+ fix: `${describeHit(h)} ${def.fix}`
29183
+ }));
29184
+ }
28821
29185
  async function* scanRepo(root, options) {
28822
29186
  const defs = await loadDefinitions(options.definitionsDir);
28823
29187
  const canaries = loadCanariesFile(canariesPath(root));
@@ -28834,6 +29198,7 @@ async function* scanRepo(root, options) {
28834
29198
  let filesSkipped = 0;
28835
29199
  let findingsTotal = 0;
28836
29200
  const ex026 = defs.find((d) => d.id === "EX-026");
29201
+ const ex036 = defs.find((d) => d.id === "EX-036" && d.enabled !== false && d.match.analysis === "lifecycle-scripts");
28837
29202
  for await (const file of walkRepo(root, options.maxFileSizeBytes)) {
28838
29203
  yield { type: "file", file };
28839
29204
  if (file.tooLarge) {
@@ -28869,7 +29234,8 @@ async function* scanRepo(root, options) {
28869
29234
  const heurs = options.bedrockClient ? await runHeuristics(file, norm, sigs, options.bedrockClient) : [];
28870
29235
  const traps = canaryFindings(text, file.rel, records, ex022);
28871
29236
  const sourceTools = (file.role === "code" || file.role === "unknown") && languageOf(file.rel) !== null ? scanSourceTools(file, text, defs) : [];
28872
- let deduped = deduplicate([...sigs, ...heurs, ...traps, ...sandboxFindings(text, file.rel), ...sourceTools]);
29237
+ const lifecycle = ex036 && file.role === "manifest" && file.rel.split("/").pop() === "package.json" ? lifecycleScanFindings(text, file.path, file.rel, ex036) : [];
29238
+ let deduped = deduplicate([...sigs, ...heurs, ...traps, ...sandboxFindings(text, file.rel), ...sourceTools, ...lifecycle]);
28873
29239
  if (checkVault && deduped.length > 0 && file.rel.includes(".exorcist/vault/")) {
28874
29240
  const backup = checkVault(file.rel, await readFile3(file.path));
28875
29241
  if (backup) deduped = deduped.map((f) => asBackupFinding(f, backup));
@@ -29129,6 +29495,14 @@ var ENTRIES = {
29129
29495
  headline: "This project file switches off the sandbox around your AI tool servers",
29130
29496
  attack: "A committed Kiro sandbox file turns MCP sandboxing, or the whole command sandbox, off, so local tool servers run without the operating-system boundary. This is only information: a project file can only tighten your global sandbox policy, so your global setting may still apply."
29131
29497
  },
29498
+ "EX-036": {
29499
+ headline: "A script that runs by itself sends your secrets out",
29500
+ attack: 'This package has a script that npm, pnpm or yarn runs on its own (on install, or before or after "npm test"), and the file it runs reads your .env or other credentials and sends data to another computer. Your AI agent only has to run the tests or install the project; it does not have to obey anything.'
29501
+ },
29502
+ "EX-037": {
29503
+ headline: "This text tells your AI to do something and not to tell you",
29504
+ attack: 'A file gives the agent a job (create a file, skip a test, edit a settings file, send something out) and then tells it to keep that from you: "do not tell the user", "do not mention it", "without telling the user". Plain wording like this has no trick words, but the request to hide the job is what gives it away. The same text can sit in a steering file, a README, a CONTRIBUTING note or a comment in source code.'
29505
+ },
29132
29506
  "EX-027": {
29133
29507
  headline: "Your AI read untrusted text and private data, and now wants to send something out",
29134
29508
  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."
@@ -29301,9 +29675,9 @@ var BUNDLED_DEFINITIONS_VERSION = "20261124.0";
29301
29675
  // ../core/src/liveupdate.ts
29302
29676
  init_zod();
29303
29677
  import { createHash as createHash2, createPrivateKey, createPublicKey, generateKeyPairSync, randomBytes as randomBytes2, sign as edSign, verify as edVerify } from "node:crypto";
29304
- import { closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync as readFileSync3, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
29678
+ import { closeSync as closeSync2, fstatSync, lstatSync, mkdirSync, openSync as openSync2, readFileSync as readFileSync3, readSync as readSync2, readdirSync, renameSync, rmSync, statSync as statSync2, writeFileSync } from "node:fs";
29305
29679
  import { homedir } from "node:os";
29306
- import { basename as basename3, join as join7, resolve as resolve2 } from "node:path";
29680
+ import { basename as basename3, join as join8, resolve as resolve3 } from "node:path";
29307
29681
  var DEFINITIONS_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
29308
29682
  MCowBQYDK2VwAyEAn4o+dmOJXIzsygT2CF/3go/1E/bk9Ub16r4hGtJJjhM=
29309
29683
  -----END PUBLIC KEY-----
@@ -29381,19 +29755,19 @@ function parseManifest(manifestBytes) {
29381
29755
  }
29382
29756
  function installedDefinitionsRoot(env = process.env) {
29383
29757
  const fromEnv = env["EXORCIST_DEFINITIONS_HOME"];
29384
- if (fromEnv) return resolve2(fromEnv);
29385
- return join7(env["HOME"] || env["USERPROFILE"] || homedir(), ".exorcist", "definitions");
29758
+ if (fromEnv) return resolve3(fromEnv);
29759
+ return join8(env["HOME"] || env["USERPROFILE"] || homedir(), ".exorcist", "definitions");
29386
29760
  }
29387
29761
  function verifySetFolder(dir, expectedVersion, publicKeyPem) {
29388
29762
  try {
29389
29763
  if (!lstatSync(dir).isDirectory()) return fail("not a real folder (a symlink or a file)");
29390
- const defsDir = join7(dir, "definitions");
29391
- for (const [p, kind] of [[join7(dir, MANIFEST_NAME), "file"], [join7(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
29764
+ const defsDir = join8(dir, "definitions");
29765
+ for (const [p, kind] of [[join8(dir, MANIFEST_NAME), "file"], [join8(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
29392
29766
  const st = lstatSync(p);
29393
29767
  if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail(`${basename3(p)} is not a plain ${kind === "file" ? "file" : "folder"}`);
29394
29768
  }
29395
- const manifestBytes = readFileSync3(join7(dir, MANIFEST_NAME));
29396
- const bad = verifySignature(manifestBytes, readFileSync3(join7(dir, SIGNATURE_NAME)), publicKeyPem);
29769
+ const manifestBytes = readFileSync3(join8(dir, MANIFEST_NAME));
29770
+ const bad = verifySignature(manifestBytes, readFileSync3(join8(dir, SIGNATURE_NAME)), publicKeyPem);
29397
29771
  if (bad) return fail("the manifest signature does not verify");
29398
29772
  const m = parseManifest(manifestBytes);
29399
29773
  if (!m.ok) return m;
@@ -29403,7 +29777,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
29403
29777
  const extra = onDisk.filter((n) => !listed.includes(n));
29404
29778
  if (extra.length > 0) return fail(`definitions/ holds files the manifest does not list: ${extra.map((n) => printable(n)).join(", ")}`);
29405
29779
  for (const name of listed) {
29406
- const p = join7(defsDir, name);
29780
+ const p = join8(defsDir, name);
29407
29781
  let st;
29408
29782
  try {
29409
29783
  st = lstatSync(p);
@@ -29434,7 +29808,7 @@ function findActiveInstalledSet(o = {}) {
29434
29808
  }
29435
29809
  const newer = names.filter((n) => isValidVersion(n) && compareVersions(n, BUNDLED_DEFINITIONS_VERSION) > 0).sort((a, b) => compareVersions(b, a));
29436
29810
  for (const name of newer) {
29437
- const r = verifyInstalledSet(join7(root, name), pem);
29811
+ const r = verifyInstalledSet(join8(root, name), pem);
29438
29812
  if (r.ok) return r.set;
29439
29813
  }
29440
29814
  return null;
@@ -29480,6 +29854,29 @@ var SessionJsonSchema = external_exports.object({
29480
29854
  approveForMe: external_exports.boolean().optional()
29481
29855
  }).passthrough();
29482
29856
 
29857
+ // ../core/src/run-scripts-guard.ts
29858
+ var INSTALL_SET = [...INSTALL_HOOKS];
29859
+
29860
+ // ../core/src/shell-read-guard.ts
29861
+ var MAX_TOTAL_BYTES = 32 * 1024 * 1024;
29862
+ var VALUE_FLAGS2 = {
29863
+ cat: /* @__PURE__ */ new Set(),
29864
+ head: /* @__PURE__ */ new Set(["-n", "-c", "--lines", "--bytes"]),
29865
+ tail: /* @__PURE__ */ new Set(["-n", "-c", "--lines", "--bytes", "-s", "--sleep-interval"]),
29866
+ less: /* @__PURE__ */ new Set(["-b", "-h", "-j", "-p", "-P", "-t", "-T", "-x", "-y", "-z"]),
29867
+ more: /* @__PURE__ */ new Set(["-n", "-p"]),
29868
+ bat: /* @__PURE__ */ new Set(["-l", "--language", "-r", "--line-range", "--theme", "--style", "--tabs", "--wrap"]),
29869
+ batcat: /* @__PURE__ */ new Set(["-l", "--language", "-r", "--line-range", "--theme", "--style", "--tabs", "--wrap"]),
29870
+ nl: /* @__PURE__ */ new Set(["-b", "-d", "-f", "-h", "-i", "-l", "-n", "-s", "-v", "-w"]),
29871
+ sed: /* @__PURE__ */ new Set(["-e", "-f", "--expression", "--file", "-l", "-E", "-s"]),
29872
+ awk: /* @__PURE__ */ new Set(["-F", "-v", "-f", "--file", "-e", "--source"]),
29873
+ gawk: /* @__PURE__ */ new Set(["-F", "-v", "-f", "--file", "-e", "--source"]),
29874
+ grep: /* @__PURE__ */ new Set(["-e", "-f", "-m", "-A", "-B", "-C", "--include", "--exclude", "--exclude-dir", "--regexp", "--file", "--max-count", "--label", "--color", "-d", "-D"])
29875
+ };
29876
+ VALUE_FLAGS2["egrep"] = VALUE_FLAGS2["grep"] ?? /* @__PURE__ */ new Set();
29877
+ VALUE_FLAGS2["fgrep"] = VALUE_FLAGS2["grep"] ?? /* @__PURE__ */ new Set();
29878
+ var FILE_PROGRAMS = new Set(Object.keys(VALUE_FLAGS2));
29879
+
29483
29880
  // ../shield/src/paraphrase.ts
29484
29881
  var W = String.raw`[\s\W_]{0,3}`;
29485
29882
  var words = (...ws) => ws.join(`${W}`);
@@ -29726,11 +30123,11 @@ var LockSchema = external_exports.object({
29726
30123
 
29727
30124
  // ../shield/src/vault.ts
29728
30125
  import { createHash as createHash3, randomBytes as randomBytes3 } from "node:crypto";
29729
- import { copyFileSync, existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync4, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
29730
- import { basename as basename4, dirname, isAbsolute as isAbsolute2, join as join8, resolve as resolve3 } from "node:path";
30126
+ import { copyFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync4, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync3, writeFileSync as writeFileSync2 } from "node:fs";
30127
+ import { basename as basename4, dirname as dirname2, isAbsolute as isAbsolute3, join as join9, resolve as resolve4 } from "node:path";
29731
30128
  init_zod();
29732
30129
  var SafeRel = external_exports.string().min(1).max(1024).refine(
29733
- (p) => !isAbsolute2(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
30130
+ (p) => !isAbsolute3(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
29734
30131
  "unsafe path"
29735
30132
  );
29736
30133
  var EditedFileSchema = external_exports.object({
@@ -29760,18 +30157,18 @@ function newId(label, now) {
29760
30157
  return `${stamp}-${slug}-${randomBytes3(2).toString("hex")}`;
29761
30158
  }
29762
30159
  function entryDir(vaultDir, id) {
29763
- return join8(vaultDir, id);
30160
+ return join9(vaultDir, id);
29764
30161
  }
29765
30162
  function writeManifest(vaultDir, e) {
29766
- writeFileSync2(join8(entryDir(vaultDir, e.id), "manifest.json"), `${JSON.stringify(e, null, 2)}
30163
+ writeFileSync2(join9(entryDir(vaultDir, e.id), "manifest.json"), `${JSON.stringify(e, null, 2)}
29767
30164
  `, "utf8");
29768
30165
  }
29769
30166
  function listEntries(vaultDir) {
29770
- if (!existsSync(vaultDir)) return [];
30167
+ if (!existsSync2(vaultDir)) return [];
29771
30168
  const out = [];
29772
30169
  for (const name of readdirSync2(vaultDir)) {
29773
- const file = join8(vaultDir, name, "manifest.json");
29774
- if (!existsSync(file)) continue;
30170
+ const file = join9(vaultDir, name, "manifest.json");
30171
+ if (!existsSync2(file)) continue;
29775
30172
  try {
29776
30173
  const parsed = EntrySchema.safeParse(JSON.parse(readFileSync4(file, "utf8")));
29777
30174
  if (parsed.success) out.push(parsed.data);
@@ -29803,7 +30200,7 @@ function readConfig(path) {
29803
30200
  var writeConfig = (path, cfg) => writeFileSync2(path, `${JSON.stringify(cfg, null, 2)}
29804
30201
  `, "utf8");
29805
30202
  function quarantineServer(o) {
29806
- const configPath = resolve3(o.configPath);
30203
+ const configPath = resolve4(o.configPath);
29807
30204
  const cfg = readConfig(configPath);
29808
30205
  if (!cfg.ok) return cfg;
29809
30206
  const entry = cfg.value.mcpServers?.[o.serverName];
@@ -29817,7 +30214,7 @@ function quarantineServer(o) {
29817
30214
  mkdirSync2(dir, { recursive: true });
29818
30215
  const backup = `${JSON.stringify(entry, null, 2)}
29819
30216
  `;
29820
- writeFileSync2(join8(dir, "entry.json"), backup, "utf8");
30217
+ writeFileSync2(join9(dir, "entry.json"), backup, "utf8");
29821
30218
  const e = {
29822
30219
  id,
29823
30220
  kind: "mcp-server",
@@ -29995,12 +30392,12 @@ var MAX_HASHED_BYTES = 64 * 1024 * 1024;
29995
30392
  var MAX_EVENT_BYTES2 = 16 * 1024 * 1024;
29996
30393
 
29997
30394
  // ../shield/src/locate.ts
29998
- import { existsSync as existsSync2, readdirSync as readdirSync3, statSync as statSync3 } from "node:fs";
29999
- import { dirname as dirname2, isAbsolute as isAbsolute3, join as join9, parse as parse3, resolve as resolve4 } from "node:path";
30395
+ import { existsSync as existsSync3, readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
30396
+ import { dirname as dirname3, isAbsolute as isAbsolute4, join as join10, parse as parse3, resolve as resolve5 } from "node:path";
30000
30397
  import { fileURLToPath } from "node:url";
30001
30398
  function hasDefinitions(dir) {
30002
30399
  try {
30003
- return statSync3(dir).isDirectory() && readdirSync3(dir).some((f) => /^EX-\d{3}.*\.yaml$/.test(f));
30400
+ return statSync4(dir).isDirectory() && readdirSync3(dir).some((f) => /^EX-\d{3}.*\.yaml$/.test(f));
30004
30401
  } catch {
30005
30402
  return false;
30006
30403
  }
@@ -30008,13 +30405,13 @@ function hasDefinitions(dir) {
30008
30405
  function findDefinitionsDir(o) {
30009
30406
  const env = o.env ?? process.env;
30010
30407
  const cwd = o.cwd ?? process.cwd();
30011
- if (o.explicit) return resolve4(cwd, o.explicit);
30408
+ if (o.explicit) return resolve5(cwd, o.explicit);
30012
30409
  const fromEnv = env["EXORCIST_DEFINITIONS"];
30013
- if (fromEnv) return resolve4(cwd, fromEnv);
30410
+ if (fromEnv) return resolve5(cwd, fromEnv);
30014
30411
  const installed = findActiveInstalledSet({ env, ...o.publicKeyPem ? { publicKeyPem: o.publicKeyPem } : {} });
30015
30412
  if (installed && hasDefinitions(installed.definitionsDir)) return installed.definitionsDir;
30016
- const here = dirname2(fileURLToPath(o.callerUrl));
30017
- const candidates = [join9(here, "..", "definitions"), join9(here, "..", "..", "..", "definitions"), join9(cwd, "definitions")];
30413
+ const here = dirname3(fileURLToPath(o.callerUrl));
30414
+ const candidates = [join10(here, "..", "definitions"), join10(here, "..", "..", "..", "definitions"), join10(cwd, "definitions")];
30018
30415
  return candidates.find(hasDefinitions) ?? null;
30019
30416
  }
30020
30417
 
@@ -30048,7 +30445,7 @@ function isWrapped(entry) {
30048
30445
 
30049
30446
  // src/tools.ts
30050
30447
  import { homedir as homedir2 } from "node:os";
30051
- import { basename as basename5, dirname as dirname3, isAbsolute as isAbsolute4, join as join10, relative as relative3, resolve as resolve5, sep } from "node:path";
30448
+ import { basename as basename5, dirname as dirname4, isAbsolute as isAbsolute5, join as join11, relative as relative4, resolve as resolve6, sep as sep2 } from "node:path";
30052
30449
  var quotesWanted = (ctx2, asked) => asked === true && ctx2.noQuotes !== true;
30053
30450
  var RANK = { critical: 0, high: 1, medium: 2, low: 3 };
30054
30451
  var HIDDEN2 = /[\u200B-\u200D\uFEFF\u202A-\u202E\u2066-\u2069\u{E0000}-\u{E007F}]/gu;
@@ -30060,17 +30457,17 @@ function findDefinitionsDir2(cwd) {
30060
30457
  return findDefinitionsDir({ callerUrl: import.meta.url, cwd });
30061
30458
  }
30062
30459
  function resolveInside(cwd, p, roots = [], primary) {
30063
- const real = (d) => realpathSync(d);
30064
- const extra = roots.filter((r) => existsSync3(r)).map(real);
30460
+ const real = (d) => realpathSync2(d);
30461
+ const extra = roots.filter((r) => existsSync4(r)).map(real);
30065
30462
  const first = primary !== void 0 && extra.includes(real(primary)) ? [real(primary)] : [];
30066
30463
  const bases = [.../* @__PURE__ */ new Set([...first, real(cwd), ...extra])];
30067
- const tries = isAbsolute4(p) ? [p] : bases.map((b) => resolve5(b, p));
30068
- const found = tries.find((t) => existsSync3(t));
30464
+ const tries = isAbsolute5(p) ? [p] : bases.map((b) => resolve6(b, p));
30465
+ const found = tries.find((t) => existsSync4(t));
30069
30466
  if (!found) return { ok: false, error: `Path not found: ${p}` };
30070
- const target = realpathSync(found);
30467
+ const target = realpathSync2(found);
30071
30468
  const base = bases.find((b) => {
30072
- const rel = relative3(b, target);
30073
- return !rel.startsWith("..") && !isAbsolute4(rel);
30469
+ const rel = relative4(b, target);
30470
+ return !rel.startsWith("..") && !isAbsolute5(rel);
30074
30471
  });
30075
30472
  if (!base) {
30076
30473
  const where = bases.length > 1 ? `the project folder (${bases[0]}) or the folders your client shared` : `the project folder (${bases[0]})`;
@@ -30101,23 +30498,23 @@ var PROJECT_MARKERS = [
30101
30498
  "README"
30102
30499
  ];
30103
30500
  function looksLikeProject(dir) {
30104
- const has = (n) => existsSync3(join10(dir, n));
30501
+ const has = (n) => existsSync4(join11(dir, n));
30105
30502
  if (has("plugin.json") || has("POWER.md")) return false;
30106
30503
  return PROJECT_MARKERS.some(has);
30107
30504
  }
30108
- var SENSITIVE_IN_HOME = [".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".password-store", join10("Library", "Keychains")];
30505
+ var SENSITIVE_IN_HOME = [".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".password-store", join11("Library", "Keychains")];
30109
30506
  var SENSITIVE_ABSOLUTE = ["/etc", "/private/etc", "/System", "/var/root", "/root"];
30110
30507
  var isWithin = (base, p) => {
30111
- const rel = relative3(base, p);
30112
- return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
30508
+ const rel = relative4(base, p);
30509
+ return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
30113
30510
  };
30114
30511
  function sensitiveReason(real, home = homedir2()) {
30115
- const realHome = existsSync3(home) ? realpathSync(home) : home;
30116
- if (dirname3(real) === real) return "it is the filesystem root";
30512
+ const realHome = existsSync4(home) ? realpathSync2(home) : home;
30513
+ if (dirname4(real) === real) return "it is the filesystem root";
30117
30514
  if (isWithin(real, realHome)) return real === realHome ? "it is the home folder" : "it contains the home folder";
30118
30515
  for (const n of SENSITIVE_IN_HOME) {
30119
- const s = join10(realHome, n);
30120
- if (isWithin(s, real) || isWithin(real, s)) return `it holds credentials or settings (${n.split(sep)[0]})`;
30516
+ const s = join11(realHome, n);
30517
+ if (isWithin(s, real) || isWithin(real, s)) return `it holds credentials or settings (${n.split(sep2)[0]})`;
30121
30518
  }
30122
30519
  for (const s of SENSITIVE_ABSOLUTE) if (isWithin(s, real)) return "it is a system folder";
30123
30520
  return null;
@@ -30130,21 +30527,21 @@ function approvalMessage(folder) {
30130
30527
  }
30131
30528
  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.";
30132
30529
  function noProjectError(ctx2, p, inside2) {
30133
- if (inside2.outside || isAbsolute4(p) || (ctx2.roots?.length ?? 0) > 0 || looksLikeProject(ctx2.cwd)) return null;
30530
+ if (inside2.outside || isAbsolute5(p) || (ctx2.roots?.length ?? 0) > 0 || looksLikeProject(ctx2.cwd)) return null;
30134
30531
  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;
30135
30532
  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.`;
30136
30533
  }
30137
30534
  async function resolveAllowed(ctx2, p) {
30138
30535
  const first = resolveInside(ctx2.cwd, p, ctx2.roots, ctx2.base);
30139
- if (first.ok || !first.outside || !isAbsolute4(p)) return first;
30536
+ if (first.ok || !first.outside || !isAbsolute5(p)) return first;
30140
30537
  const noRoots = (ctx2.roots?.length ?? 0) === 0;
30141
30538
  if (!ctx2.ask) {
30142
30539
  return noRoots && !looksLikeProject(ctx2.cwd) ? { ...first, error: `${first.error} No project folder is known. ${FIXES}` } : first;
30143
30540
  }
30144
30541
  let folder;
30145
30542
  try {
30146
- const real = realpathSync(p);
30147
- folder = statSync4(real).isDirectory() ? real : dirname3(real);
30543
+ const real = realpathSync2(p);
30544
+ folder = statSync5(real).isDirectory() ? real : dirname4(real);
30148
30545
  } catch {
30149
30546
  return first;
30150
30547
  }
@@ -30176,16 +30573,16 @@ function usableRoots(entries, home) {
30176
30573
  continue;
30177
30574
  }
30178
30575
  } else if (/^[a-z][a-z0-9+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) continue;
30179
- if (!isAbsolute4(path) || !existsSync3(path)) continue;
30576
+ if (!isAbsolute5(path) || !existsSync4(path)) continue;
30180
30577
  let real;
30181
30578
  try {
30182
- if (!statSync4(path).isDirectory()) continue;
30183
- real = realpathSync(path);
30579
+ if (!statSync5(path).isDirectory()) continue;
30580
+ real = realpathSync2(path);
30184
30581
  } catch {
30185
30582
  continue;
30186
30583
  }
30187
- const realHome = existsSync3(home) ? realpathSync(home) : home;
30188
- if (real === resolve5("/") || real === realHome || dirname3(real) === real) continue;
30584
+ const realHome = existsSync4(home) ? realpathSync2(home) : home;
30585
+ if (real === resolve6("/") || real === realHome || dirname4(real) === real) continue;
30189
30586
  if (!out.includes(real)) out.push(real);
30190
30587
  }
30191
30588
  return out;
@@ -30227,8 +30624,8 @@ async function scanRepoTool(ctx2, a) {
30227
30624
  if (!inside2.ok) return err(inside2.error);
30228
30625
  const defs = await loadDefs(ctx2);
30229
30626
  if (!defs.ok) return err(defs.error);
30230
- const isFile = statSync4(inside2.path).isFile();
30231
- const root = isFile ? dirname3(inside2.path) : inside2.path;
30627
+ const isFile = statSync5(inside2.path).isFile();
30628
+ const root = isFile ? dirname4(inside2.path) : inside2.path;
30232
30629
  const only = isFile ? basename5(inside2.path) : null;
30233
30630
  const findings = [];
30234
30631
  let files = 0;
@@ -30245,7 +30642,7 @@ async function scanMcpConfigTool(ctx2, a) {
30245
30642
  const none = noProjectError(ctx2, a.path, inside2);
30246
30643
  if (none) return err(none);
30247
30644
  if (!inside2.ok) return err(inside2.error);
30248
- if (!statSync4(inside2.path).isFile()) return err(`${a.path} is a folder. Give the path of an MCP config file.`);
30645
+ if (!statSync5(inside2.path).isFile()) return err(`${a.path} is a folder. Give the path of an MCP config file.`);
30249
30646
  const defs = await loadDefs(ctx2);
30250
30647
  if (!defs.ok) return err(defs.error);
30251
30648
  const text = readFileSync5(inside2.path, "utf8");
@@ -30255,7 +30652,7 @@ async function scanMcpConfigTool(ctx2, a) {
30255
30652
  } catch {
30256
30653
  return err(`${a.path} is not valid JSON.`);
30257
30654
  }
30258
- const rel = relative3(inside2.base, inside2.path);
30655
+ const rel = relative4(inside2.base, inside2.path);
30259
30656
  const findings = scanText(text, "mcp-config", defs.defs, rel);
30260
30657
  const servers = Object.entries(config2.mcpServers ?? {});
30261
30658
  const local = servers.filter(([, e]) => typeof e["command"] === "string");
@@ -30294,7 +30691,7 @@ async function quarantineTool(ctx2, a) {
30294
30691
  configPath: inside2.path,
30295
30692
  serverName: a.server,
30296
30693
  reason: a.reason?.slice(0, 200) ?? "quarantined from an AI agent request",
30297
- vaultDir: join10(inside2.base, ".exorcist", "vault")
30694
+ vaultDir: join11(inside2.base, ".exorcist", "vault")
30298
30695
  });
30299
30696
  if (!r.ok) return err(r.error);
30300
30697
  return {
@@ -30304,7 +30701,7 @@ Tell the user. They can undo this with: exorcist vault restore ${r.value.id}`
30304
30701
  }
30305
30702
 
30306
30703
  // src/index.ts
30307
- var VERSION = "0.3.0";
30704
+ var VERSION = "0.3.2";
30308
30705
  var ctx = {
30309
30706
  cwd: process.cwd(),
30310
30707
  approved: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exorcist-98/mcp-server",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "MCP server for Exorcist 98: scan repos and MCP configs, explain findings, quarantine servers.",