@exorcist-98/mcp-server 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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.7"] }
40
+ "exorcist": { "command": "npx", "args": ["-y", "@exorcist-98/mcp-server@0.3.8"] }
41
41
  }
42
42
  }
43
43
  ```
@@ -11,7 +11,7 @@ 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?|\\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)))"
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))|ignora(?:r)?\\s+(?:todas\\s+)?(?:las\\s+)?instrucciones\\s+(?:anteriores|previas)|olvida\\s+(?:todas\\s+)?(?:las\\s+)?instrucciones\\s+anteriores|ignore(?:z|r)?\\s+(?:toutes\\s+)?(?:les\\s+)?instructions\\s+(?:pr[eé]c[eé]dentes|ant[eé]rieures)|ignorier(?:e|en)?\\s+(?:alle\\s+)?(?:vorherigen|fr[üu]heren|obigen)\\s+(?:anweisungen|instruktionen|regeln)|ignor(?:e|ar)\\s+(?:todas\\s+)?(?:as\\s+)?instru[çc][õo]es\\s+(?:anteriores|pr[ée]vias)|ignora(?:re)?\\s+(?:tutte\\s+)?(?:le\\s+)?(?:istruzioni|regole)\\s+(?:precedenti|anteriori)|忽略(?:之前|以前|先前|上述|以上|前面)(?:的)?(?:所有)?(?:指令|指示|说明|规则|提示)|(?:以前|これまで|上記|前)の(?:すべての)?(?:指示|命令|ルール|指令)を(?:すべて)?(?:無視|忘れ)|(?:이전|위의|앞의)\\s*(?:모든\\s*)?(?:지시|지침|명령|규칙)(?:사항)?(?:을|를)?\\s*(?:모두\\s*)?(?:무시|잊)|игнорируй(?:те)?\\s+(?:все\\s+)?(?:предыдущие|прежние|вышеуказанные)\\s+(?:инструкции|указания|правила))"
15
15
  # The last alternative is an exfiltration order (m8-incidents 3.1): a verb
16
16
  # (send, upload, post, forward, email, paste ...) with an object (env file,
17
17
  # credentials, tokens, keys, secrets) and a destination (a URL, an address, a
@@ -1,6 +1,6 @@
1
1
  id: EX-035
2
2
  title: Committed sandbox file turns MCP sandboxing off
3
- severity: low
3
+ severity: info
4
4
  applies_to:
5
5
  - config
6
6
  # The encyclopedia record for the sandbox policy check (CT-18). The real
@@ -32,7 +32,14 @@ match:
32
32
  # concealment; only "do not ask the
33
33
  # user." ending the sentence is)
34
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|(?:do\s+not|don[''’]t|never|must\s+not|should\s+not)\s+(?:(?:ever|even|actually)\s+)?(?:mention|list|include|note|document|describe|report|record|log|disclose|reveal|call\s+out)\s+(?:it|this|that|these|them|the\s+(?:change|changes|addition|code|line|lines|call|helper|snippet|file|step))\s+(?:in|from|on|to)\s+(?:your|the|any)\s+(?:summary|response|reply|answer|output|message|description|commit\s+messages?|changelog|diff|PR|review|report|notes?)\b|without\s+(?:mentioning|listing|noting|documenting|reporting|describing|including)\s+(?:it|this|that|the\s+(?:change|changes|addition|code|call))\b)|(?<!(?:\bnot|\bnever|n[''’]t)\s+)\b(?:quietly|silently|secretly|covertly|discreetly)\s+(?:add|insert|inject|append|include|embed|put|install|create)\b)'
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|(?:do\s+not|don[''’]t|never|must\s+not|should\s+not)\s+(?:(?:ever|even|actually)\s+)?(?:mention|list|include|note|document|describe|report|record|log|disclose|reveal|call\s+out)\s+(?:it|this|that|these|them|the\s+(?:change|changes|addition|code|line|lines|call|helper|snippet|file|step))\s+(?:in|from|on|to)\s+(?:your|the|any)\s+(?:summary|response|reply|answer|output|message|description|commit\s+messages?|changelog|diff|PR|review|report|notes?)\b|without\s+(?:mentioning|listing|noting|documenting|reporting|describing|including)\s+(?:it|this|that|the\s+(?:change|changes|addition|code|call))\b)|(?:(?=\b(?:this|that|it|these|those|all|just|between|there|no|nobody|leave|keep|kept|omit|scrub|strip|erase|purge|do|don|never|must|mustn|should|shouldn|not|say|tell|mention|hide|the|users?|humans?|developers?|owners?|operators?|go|going|everything)\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})(?:(?:this|that|it|these|those|all\s+of\s+this)(?:\s+(?:changes?|edits?|steps?|files?))?\s+(?:stays?|remains?|should\s+stay|must\s+stay|is\s+to\s+stay)\s+(?:just\s+)?between\s+(?:us|you\s+and\s+me|me\s+and\s+you|the\s+two\s+of\s+us)\b|(?:just\s+)?between\s+(?:us|you\s+and\s+me|me\s+and\s+you|the\s+two\s+of\s+us)(?=\s*(?:[.!;,)\]"''`]|\n|$))|(?:there(?:[''’]s|\s+is)\s+)?no\s+need\s+to\s+(?:(?:mention|tell|say|report|flag|surface|note|log|document|list|include|disclose|reveal|inform|notify)\s+(?:(?:it|this|that|these|those|them)|(?:the\s+|your\s+)?(?:users?|humans?|developers?|owners?|operators?|anyone|anybody))|bring\s+(?:it|this|that|these|those|them)\s+up|let\s+(?:the\s+|your\s+)?(?:users?|humans?|developers?|owners?|operators?|anyone|anybody)\s+know)\b(?:(?=\s*(?:[.!;,)\]"''`]|\n|$|\*/))|\s+(?:to|with)\s+(?:the\s+|your\s+)?(?:users?|humans?|developers?|owners?|operators?|anyone|anybody)\b|\s+(?:in|from|on)\s+(?:your|the|any)\s+(?:summary|summaries|response|reply|answer|output|message|description|commit\s+messages?|changelog|diff|PR|review|report|notes?|logs?|history)\b|\s+about\s+(?:it|this|that|these|those|them)\b)|(?:leave|keep|kept)\s+(?:it|this|that|these|those|them)\s+out\s+(?:of|from)\s+(?:your|the|any)\s+(?:summary|summaries|response|reply|answer|output|message|description|commit\s+messages?|changelog|diff|PR|review|report|notes?|logs?|history)\b|omit\s+(?:it|this|that|these|those|them)\s+from\s+(?:your|the|any)\s+(?:summary|summaries|response|reply|answer|output|message|description|commit\s+messages?|changelog|diff|PR|review|report|notes?|logs?|history)\b|(?:scrub|strip|erase|purge)\s+(?:(?:it|this|that|these|those|them)|any\s+(?:mention|trace)s?\s+of\s+(?:it|this|that|these|those|them))\s+from\s+(?:your|the|any)\s+(?:summary|summaries|response|reply|answer|output|message|description|commit\s+messages?|changelog|diff|PR|review|report|notes?|logs?|history)\b|leave\s+no\s+trace\b|(?:do\s+not|don[''’]t|never|must\s+not|mustn[''’]t|should\s+not|shouldn[''’]t)\s+(?:(?:ever|even|actually)\s+)?(?:bring\s+(?:it|this|that|these|those|them)\s+up(?:(?=\s*(?:[.!;,)\]"''`]|\n|$|\*/))|\s+(?:to|with)\s+(?:the\s+|your\s+)?(?:users?|humans?|developers?|owners?|operators?|anyone|anybody)\b|\s+(?:in|from|on)\s+(?:your|the|any)\s+(?:summary|summaries|response|reply|answer|output|message|description|commit\s+messages?|changelog|diff|PR|review|report|notes?|logs?|history)\b)|breathe\s+a\s+word\b|(?:put|write|add|record|surface|flag|highlight|expose|log|file|list)\s+(?:it|this|that|these|those|them)\b(?:\s+(?:to|with)\s+(?:the\s+|your\s+)?(?:users?|humans?|developers?|owners?|operators?|anyone|anybody)\b|\s+(?:in|from|on)\s+(?:your|the|any)\s+(?:summary|summaries|response|reply|answer|output|message|description|commit\s+messages?|changelog|diff|PR|review|report|notes?|logs?|history)\b)|(?:tell|inform|notify|alert|warn)\s+(?:the\s+|your\s+)?(?:reviewers?|maintainers?|team|code\s+owners?)\b(?:(?=\s*(?:[.!;,)\]"''`]|\n|$|\*/))|\s+(?:about|of)\s+(?:it|this|that|these|those|them)\b))|keep\s+(?:quiet|silent)\s+about\s+(?:it|this|that|these|those|them)\b|keep\s+(?:it|this|that|these|those|them)\s+(?:under\s+wraps|off\s+the\s+record|to\s+yourself|low[- ]key)\b|keep\s+(?:these|those|the)\s+(?:changes?|edits?|steps?|files?)\s+(?:quiet|secret|hidden|under\s+wraps|between\s+us)\b|(?:this|that|it|everything|all\s+of\s+this)\s+(?:is|stays?|remains?|should\s+stay|must\s+stay|goes)\s+off\s+the\s+record\b|(?:go|going)\s+off\s+the\s+record\b|not\s+a\s+word\s+(?:of\s+(?:this|it)|about\s+(?:it|this|that)|to\s+(?:the\s+|your\s+)?(?:users?|humans?|developers?|owners?|operators?|anyone|anybody))\b|(?:say|tell|mention)\s+nothing\s+(?:about\s+(?:it|this|that)|to\s+(?:the\s+|your\s+)?(?:users?|humans?|developers?|owners?|operators?|anyone|anybody))\b|hide\s+(?:(?:them|(?:these|those|the)\s+(?:changes?|edits?|files?|steps?|additions?))\s+from\s+(?:the|your|any)\s+(?:users?|humans?|developers?|owners?|operators?|reviewers?|review|summary|commit\s+messages?|diff|changelog|PR)|(?:it|this|that)\s+from\s+(?:the|your|any)\s+(?:reviewers?|review|summary|commit\s+messages?|diff|changelog|PR))\b|(?:the\s+)?(?:users?|humans?|developers?|owners?|operators?)\s+(?:does\s+not|doesn[''’]t|do\s+not|don[''’]t|needn[''’]t|need\s+not|will\s+not|won[''’]t|should\s+not|shouldn[''’]t)\s+(?:need\s+to\s+)?(?:know|see|hear)(?:\s+(?:about|of)\s+(?:it|this|that|these|those|them)\b|(?=\s*(?:[.!;,)\]"''`]|\n|$|\*/)))|(?:nobody|no\s+one|no\s+human)\s+(?:needs|has|should\s+need)\s+to\s+(?:know|see|hear)(?:\s+(?:about|of)\s+(?:it|this|that)\b|(?=\s*(?:[.!;,)\]"''`]|\n|$|\*/)))))|no\s+(?:se\s+lo\s+|le\s+|se\s+|lo\s+)?(?:digas|menciones|cuentes|informes|avises|reveles)\s+(?:esto\s+|eso\s+|nada\s+)?(?:al|a\s+el|a\s+la)\s+(?:usuari[oa]|desarrollador[a]?|humano)|sin\s+(?:avisar|informar|notificar|decirle|decírselo|decirselo)\s+(?:al|a\s+la)\s+usuari[oa]|mant[eé]n(?:lo|la)?\s+(?:esto\s+|eso\s+)?en\s+secreto|ne\s+(?:le\s+|la\s+|lui\s+|en\s+)?(?:dis|dites|mentionne|mentionnez|révèle|révélez|informe|informez|signale|signalez)\s+pas\s+(?:cela\s+|ça\s+|ceci\s+)?(?:à|a|au)\s+(?:l[''’]|la\s+|le\s+)?(?:utilisateur|développeur|developpeur|humain)|sans\s+(?:en\s+|le\s+|lui\s+)?(?:informer|avertir|prévenir|prevenir|dire|parler)\s+(?:à\s+|a\s+)?l[''’]utilisateur|gardez?\s+(?:cela|ça|ceci)\s+secret|(?:sag|sage|sagen\s+sie|erz[äa]hl|erz[äa]hle|erw[äa]hn|erw[äa]hne|informiere)\s+(?:es\s+|das\s+|dies\s+)?(?:dem|den)\s+(?:benutzer|nutzer|entwickler)n?\s+(?:nichts|nicht)|ohne\s+(?:den|dem)\s+(?:benutzer|nutzer|entwickler)n?\s+(?:zu\s+informieren|zu\s+benachrichtigen|bescheid\s+zu\s+sagen)|halte?\s+(?:das|dies|es)\s+geheim|n[ãa]o\s+(?:conte|diga|mencione|informe|avise|revele)\s+(?:isso\s+|isto\s+|nada\s+)?(?:ao|para\s+o)\s+(?:usu[áa]rio|utilizador|desenvolvedor)|sem\s+(?:avisar|informar|contar|dizer)\s+(?:ao|o)\s+(?:usu[áa]rio|utilizador)|mantenha\s+(?:isso|isto)\s+em\s+segredo|non\s+(?:dirlo|dirgli|dire|menzionarlo|menzionare|informare|avvisare|avvertire|rivelare)\s+(?:questo\s+|nulla\s+)?(?:all[''’]|al\s+|l[''’]|il\s+)(?:utente|sviluppatore)|senza\s+(?:dirlo|avvisare|informare|avvertire)\s+(?:all[''’]|l[''’])utente|tieni\s+(?:questo|ciò|cio)\s+segreto|(?:不要|别|切勿|请勿|勿)(?:告诉|告知|通知|提醒)(?:用户|使用者|开发者|人类)|瞒着用户|对用户保密|不要让用户知道|(?:不要|不能|勿)(?:向|对)(?:用户|使用者)(?:透露|提及|说明)|ユーザー(?:に|には|へ)(?:は)?(?:絶対に)?(?:言わ|伝え|知らせ|教え|報告し)(?:ない|ず|ません)|ユーザーに(?:は)?(?:内緒|秘密)|ユーザーに(?:気づか|知ら)れ(?:ない|ず)|사용자(?:에게|한테)(?:는)?\s*(?:말하지|알리지|알려주지)\s*(?:마|말|않)|사용자\s*몰래|사용자에게\s*(?:비밀|숨기)|не\s+(?:говори|говорите|сообщай|сообщайте|рассказывай|рассказывайте|упоминай|упоминайте)\s+(?:об\s+этом\s+|этого\s+|это\s+)?(?:пользовател[юя]|разработчик[уа])|без\s+(?:ведома|уведомления)\s+пользователя|держи(?:те)?\s+это\s+в\s+секрете|скрой(?:те)?\s+это\s+от\s+пользователя|(?<!(?:\bnot|\bnever|n[''’]t)\s+)\b(?:quietly|silently|secretly|covertly|discreetly)\s+(?:add|insert|inject|append|include|embed|put|install|create)\b)'
36
+ # m19-scan (SN-5): in an instruction file an order to the agent and a concealment
37
+ # anywhere in the same file are reported. For these paths the look-behind of the
38
+ # regex (an order word within 300 characters, in the same paragraph) is replaced by
39
+ # an order word anywhere else in the file (`order_regex`). Other files keep the window.
40
+ wide_paths:
41
+ - '(^|/)(\.kiro/steering/.+|AGENTS\.md|CLAUDE\.md|GEMINI\.md|CONTRIBUTING\.md|\.cursorrules|\.clinerules(/.+)?|\.github/copilot-instructions\.md)$'
42
+ order_regex: '\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'
36
43
  # A phrase in quotation marks that closes right after it, in a passage that
37
44
  # warns about it or quotes it as an example, is not an order.
38
45
  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)'
@@ -0,0 +1,37 @@
1
+ id: EX-075
2
+ title: An instruction file tells the agent to do something unrelated to the code
3
+ severity: medium
4
+ applies_to:
5
+ - instruction
6
+ - docs
7
+ # Only the files an agent takes as its instructions: steering files, AGENTS.md,
8
+ # CLAUDE.md, GEMINI.md, CONTRIBUTING.md, .cursorrules, .clinerules and
9
+ # .github/copilot-instructions.md (m19-scan, SN-7).
10
+ only_paths:
11
+ - '(^|/)(\.kiro/steering/.+|AGENTS\.md|CLAUDE\.md|GEMINI\.md|CONTRIBUTING\.md|\.cursorrules|\.clinerules(/.+)?|\.github/copilot-instructions\.md)$'
12
+ match:
13
+ # An order that has nothing to do with building, testing or linting the code,
14
+ # reported even when nothing hides it (L-054, a plain order that does not hide
15
+ # itself). Four families:
16
+ # 1. a marker or flag file, a file outside the task (a dotfile in the root, a
17
+ # shell startup file, audit logs, the git folder);
18
+ # 2. skipping, disabling or weakening a test or a check ("do not skip tests"
19
+ # and "never disable the lint check" are quiet);
20
+ # 3. running a quoted command whose first word is not a build, test or lint
21
+ # tool, or a quoted command that downloads, pipes into a shell or deletes;
22
+ # 4. fetching a URL.
23
+ # Quiet on purpose: "run `pnpm test` before you commit", "add a test for every
24
+ # bug you fix", "use `npm ci` in CI", and a link to the project's own docs.
25
+ regex: '\b(?:create|write|touch|drop|leave|place)\s+(?:an?\s+|the\s+)?(?:(?:empty|new|small|hidden|marker|flag|sentinel)\s+)*(?:marker|flag|sentinel|stamp|canary|beacon)\s+file\b|\b(?:create|write|touch)\s+(?:an?\s+|the\s+)?(?:(?:empty|new)\s+)?(?:file\s+)?(?:named\s+|called\s+)?[''"`]?\.(?!(?:gitignore|gitattributes|editorconfig|env\.example|prettierrc|eslintrc|nvmrc|github|vscode|kiro)\b)[a-z][\w-]*|\b(?:delete|remove|erase|wipe)\s+(?:the\s+|all\s+|any\s+)?(?:\.git\b|\.exorcist|\.kiro|audit\s+logs?|log\s+files?|git\s+history|lockfiles?|\.env\b)|\b(?:edit|modify|change|overwrite|append\s+to)\s+(?:the\s+|your\s+|my\s+)?(?:~/\.[\w./-]+|\.bashrc|\.zshrc|\.gitconfig|\.ssh/\S+|/etc/\S+|\.git/hooks\S*)|(?<!(?:\bnot|\bnever|n[''’]t|\bavoid|\bnor|\bwithout)\s+)\b(?:skip|disable|weaken|bypass|turn\s+off|comment\s+out|silence)\s+(?:(?:the|any|all|failing|flaky|these|those)\s+)*(?:tests?|checks?|lint(?:ing)?|linters?|ci|hooks?|pre-commit|type\s*checks?|typecheck|test\s+suite)\b|\b(?:run|execute|invoke)\s+(?:the\s+(?:command|script)\s+)?`(?!(?:pnpm|npm|yarn|bun|npx|pnpx|bunx|node|tsc|tsx|vitest|jest|eslint|prettier|make|cargo|go|pytest|python3?|pip|uv|git|ruby|bundle|rake|mvn|gradle|dotnet|deno|biome|ruff|mypy|black|flake8|rustfmt|clippy|exorcist|dig|host|nslookup|ping|jq|ls|cat|echo|pwd|which|uname|date|\./(?:scripts|bin)/[\w.-]*(?:build|test|lint|format|check|setup|bootstrap|dev|install))\b)[^`\n]+`|\b(?:run|execute|invoke)\s+(?:the\s+(?:command|script)\s+)?`[^`\n]*(?:\bcurl\b|\bwget\b|\|\s*(?:ba|z)?sh\b|\brm\s+-rf?\b|\bsudo\b|\bnc\b|\bchmod\b)[^`\n]*`|\b(?:fetch|download|retrieve)\s+(?:the\s+(?:file|page|script|content|contents|rules)\s+(?:at|from)\s+|from\s+)?[''"`<(]?https?://|\b(?:curl|wget)\b[^\n]{0,80}https?://[^\n]*(?:\|\s*(?:ba|z)?sh\b|\s-o\b|\s-O\b|\s>\s|--output\b)'
26
+ owasp:
27
+ - "ASI02 Inadequate Human-in-the-Loop Controls"
28
+ - "ASI03 Prompt Injection via External Content"
29
+ - "LLM06:2025 Excessive Agency"
30
+ fix: >
31
+ Check why this instruction file asks the agent for something that is not
32
+ about building, testing or linting the code: a marker or flag file, skipping
33
+ or weakening a test or check, running a command that is not a build, test or
34
+ lint command, or fetching a URL. If it is needed, write it as a script a
35
+ person runs, or ask the agent to report to you first. If it is not yours,
36
+ remove it. A file the agent reads should not give it jobs that change files
37
+ outside the task or reach the network.
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 = resolve10.call(this, root, ref);
7086
+ let _sch = resolve11.call(this, root, ref);
7087
7087
  if (_sch === void 0) {
7088
7088
  const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
7089
7089
  const { schemaId } = this.opts;
@@ -7110,7 +7110,7 @@ var require_compile = __commonJS({
7110
7110
  function sameSchemaEnv(s1, s2) {
7111
7111
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
7112
7112
  }
7113
- function resolve10(root, ref) {
7113
+ function resolve11(root, ref) {
7114
7114
  let sch;
7115
7115
  while (typeof (sch = this.refs[ref]) == "string")
7116
7116
  ref = sch;
@@ -7974,7 +7974,7 @@ var require_fast_uri = __commonJS({
7974
7974
  }
7975
7975
  return uri;
7976
7976
  }
7977
- function resolve10(baseURI, relativeURI, options) {
7977
+ function resolve11(baseURI, relativeURI, options) {
7978
7978
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
7979
7979
  const {
7980
7980
  parsed: baseParsed,
@@ -8010,50 +8010,50 @@ var require_fast_uri = __commonJS({
8010
8010
  schemelessOptions.skipEscape = true;
8011
8011
  return serialize(resolved, schemelessOptions);
8012
8012
  }
8013
- function resolveComponent(base, relative7, options, skipNormalization) {
8013
+ function resolveComponent(base, relative8, options, skipNormalization) {
8014
8014
  const target = {};
8015
8015
  if (!skipNormalization) {
8016
8016
  base = parse4(serialize(base, options), options);
8017
- relative7 = parse4(serialize(relative7, options), options);
8017
+ relative8 = parse4(serialize(relative8, options), options);
8018
8018
  }
8019
8019
  options = options || {};
8020
- if (!options.tolerant && relative7.scheme) {
8021
- target.scheme = relative7.scheme;
8022
- target.userinfo = relative7.userinfo;
8023
- target.host = relative7.host;
8024
- target.port = relative7.port;
8025
- target.path = removeDotSegments(relative7.path || "");
8026
- target.query = relative7.query;
8020
+ if (!options.tolerant && relative8.scheme) {
8021
+ target.scheme = relative8.scheme;
8022
+ target.userinfo = relative8.userinfo;
8023
+ target.host = relative8.host;
8024
+ target.port = relative8.port;
8025
+ target.path = removeDotSegments(relative8.path || "");
8026
+ target.query = relative8.query;
8027
8027
  } else {
8028
- if (relative7.userinfo !== void 0 || relative7.host !== void 0 || relative7.port !== void 0) {
8029
- target.userinfo = relative7.userinfo;
8030
- target.host = relative7.host;
8031
- target.port = relative7.port;
8032
- target.path = removeDotSegments(relative7.path || "");
8033
- target.query = relative7.query;
8028
+ if (relative8.userinfo !== void 0 || relative8.host !== void 0 || relative8.port !== void 0) {
8029
+ target.userinfo = relative8.userinfo;
8030
+ target.host = relative8.host;
8031
+ target.port = relative8.port;
8032
+ target.path = removeDotSegments(relative8.path || "");
8033
+ target.query = relative8.query;
8034
8034
  } else {
8035
- if (!relative7.path) {
8035
+ if (!relative8.path) {
8036
8036
  target.path = base.path;
8037
- if (relative7.query !== void 0) {
8038
- target.query = relative7.query;
8037
+ if (relative8.query !== void 0) {
8038
+ target.query = relative8.query;
8039
8039
  } else {
8040
8040
  target.query = base.query;
8041
8041
  }
8042
8042
  } else {
8043
- if (relative7.path[0] === "/") {
8044
- target.path = removeDotSegments(relative7.path);
8043
+ if (relative8.path[0] === "/") {
8044
+ target.path = removeDotSegments(relative8.path);
8045
8045
  } else {
8046
8046
  const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
8047
8047
  if (baseHasAuthority && !base.path) {
8048
- target.path = "/" + relative7.path;
8048
+ target.path = "/" + relative8.path;
8049
8049
  } else if (!base.path) {
8050
- target.path = relative7.path;
8050
+ target.path = relative8.path;
8051
8051
  } else {
8052
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative7.path;
8052
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative8.path;
8053
8053
  }
8054
8054
  target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
8055
8055
  }
8056
- target.query = relative7.query;
8056
+ target.query = relative8.query;
8057
8057
  }
8058
8058
  target.userinfo = base.userinfo;
8059
8059
  target.host = base.host;
@@ -8061,7 +8061,7 @@ var require_fast_uri = __commonJS({
8061
8061
  }
8062
8062
  target.scheme = base.scheme;
8063
8063
  }
8064
- target.fragment = relative7.fragment;
8064
+ target.fragment = relative8.fragment;
8065
8065
  return target;
8066
8066
  }
8067
8067
  function equal(uriA, uriB, options) {
@@ -8365,7 +8365,7 @@ var require_fast_uri = __commonJS({
8365
8365
  var fastUri = {
8366
8366
  SCHEMES,
8367
8367
  normalize: normalize3,
8368
- resolve: resolve10,
8368
+ resolve: resolve11,
8369
8369
  resolveComponent,
8370
8370
  equal,
8371
8371
  serialize,
@@ -11810,14 +11810,14 @@ var init_severity_paths = __esm({
11810
11810
 
11811
11811
  // ../core/src/walker.ts
11812
11812
  import { opendir, stat, open, realpath } from "node:fs/promises";
11813
- import { join as join5, relative as relative2, extname, basename as basename2, isAbsolute as isAbsolute3 } from "node:path";
11813
+ import { join as join5, relative as relative3, extname, basename as basename3, isAbsolute as isAbsolute3 } from "node:path";
11814
11814
  function isAgentFacing(rel, role) {
11815
11815
  if (!AGENT_FACING_ROLES.has(role)) return false;
11816
11816
  return !(role === "config" && LOCKFILE_NAMES.has(rel.split("/").pop() ?? ""));
11817
11817
  }
11818
11818
  function classifyFile(rel) {
11819
11819
  const norm = rel.replace(/\\/g, "/");
11820
- const base = basename2(norm);
11820
+ const base = basename3(norm);
11821
11821
  const ext = extname(norm).toLowerCase();
11822
11822
  if (base === "AGENTS.md" || base === "AGENT.md" || base === "CLAUDE.md" || base === "CLAUDE.local.md" || base === "GEMINI.md" || base === ".cursorrules" || base === ".windsurfrules" || base === ".clinerules" || norm.startsWith(".clinerules/") || norm.startsWith(".cursor/rules/") || norm.startsWith(".windsurf/rules/") || norm.startsWith(".amazonq/rules/") || norm === ".github/copilot-instructions.md" || norm.startsWith(".github/instructions/") || norm.startsWith(".github/prompts/") || /^\.claude\/(commands|agents|skills)\//.test(norm) || base === "SKILL.md" || base === "POWER.md" || /^power\/(?:[^/]+\/)*steering\/[^/]+$/.test(norm) || base.startsWith("README") || norm.startsWith(".kiro/steering/")) return "instruction";
11823
11823
  if (/^power\/(?:[^/]+\/)*mcp\.json$/.test(norm) || norm.endsWith(".kiro/settings/mcp.json") || norm.endsWith(".cursor/mcp.json") || norm.endsWith(".vscode/mcp.json") || norm.endsWith(".amazonq/mcp.json") || norm.endsWith(".gemini/settings.json") || norm.endsWith(".claude/settings.json") || norm.endsWith(".claude/settings.local.json") || norm === "mcp.json" || norm === ".mcp.json" || base === "claude_desktop_config.json") return "mcp-config";
@@ -11861,7 +11861,7 @@ async function* walkPathsIn(root, dir) {
11861
11861
  }
11862
11862
  for await (const entry of dh) {
11863
11863
  const absPath = join5(dir, entry.name);
11864
- const rel = relative2(root, absPath).replace(/\\/g, "/");
11864
+ const rel = relative3(root, absPath).replace(/\\/g, "/");
11865
11865
  if (entry.isDirectory()) {
11866
11866
  if (SKIP_DIRS.has(entry.name)) continue;
11867
11867
  yield { rel, isDirectory: true };
@@ -11886,7 +11886,7 @@ async function* fileRecord(ctx2, rel, readPath, size, link) {
11886
11886
  }
11887
11887
  if (size > ctx2.maxFileSize) {
11888
11888
  if (!agent) {
11889
- if (!TRUNCATE_ROLES.has(role) || LOCKFILE_NAMES.has(basename2(rel))) {
11889
+ if (!TRUNCATE_ROLES.has(role) || LOCKFILE_NAMES.has(basename3(rel))) {
11890
11890
  ctx2.note({ kind: "skipped", rel, reason: "too large", agentFacing: false });
11891
11891
  return;
11892
11892
  }
@@ -11917,14 +11917,14 @@ async function* walkDir(ctx2, dir, realDir, chain, isRoot = false) {
11917
11917
  dh = await opendir(dir);
11918
11918
  } catch (err2) {
11919
11919
  if (isRoot) throw err2;
11920
- const rel = relative2(ctx2.root, dir).replace(/\\/g, "/");
11920
+ const rel = relative3(ctx2.root, dir).replace(/\\/g, "/");
11921
11921
  ctx2.note({ kind: "unreadable", rel, reason: reasonOf(err2), agentFacing: true });
11922
11922
  return;
11923
11923
  }
11924
11924
  try {
11925
11925
  for await (const entry of dh) {
11926
11926
  const absPath = join5(dir, entry.name);
11927
- const rel = relative2(ctx2.root, absPath).replace(/\\/g, "/");
11927
+ const rel = relative3(ctx2.root, absPath).replace(/\\/g, "/");
11928
11928
  if (entry.isDirectory()) {
11929
11929
  if (SKIP_DIRS.has(entry.name)) continue;
11930
11930
  const real = join5(realDir, entry.name);
@@ -11964,7 +11964,7 @@ async function* walkDir(ctx2, dir, realDir, chain, isRoot = false) {
11964
11964
  }
11965
11965
  }
11966
11966
  } catch (err2) {
11967
- const rel = relative2(ctx2.root, dir).replace(/\\/g, "/");
11967
+ const rel = relative3(ctx2.root, dir).replace(/\\/g, "/");
11968
11968
  ctx2.note({ kind: "unreadable", rel, reason: reasonOf(err2), agentFacing: true });
11969
11969
  }
11970
11970
  }
@@ -12006,7 +12006,7 @@ var init_walker = __esm({
12006
12006
  ".nyc_output"
12007
12007
  ]);
12008
12008
  isInside = (root, target) => {
12009
- const rel = relative2(root, target);
12009
+ const rel = relative3(root, target);
12010
12010
  return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
12011
12011
  };
12012
12012
  TRUNCATE_ROLES = /* @__PURE__ */ new Set(["docs", "code", "config", "manifest"]);
@@ -20575,7 +20575,7 @@ var Protocol = class {
20575
20575
  return;
20576
20576
  }
20577
20577
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
20578
- await new Promise((resolve10) => setTimeout(resolve10, pollInterval));
20578
+ await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
20579
20579
  options?.signal?.throwIfAborted();
20580
20580
  }
20581
20581
  } catch (error2) {
@@ -20592,7 +20592,7 @@ var Protocol = class {
20592
20592
  */
20593
20593
  request(request, resultSchema, options) {
20594
20594
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
20595
- return new Promise((resolve10, reject2) => {
20595
+ return new Promise((resolve11, reject2) => {
20596
20596
  const earlyReject = (error2) => {
20597
20597
  reject2(error2);
20598
20598
  };
@@ -20670,7 +20670,7 @@ var Protocol = class {
20670
20670
  if (!parseResult.success) {
20671
20671
  reject2(parseResult.error);
20672
20672
  } else {
20673
- resolve10(parseResult.data);
20673
+ resolve11(parseResult.data);
20674
20674
  }
20675
20675
  } catch (error2) {
20676
20676
  reject2(error2);
@@ -20932,12 +20932,12 @@ var Protocol = class {
20932
20932
  }
20933
20933
  } catch {
20934
20934
  }
20935
- return new Promise((resolve10, reject2) => {
20935
+ return new Promise((resolve11, reject2) => {
20936
20936
  if (signal.aborted) {
20937
20937
  reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
20938
20938
  return;
20939
20939
  }
20940
- const timeoutId = setTimeout(resolve10, interval);
20940
+ const timeoutId = setTimeout(resolve11, interval);
20941
20941
  signal.addEventListener("abort", () => {
20942
20942
  clearTimeout(timeoutId);
20943
20943
  reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -22078,7 +22078,7 @@ var McpServer = class {
22078
22078
  let task = createTaskResult.task;
22079
22079
  const pollInterval = task.pollInterval ?? 5e3;
22080
22080
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
22081
- await new Promise((resolve10) => setTimeout(resolve10, pollInterval));
22081
+ await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
22082
22082
  const updatedTask = await extra.taskStore.getTask(taskId);
22083
22083
  if (!updatedTask) {
22084
22084
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -22742,12 +22742,12 @@ var StdioServerTransport = class {
22742
22742
  this.onclose?.();
22743
22743
  }
22744
22744
  send(message) {
22745
- return new Promise((resolve10) => {
22745
+ return new Promise((resolve11) => {
22746
22746
  const json2 = serializeMessage(message);
22747
22747
  if (this._stdout.write(json2)) {
22748
- resolve10();
22748
+ resolve11();
22749
22749
  } else {
22750
- this._stdout.once("drain", resolve10);
22750
+ this._stdout.once("drain", resolve11);
22751
22751
  }
22752
22752
  });
22753
22753
  }
@@ -22759,7 +22759,7 @@ import { homedir as homedir6 } from "node:os";
22759
22759
  import { delimiter } from "node:path";
22760
22760
 
22761
22761
  // src/tools.ts
22762
- import { existsSync as existsSync4, readFileSync as readFileSync7, realpathSync as realpathSync3, statSync as statSync6 } from "node:fs";
22762
+ import { existsSync as existsSync5, readFileSync as readFileSync7, realpathSync as realpathSync4, statSync as statSync6 } from "node:fs";
22763
22763
  import { fileURLToPath as fileURLToPath2 } from "node:url";
22764
22764
 
22765
22765
  // ../shield/src/canonical.ts
@@ -22788,11 +22788,52 @@ init_zod();
22788
22788
 
22789
22789
  // ../shield/src/userkey.ts
22790
22790
  import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
22791
- import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, writeSync } from "node:fs";
22791
+ import { closeSync, constants, existsSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, writeSync } from "node:fs";
22792
22792
  import { homedir } from "node:os";
22793
- import { isAbsolute, join } from "node:path";
22793
+ import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
22794
22794
  var KEY_FILE = "shield.key";
22795
22795
  var IS_WINDOWS = process.platform === "win32";
22796
+ function userDirOverrideProblem(dir, cwd = process.cwd()) {
22797
+ const real = (p) => {
22798
+ let cur = resolve(p);
22799
+ let rest = "";
22800
+ for (let i = 0; i < 64; i++) {
22801
+ try {
22802
+ return join(realpathSync.native(cur), rest);
22803
+ } catch {
22804
+ }
22805
+ const up = dirname(cur);
22806
+ if (up === cur) break;
22807
+ rest = join(basename(cur), rest);
22808
+ cur = up;
22809
+ }
22810
+ return resolve(p);
22811
+ };
22812
+ const fold2 = (p) => process.platform === "darwin" || IS_WINDOWS ? p.toLowerCase() : p;
22813
+ const d = fold2(real(dir));
22814
+ const c = fold2(real(cwd));
22815
+ if (d === fold2(real(join(homedir(), ".config", "exorcist-98")))) return null;
22816
+ const rel = relative(c, d);
22817
+ if (rel === "" || !rel.startsWith("..") && !isAbsolute(rel)) return "it is inside the current project folder";
22818
+ for (let cur = d, i = 0; i < 64; i++) {
22819
+ if (existsSync(join(cur, ".git"))) return `it is inside a git repository (${cur})`;
22820
+ const up = dirname(cur);
22821
+ if (up === cur) break;
22822
+ cur = up;
22823
+ }
22824
+ let st;
22825
+ try {
22826
+ st = lstatSync(dir);
22827
+ } catch {
22828
+ return null;
22829
+ }
22830
+ if (st.isSymbolicLink()) return "it is a symbolic link";
22831
+ if (!st.isDirectory()) return "it is not a folder";
22832
+ const me = uid();
22833
+ if (!IS_WINDOWS && me !== void 0 && st.uid !== me) return "it is not owned by you";
22834
+ if (!IS_WINDOWS && (st.mode & 63) !== 0) return "other users or your group can open it (a private folder is mode 0700)";
22835
+ return null;
22836
+ }
22796
22837
  function userConfigDir(env = process.env) {
22797
22838
  const o = env["EXORCIST_USER_DIR"];
22798
22839
  if (o && isAbsolute(o)) return o;
@@ -22800,6 +22841,14 @@ function userConfigDir(env = process.env) {
22800
22841
  const base = xdg && isAbsolute(xdg) ? xdg : join(homedir(), ".config");
22801
22842
  return join(base, "exorcist-98");
22802
22843
  }
22844
+ function userDirRefusal(env = process.env, cwd = process.cwd()) {
22845
+ const o = env["EXORCIST_USER_DIR"];
22846
+ const xdg = env["XDG_CONFIG_HOME"];
22847
+ const overridden = o && isAbsolute(o) || xdg && isAbsolute(xdg);
22848
+ if (!overridden) return null;
22849
+ const problem = userDirOverrideProblem(userConfigDir(env), cwd);
22850
+ return problem === null ? null : `the user-level folder ${userConfigDir(env)} (set by EXORCIST_USER_DIR or XDG_CONFIG_HOME) was refused: ${problem}`;
22851
+ }
22803
22852
  var uid = () => typeof process.getuid === "function" ? process.getuid() : void 0;
22804
22853
  function ensurePrivateDir(dir) {
22805
22854
  try {
@@ -22842,6 +22891,10 @@ function readKeyFile(path) {
22842
22891
  }
22843
22892
  var cache = /* @__PURE__ */ new Map();
22844
22893
  function getUserKey(o = {}) {
22894
+ if (o.dir === void 0) {
22895
+ const refused = userDirRefusal();
22896
+ if (refused !== null) return { ok: false, error: refused };
22897
+ }
22845
22898
  const dir = o.dir ?? userConfigDir();
22846
22899
  const cached2 = cache.get(dir);
22847
22900
  if (cached2) return { ok: true, key: cached2 };
@@ -22954,7 +23007,13 @@ var PolicySchema = external_exports.object({
22954
23007
  * opt-in that only the USER-LEVEL policy can set. A project policy, signed or not,
22955
23008
  * that asks for it is ignored with a note.
22956
23009
  */
22957
- sessionRelease: external_exports.enum(["os", "terminal", "notification-code"]).optional()
23010
+ sessionRelease: external_exports.enum(["os", "terminal", "notification-code"]).optional(),
23011
+ /**
23012
+ * The event log (m19-log, LG-2). `off` stops the Shield writing events after one final event that says so.
23013
+ * Only the USER-LEVEL policy can set it: a project policy that sets `events` is ignored with a note, and the
23014
+ * environment variable EXORCIST_EVENTS is ignored (an MCP config can set a server's environment).
23015
+ */
23016
+ events: external_exports.enum(["on", "off"]).optional()
22958
23017
  }).strict();
22959
23018
 
22960
23019
  // ../shield/src/approval.ts
@@ -26265,7 +26324,13 @@ var MatchSchema = external_exports.object({
26265
26324
  max_length: external_exports.number().int().min(1),
26266
26325
  classes: external_exports.array(external_exports.string()).min(1),
26267
26326
  severity: external_exports.enum(["critical", "high", "medium", "low"])
26268
- }).optional()
26327
+ }).optional(),
26328
+ // regex only: for a file whose path matches one of these patterns, the look-behinds of the regex (the order a
26329
+ // concealment must follow within 300 characters of one paragraph) are dropped and replaced by this: an order word
26330
+ // (`order_regex`) anywhere else in the file. Used for instruction files, where an order and its concealment may be
26331
+ // far apart (m19-scan SN-5). Both are needed for the wide reading.
26332
+ wide_paths: external_exports.array(external_exports.string().refine(compiles, "wide_paths entries must be valid regular expressions")).optional(),
26333
+ order_regex: external_exports.string().optional()
26269
26334
  }).superRefine((val, ctx2) => {
26270
26335
  const hasAny = val.regex !== void 0 || val.unicode_class !== void 0 && val.unicode_class.length > 0 || val.json_path !== void 0 || val.hidden_text === true || val.analysis !== void 0;
26271
26336
  if (!hasAny) {
@@ -26283,7 +26348,7 @@ var MatchSchema = external_exports.object({
26283
26348
  if ((val.exclude_regex !== void 0 || val.validate !== void 0) && val.regex === void 0 && val.json_path === void 0) {
26284
26349
  ctx2.addIssue({ code: external_exports.ZodIssueCode.custom, message: "match.exclude_regex and match.validate need match.regex or match.json_path" });
26285
26350
  }
26286
- for (const key of ["regex", "value_regex", "exclude_regex", "file_regex", "quoted_example_cues", "negated_cues", "decoded_flag_regex"]) {
26351
+ for (const key of ["regex", "value_regex", "exclude_regex", "file_regex", "quoted_example_cues", "negated_cues", "decoded_flag_regex", "order_regex"]) {
26287
26352
  const pattern = val[key];
26288
26353
  if (pattern !== void 0 && !compiles(pattern)) {
26289
26354
  ctx2.addIssue({
@@ -26296,7 +26361,7 @@ var MatchSchema = external_exports.object({
26296
26361
  var VirusDefinitionSchema = external_exports.object({
26297
26362
  id: external_exports.string().regex(/^EX-\d{3}$/, "id must match EX-NNN"),
26298
26363
  title: external_exports.string().min(1, "title must not be empty"),
26299
- severity: external_exports.enum(["critical", "high", "medium", "low"]),
26364
+ severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
26300
26365
  applies_to: external_exports.array(external_exports.string()).min(1, "applies_to must have at least one entry"),
26301
26366
  match: MatchSchema,
26302
26367
  owasp: external_exports.array(external_exports.string()).min(1, "owasp must have at least one reference"),
@@ -26349,7 +26414,7 @@ async function loadDefinitions(dir) {
26349
26414
  init_zod();
26350
26415
  import { createHash } from "node:crypto";
26351
26416
  import { readFileSync as readFileSync2 } from "node:fs";
26352
- import { basename, isAbsolute as isAbsolute2, join as join3, relative, resolve } from "node:path";
26417
+ import { basename as basename2, isAbsolute as isAbsolute2, join as join3, relative as relative2, resolve as resolve2 } from "node:path";
26353
26418
  var ManifestSchema = external_exports.object({
26354
26419
  id: external_exports.string(),
26355
26420
  kind: external_exports.enum(["mcp-server", "file", "exorcise"]),
@@ -26359,11 +26424,11 @@ var ManifestSchema = external_exports.object({
26359
26424
  });
26360
26425
  var VAULT_PATH = /^(?:(.*)\/)?\.exorcist\/vault\/([^/]+)\/(.+)$/;
26361
26426
  var inside = (dir, p) => {
26362
- const r = relative(dir, p);
26427
+ const r = relative2(dir, p);
26363
26428
  return r === "" || !r.startsWith("..") && !isAbsolute2(r);
26364
26429
  };
26365
26430
  function vaultBackupChecker(root) {
26366
- const absRoot = resolve(root);
26431
+ const absRoot = resolve2(root);
26367
26432
  const manifests = /* @__PURE__ */ new Map();
26368
26433
  return (rel, bytes) => {
26369
26434
  const m = VAULT_PATH.exec(rel.replace(/\\/g, "/"));
@@ -26385,14 +26450,14 @@ function vaultBackupChecker(root) {
26385
26450
  const e = manifests.get(key);
26386
26451
  if (!e) return null;
26387
26452
  const digest = createHash("sha256").update(bytes).digest("hex");
26388
- const target = resolve(e.target);
26453
+ const target = resolve2(e.target);
26389
26454
  if (e.kind === "exorcise") {
26390
26455
  if (target !== project) return null;
26391
26456
  const f = e.files?.find((x) => `files/${x.rel}` === inner);
26392
26457
  return f && f.sha256 === digest ? { id, kind: e.kind } : null;
26393
26458
  }
26394
26459
  if (!inside(project, target)) return null;
26395
- const expected = e.kind === "mcp-server" ? "entry.json" : `files/${basename(target)}`;
26460
+ const expected = e.kind === "mcp-server" ? "entry.json" : `files/${basename2(target)}`;
26396
26461
  return inner === expected && e.sha256 === digest ? { id, kind: e.kind } : null;
26397
26462
  };
26398
26463
  }
@@ -26584,6 +26649,30 @@ var EXEC_COMMANDS = /* @__PURE__ */ new Set([
26584
26649
  "powershell",
26585
26650
  "pwsh"
26586
26651
  ]);
26652
+ var INTERPRETERS = /* @__PURE__ */ new Set([
26653
+ "sh",
26654
+ "bash",
26655
+ "zsh",
26656
+ "fish",
26657
+ "dash",
26658
+ "node",
26659
+ "nodejs",
26660
+ "deno",
26661
+ "bun",
26662
+ "python",
26663
+ "python3",
26664
+ "perl",
26665
+ "ruby",
26666
+ "php",
26667
+ "lua",
26668
+ "tsx",
26669
+ "ts-node",
26670
+ "osascript",
26671
+ "powershell",
26672
+ "pwsh",
26673
+ "env",
26674
+ "xargs"
26675
+ ]);
26587
26676
  var NETWORK_ALLOW = /^(?:WebFetch|Bash\(\s*(?:curl|wget|ssh|scp|nc|ncat|ftp|rsync|telnet)\b)/;
26588
26677
  var WRITE_ALLOW = /^(?:Write|Edit|MultiEdit|NotebookEdit|Bash\(\s*(?:rm|mv|cp|tee|chmod|chown|dd|ln|touch|mkdir|truncate)\b|Bash\(\s*\*+\s*\))/;
26589
26678
  var ALLOW_ENTRY = /^(?:Bash|Shell|PowerShell|Run)\(([^)]*)\)$/;
@@ -26715,7 +26804,7 @@ function readProjectSettings(rel, text) {
26715
26804
  const arg = (m[1] ?? "").trim();
26716
26805
  const wild = /^(.+?)(?::\s*\*+|\s+\*+)$/.exec(arg);
26717
26806
  const cmd = (wild ? wild[1] ?? "" : arg).trim();
26718
- const bareInterpreter = !wild && EXEC_COMMANDS.has(cmd) && ["sh", "bash", "zsh", "fish", "dash", "node", "nodejs", "deno", "bun", "python", "python3", "perl", "ruby", "php", "lua", "tsx", "ts-node", "osascript", "powershell", "pwsh", "env", "xargs"].includes(cmd);
26807
+ const bareInterpreter = !wild && EXEC_COMMANDS.has(cmd) && INTERPRETERS.has(cmd);
26719
26808
  if (wild && EXEC_COMMANDS.has(cmd) || bareInterpreter) add("allow-exec", JSON.stringify(e), e, loud ? "high" : "medium");
26720
26809
  }
26721
26810
  }
@@ -30005,6 +30094,62 @@ function getRegex(pattern, flags2) {
30005
30094
  regexCache.set(key, re2);
30006
30095
  return re2;
30007
30096
  }
30097
+ function stripLookbehinds(pattern) {
30098
+ let out = "";
30099
+ let i = 0;
30100
+ while (i < pattern.length) {
30101
+ if (pattern.startsWith("(?<=", i)) {
30102
+ let depth = 0;
30103
+ let j = i;
30104
+ let inClass = false;
30105
+ for (; j < pattern.length; j++) {
30106
+ const c = pattern[j];
30107
+ if (c === "\\") {
30108
+ j++;
30109
+ continue;
30110
+ }
30111
+ if (inClass) {
30112
+ if (c === "]") inClass = false;
30113
+ continue;
30114
+ }
30115
+ if (c === "[") inClass = true;
30116
+ else if (c === "(") depth++;
30117
+ else if (c === ")") {
30118
+ depth--;
30119
+ if (depth === 0) break;
30120
+ }
30121
+ }
30122
+ i = j + 1;
30123
+ continue;
30124
+ }
30125
+ if (pattern[i] === "\\") {
30126
+ out += pattern.slice(i, i + 2);
30127
+ i += 2;
30128
+ continue;
30129
+ }
30130
+ out += pattern[i];
30131
+ i++;
30132
+ }
30133
+ return out;
30134
+ }
30135
+ function isWideFile(match, rel) {
30136
+ return match.order_regex !== void 0 && match.wide_paths !== void 0 && match.wide_paths.some((p) => getRegex(p, "i").test(rel));
30137
+ }
30138
+ var MAX_ORDER_HITS = 5e3;
30139
+ function orderSpans(order, text) {
30140
+ const re2 = getRegex(order, "gi");
30141
+ const out = [];
30142
+ re2.lastIndex = 0;
30143
+ let m;
30144
+ while (out.length < MAX_ORDER_HITS && (m = re2.exec(text)) !== null) {
30145
+ if (m[0].length === 0) {
30146
+ re2.lastIndex++;
30147
+ continue;
30148
+ }
30149
+ out.push([m.index, m.index + m[0].length]);
30150
+ }
30151
+ return out;
30152
+ }
30008
30153
  function escapeCodePoint(hit) {
30009
30154
  const hex = hit.codePoint.toString(16).toUpperCase();
30010
30155
  return hit.codePoint > 65535 ? `\\u{${hex}}` : `\\u${hex.padStart(4, "0")}`;
@@ -30215,12 +30360,19 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
30215
30360
  fix: def.fix
30216
30361
  };
30217
30362
  const mine = [];
30363
+ const narrow = [];
30218
30364
  if (match.regex) {
30219
- const re2 = getRegex(match.regex, "gi");
30365
+ const wide = isWideFile(match, file.rel);
30366
+ const re2 = getRegex(wide ? stripLookbehinds(match.regex) : match.regex, "gi");
30220
30367
  mine.push(addLogical(re2, norm.plain));
30221
30368
  if (vis) mine.push(addLogical(re2, vis.text));
30369
+ if (wide) {
30370
+ const own = getRegex(match.regex, "gi");
30371
+ narrow.push(addLogical(own, norm.plain));
30372
+ if (vis) narrow.push(addLogical(own, vis.text));
30373
+ }
30222
30374
  }
30223
- active.push({ def, base, keep, jobs: mine });
30375
+ active.push({ def, base, keep, jobs: mine, narrow });
30224
30376
  }
30225
30377
  let results = jobs.length > 0 ? guarded(jobs, limitMs) : [];
30226
30378
  const timedOut = /* @__PURE__ */ new Set();
@@ -30245,10 +30397,10 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
30245
30397
  }
30246
30398
  return out2;
30247
30399
  };
30248
- for (const { def, base, keep, jobs: mine } of active) {
30400
+ for (const { def, base, keep, jobs: mine, narrow } of active) {
30249
30401
  const { match } = def;
30250
30402
  if (match.regex) {
30251
- if (mine.some(timedOutLogical)) {
30403
+ if ([...mine, ...narrow].some(timedOutLogical)) {
30252
30404
  findings.push({
30253
30405
  ...base,
30254
30406
  severity: agentFacing ? base.severity : "medium",
@@ -30263,8 +30415,11 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
30263
30415
  mine.forEach((logicalId, k) => {
30264
30416
  const src = k === 0 || !vis ? norm.plain : vis.text;
30265
30417
  const toPlain = k === 0 || !vis ? (i) => i : (i) => vis.map[i] ?? i;
30418
+ const orders = isWideFile(match, file.rel) ? orderSpans(match.order_regex, src) : null;
30419
+ const ownHits = narrow.length > 0 ? new Set(matchesOf(narrow[k] ?? -1).map(([i]) => i)) : null;
30266
30420
  for (const [index2, text] of matchesOf(logicalId)) {
30267
30421
  if (!keep(text)) continue;
30422
+ if (orders && !ownHits?.has(index2) && !orders.some(([s, e]) => e <= index2 || s >= index2 + text.length)) continue;
30268
30423
  const at = toPlain(index2);
30269
30424
  if (seen.has(at)) continue;
30270
30425
  if (!ctx2.allows(def, text, at, src, index2)) continue;
@@ -30395,7 +30550,7 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
30395
30550
  const out = lowered.size === 0 ? findings : findings.map((f) => lowered.has(f.ruleId) ? { ...f, severity: "low" } : f);
30396
30551
  return sameLineGroups(out, defs);
30397
30552
  }
30398
- var SEVERITY_RANK = { critical: 4, high: 3, medium: 2, low: 1 };
30553
+ var SEVERITY_RANK = { critical: 4, high: 3, medium: 2, low: 1, info: 0 };
30399
30554
  function sameLineGroups(findings, defs) {
30400
30555
  const groupOf = new Map(defs.filter((d) => d.same_line_group).map((d) => [d.id, d.same_line_group]));
30401
30556
  if (groupOf.size === 0) return findings;
@@ -30845,11 +31000,68 @@ function extractPy(text, budget, out, dyn = []) {
30845
31000
  if (r.dyn !== null) dyn.push(r.dyn);
30846
31001
  if (r.after > 0) after = r.after;
30847
31002
  }
30848
- lit ??= docstringAfter(text, after, limit);
31003
+ const doc = docstringAfter(text, after, limit);
31004
+ if (lit === null) lit = doc;
31005
+ else if (doc !== null && PY_ARGS_SECTION.test(doc.value)) out.push(toFound(doc));
30849
31006
  if (lit) out.push(toFound(lit));
30850
31007
  }
30851
31008
  }
30852
31009
  }
31010
+ var PY_ARGS_SECTION = /^[ \t]*(?:Args|Arguments|Parameters|Params)[ \t]*:/m;
31011
+ var FIELD_KEYS = ["type", "enum", "items", "properties", "format", "default", "minimum", "maximum", "anyOf", "oneOf"];
31012
+ var SCHEMA_WORD = /properties|inputSchema|input_schema|parameters/;
31013
+ var MCP_TEXT = /modelcontextprotocol|FastMCP|McpServer|mcp\.server|inputSchema|input_schema|@mcp\.tool|\.tool\(|registerTool/;
31014
+ var nearSchema = (text, at) => SCHEMA_WORD.test(text.slice(Math.max(0, at - 3e3), at));
31015
+ function extractFieldsTs(text, out, dyn) {
31016
+ const keyBudget = { left: MAX_SITES };
31017
+ for (const at of indexesOf(text, "description", keyBudget)) {
31018
+ if (isIdent(text[at - 1])) continue;
31019
+ const limit = lim(text, at);
31020
+ let j = at + "description".length;
31021
+ if (text[j] === '"' || text[j] === "'") j++;
31022
+ j = skipTrivia(text, j, "ts", limit);
31023
+ if (text[j] !== ":") continue;
31024
+ const open4 = enclosingObject(text, at);
31025
+ if (open4 < 0 || !hasKeyAtTop(text, open4, FIELD_KEYS, limit)) continue;
31026
+ const p = skipTrivia(text, j + 1, "ts", limit);
31027
+ const l = isQuote(text[p]) ? readLiteral(text, p, "ts", limit) : null;
31028
+ if (l) {
31029
+ out.push(toFound(l));
31030
+ if (text[skipTrivia(text, l.next, "ts", limit)] === "+" && nearSchema(text, at)) dyn.push(p);
31031
+ } else if (nearSchema(text, at)) dyn.push(p);
31032
+ }
31033
+ const describeBudget = { left: MAX_SITES };
31034
+ for (const at of indexesOf(text, ".describe(", describeBudget)) {
31035
+ const limit = lim(text, at);
31036
+ const p = skipTrivia(text, at + ".describe(".length, "ts", limit);
31037
+ if (text[p] === ")") continue;
31038
+ const l = isQuote(text[p]) ? readLiteral(text, p, "ts", limit) : null;
31039
+ if (l) {
31040
+ out.push(toFound(l));
31041
+ if (text[skipTrivia(text, l.next, "ts", limit)] === "+") dyn.push(p);
31042
+ } else dyn.push(p);
31043
+ }
31044
+ }
31045
+ function extractFieldsPy(text, out, dyn) {
31046
+ const fieldBudget = { left: MAX_SITES };
31047
+ for (const at of indexesOf(text, "Field(", fieldBudget)) {
31048
+ if (isIdent(text[at - 1])) continue;
31049
+ const { lit, dyn: d } = findKeyString(text, at + 5, "py", lim(text, at), "=");
31050
+ if (lit) out.push(toFound(lit));
31051
+ if (d !== null) dyn.push(d);
31052
+ }
31053
+ const annBudget = { left: MAX_SITES };
31054
+ for (const at of indexesOf(text, "Annotated[", annBudget)) {
31055
+ if (isIdent(text[at - 1])) continue;
31056
+ const limit = lim(text, at);
31057
+ const first = skipTrivia(text, at + "Annotated[".length, "py", limit);
31058
+ const e = skipArgument(text, first, "py", limit);
31059
+ if (e < 0 || text[e] !== ",") continue;
31060
+ const p = skipTrivia(text, e + 1, "py", limit);
31061
+ const l = readPyString(text, p, limit);
31062
+ if (l) out.push(toFound(l));
31063
+ }
31064
+ }
30853
31065
  function extractGo(text, budget, out) {
30854
31066
  for (const at of indexesOf(text, "WithDescription(", budget)) {
30855
31067
  if (isIdent(text[at - 1])) continue;
@@ -30859,9 +31071,10 @@ function extractGo(text, budget, out) {
30859
31071
  if (l) out.push(toFound(l));
30860
31072
  }
30861
31073
  }
30862
- function extractAll(text, lang) {
31074
+ function extractAll(text, lang, mcpPath = false) {
30863
31075
  const out = [];
30864
31076
  const dyn = [];
31077
+ const dynFields = [];
30865
31078
  const budget = { left: MAX_SITES };
30866
31079
  if (lang === "ts") {
30867
31080
  extractTs(text, budget, out, dyn);
@@ -30872,11 +31085,20 @@ function extractAll(text, lang) {
30872
31085
  extractPyConstructor(text, { left: MAX_SITES }, out, dyn);
30873
31086
  } else if (lang === "go") extractGo(text, budget, out);
30874
31087
  else extractOther(text, lang, budget, out);
31088
+ if ((lang === "ts" || lang === "py") && (mcpPath || out.length > 0 || dyn.length > 0 || MCP_TEXT.test(text))) {
31089
+ if (lang === "ts") extractFieldsTs(text, out, dynFields);
31090
+ else extractFieldsPy(text, out, dynFields);
31091
+ }
30875
31092
  const seen = /* @__PURE__ */ new Set();
30876
- return { found: out.filter((f) => !seen.has(f.offset) && seen.add(f.offset)).sort((a, b) => a.offset - b.offset), dyn: [...new Set(dyn)].sort((a, b) => a - b) };
31093
+ const taken = new Set(dyn);
31094
+ return {
31095
+ found: out.filter((f) => !seen.has(f.offset) && seen.add(f.offset)).sort((a, b) => a.offset - b.offset),
31096
+ dyn: [...taken].sort((a, b) => a - b),
31097
+ dynFields: [...new Set(dynFields)].filter((d) => !taken.has(d)).sort((a, b) => a - b)
31098
+ };
30877
31099
  }
30878
- function extract(text, lang) {
30879
- return extractAll(text, lang).found;
31100
+ function extract(text, lang, mcpPath = false) {
31101
+ return extractAll(text, lang, mcpPath).found;
30880
31102
  }
30881
31103
  function enclosingObject(text, at) {
30882
31104
  let depth = 0;
@@ -30997,17 +31219,22 @@ function scanDynamicToolDescriptions(file, text, defs) {
30997
31219
  const lang = languageOf(file.rel);
30998
31220
  if (!def || lang === null || typeof text !== "string" || lang !== "ts" && lang !== "py") return [];
30999
31221
  if (!/mcp/i.test(file.rel) && !/modelcontextprotocol|FastMCP|McpServer|mcp\.server/.test(text)) return [];
31000
- return extractAll(text, lang).dyn.map((at) => ({
31222
+ const { dyn, dynFields } = extractAll(text, lang, true);
31223
+ const make = (at, span, what) => ({
31001
31224
  source: "signature",
31002
31225
  ruleId: def.id,
31003
31226
  title: def.title,
31004
31227
  severity: "medium",
31005
31228
  file: file.rel,
31006
31229
  ...positionOf(text, at),
31007
- span: "tool description built at run time: not checked",
31230
+ span,
31008
31231
  owasp: def.owasp,
31009
- fix: "This tool description is computed (a variable, a constant from another file, a template or a concatenation), so the scan cannot read what an agent will be told. Write it as one plain string in the registration, or run the server behind the Shield (exorcist wrap), which checks what a running server really sends."
31010
- }));
31232
+ fix: `This ${what} is computed (a variable, a constant from another file, a template or a concatenation), so the scan cannot read what an agent will be told. Write it as one plain string in the registration, or run the server behind the Shield: exorcist wrap <mcp config> (or exorcist init --shield) checks the real text the running server sends and withholds a poisoned tool.`
31233
+ });
31234
+ return [
31235
+ ...dyn.map((at) => make(at, "tool description built at run time: not checked", "tool description")),
31236
+ ...dynFields.map((at) => make(at, "tool field description built at run time: not checked", "field description of a tool parameter"))
31237
+ ];
31011
31238
  } catch {
31012
31239
  return [];
31013
31240
  }
@@ -31065,7 +31292,7 @@ function scanSourceTools(file, text, defs) {
31065
31292
  const lang = languageOf(file.rel);
31066
31293
  if (!def || lang === null || typeof text !== "string") return [];
31067
31294
  const out = [];
31068
- for (const s of extract(text, lang)) {
31295
+ for (const s of extract(text, lang, /mcp/i.test(file.rel))) {
31069
31296
  for (const hit of scanText(s.text, "mcp-config", [def], file.rel)) {
31070
31297
  const idx = Math.min(Math.max(indexOfLineCol(s.text, hit.line, hit.col), 0), s.text.length);
31071
31298
  if (isQuietHint(hit.span, s.text, idx)) continue;
@@ -31109,8 +31336,8 @@ function sandboxFindings(text, rel) {
31109
31336
  return [{
31110
31337
  source: "signature",
31111
31338
  ruleId: SANDBOX_RULE_ID,
31112
- title: mcpOff ? "Info: MCP sandboxing is off in this project" : "Info: the command sandbox is off in this project",
31113
- severity: "low",
31339
+ title: mcpOff ? "MCP sandboxing is off in this project" : "The command sandbox is off in this project",
31340
+ severity: "info",
31114
31341
  file: rel,
31115
31342
  line,
31116
31343
  col,
@@ -31207,8 +31434,8 @@ function checkPathSegment(name) {
31207
31434
  }
31208
31435
 
31209
31436
  // ../core/src/lifecycle-scripts.ts
31210
- import { closeSync as closeSync2, existsSync, lstatSync as lstatSync2, openSync as openSync2, readdirSync, readSync, realpathSync, statSync as statSync2 } from "node:fs";
31211
- import { isAbsolute as isAbsolute6, join as join8, posix as posix2, relative as relative5, resolve as resolve5, sep } from "node:path";
31437
+ import { closeSync as closeSync2, existsSync as existsSync2, lstatSync as lstatSync2, openSync as openSync2, readdirSync, readSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
31438
+ import { isAbsolute as isAbsolute6, join as join8, posix as posix2, relative as relative6, resolve as resolve6, sep } from "node:path";
31212
31439
 
31213
31440
  // ../core/src/install-hooks.ts
31214
31441
  var INSTALL_HOOKS = [
@@ -31570,7 +31797,7 @@ function pmActions(e, scripts = /* @__PURE__ */ new Set()) {
31570
31797
  }
31571
31798
 
31572
31799
  // ../core/src/shell-analyze.ts
31573
- import { basename as basename3, resolve as resolve4 } from "node:path";
31800
+ import { basename as basename4, resolve as resolve5 } from "node:path";
31574
31801
 
31575
31802
  // ../core/src/shell-parse.ts
31576
31803
  var MAX_COMMAND_CHARS = 65536;
@@ -32038,15 +32265,15 @@ function parseShell(command, sub = false) {
32038
32265
  init_zod();
32039
32266
  import { readFileSync as readFileSync4, statSync } from "node:fs";
32040
32267
  import { homedir as homedir3 } from "node:os";
32041
- import { isAbsolute as isAbsolute5, join as join7, normalize as normalize2, relative as relative4, resolve as resolve3 } from "node:path";
32268
+ import { isAbsolute as isAbsolute5, join as join7, normalize as normalize2, relative as relative5, resolve as resolve4 } from "node:path";
32042
32269
 
32043
32270
  // ../core/src/user-dir-guard.ts
32044
32271
  import { homedir as homedir2 } from "node:os";
32045
- import { dirname, isAbsolute as isAbsolute4, join as join6, relative as relative3, resolve as resolve2 } from "node:path";
32272
+ import { dirname as dirname2, isAbsolute as isAbsolute4, join as join6, relative as relative4, resolve as resolve3 } from "node:path";
32046
32273
  function userKeyDirs(env = process.env) {
32047
32274
  const out = /* @__PURE__ */ new Set();
32048
32275
  const o = env["EXORCIST_USER_DIR"];
32049
- if (o && isAbsolute4(o)) out.add(resolve2(o));
32276
+ if (o && isAbsolute4(o)) out.add(resolve3(o));
32050
32277
  const xdg = env["XDG_CONFIG_HOME"];
32051
32278
  out.add(join6(xdg && isAbsolute4(xdg) ? xdg : join6(homedir2(), ".config"), "exorcist-98"));
32052
32279
  out.add(join6(homedir2(), ".config", "exorcist-98"));
@@ -32106,13 +32333,13 @@ function insideProject(raw, cwd) {
32106
32333
  }
32107
32334
  if (!isAbsolute5(p)) return true;
32108
32335
  if (cwd === void 0) return !raw.startsWith("~");
32109
- const rel = relative4(cwd, resolve3(p));
32336
+ const rel = relative5(cwd, resolve4(p));
32110
32337
  return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
32111
32338
  }
32112
32339
  function withinProject(raw, cwd) {
32113
32340
  if (raw === "" || /[$`~]|:\/\//.test(raw)) return false;
32114
32341
  if (cwd === void 0) return !isAbsolute5(raw) && !normalize2(raw).split(/[\\/]/).includes("..");
32115
- const rel = relative4(cwd, resolve3(cwd, raw));
32342
+ const rel = relative5(cwd, resolve4(cwd, raw));
32116
32343
  return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
32117
32344
  }
32118
32345
  var anyInside = (list, cwd) => list.split(/[:;]/).some((p) => insideProject(p, cwd));
@@ -32629,7 +32856,7 @@ var reject = (reason, fix = FIX_SIMPLE) => {
32629
32856
  var SYSTEM_DIRS = ["/usr/bin/", "/bin/", "/usr/sbin/", "/sbin/", "/usr/local/bin/", "/usr/local/sbin/", "/opt/homebrew/bin/", "/opt/homebrew/sbin/", "/opt/local/bin/", "/usr/libexec/", "/usr/local/opt/"];
32630
32857
  var SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "ksh", "ash", "csh", "tcsh", "fish"]);
32631
32858
  var NODE_LIKE = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno"]);
32632
- var INTERPRETERS = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno", "python", "python3", "ruby", "perl", "php", "lua", "sh", "bash", "zsh", "dash", "ksh"]);
32859
+ var INTERPRETERS2 = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno", "python", "python3", "ruby", "perl", "php", "lua", "sh", "bash", "zsh", "dash", "ksh"]);
32633
32860
  var KNOWN_PROGRAMS = /* @__PURE__ */ new Set([
32634
32861
  // shell builtins and plain utilities
32635
32862
  "cd",
@@ -32941,7 +33168,7 @@ var WRAP_SPECS = {
32941
33168
  var XARGS_SPEC = spec("-a -d -E -e -I -i -L -l -n -P -s --arg-file --delimiter --max-args --max-procs --max-chars --max-lines --eof --replace", "-0 -r -t -p -x --null --no-run-if-empty --verbose --interactive --exit --open-tty");
32942
33169
  var SHELL_VALUE_FLAGS = /* @__PURE__ */ new Set(["-o", "+o", "-O", "+O", "--rcfile", "--init-file"]);
32943
33170
  function progName(raw) {
32944
- const b = basename3(raw.replace(/\\/g, "/"));
33171
+ const b = basename4(raw.replace(/\\/g, "/"));
32945
33172
  return b.replace(/\.(exe|cmd|bat|ps1)$/i, "").toLowerCase();
32946
33173
  }
32947
33174
  var wordsText = (ws) => ws.map((w) => w.text);
@@ -33061,7 +33288,7 @@ function checkSpecial(prog, f, words2, ctx2) {
33061
33288
  if (prog === "less" || prog === "more" || prog === "man") {
33062
33289
  if (args.some((a) => a.startsWith("--lesskey") || a === "+!" || a.startsWith("+!"))) reject("a pager was given commands to run", FIX_READ_TOOL);
33063
33290
  }
33064
- if (INTERPRETERS.has(prog) || /^python[0-9.]*$/.test(prog)) {
33291
+ if (INTERPRETERS2.has(prog) || /^python[0-9.]*$/.test(prog)) {
33065
33292
  const inlineFlag = (a) => {
33066
33293
  if (NODE_LIKE.has(prog) || prog === "nodejs") return a === "-e" || a === "--eval" || a === "-p" || a === "--print" || a === "-pe" || a === "-ep";
33067
33294
  if (/^python/.test(prog)) return a === "-c" || /^-[A-Za-z]*c$/.test(a) && a.length <= 4 && a.startsWith("-") && !a.startsWith("--");
@@ -33246,7 +33473,7 @@ function resolveWords(words2, f, ctx2) {
33246
33473
  }
33247
33474
  pushExec(ctx2, f, words2, raw);
33248
33475
  const e = lastExec(ctx2);
33249
- if (ctx2.mode === "script" && (INTERPRETERS.has(prog) || /^python/.test(prog))) {
33476
+ if (ctx2.mode === "script" && (INTERPRETERS2.has(prog) || /^python/.test(prog))) {
33250
33477
  const flags2 = /* @__PURE__ */ new Set(["-e", "-c", "-p", "--eval", "--print", "-r", "-E"]);
33251
33478
  const k = e.args.findIndex((a) => flags2.has(a.text));
33252
33479
  const flag = e.args[k]?.text;
@@ -34008,14 +34235,14 @@ function describeHit(h) {
34008
34235
  }
34009
34236
  function readLocalText(pkgDir, rel) {
34010
34237
  try {
34011
- const abs = resolve5(pkgDir, rel);
34238
+ const abs = resolve6(pkgDir, rel);
34012
34239
  const within = (root, p) => {
34013
- const r = relative5(root, p);
34240
+ const r = relative6(root, p);
34014
34241
  return r !== "" && !r.startsWith("..") && !isAbsolute6(r) && !r.split(sep).includes("..");
34015
34242
  };
34016
- if (!within(pkgDir, abs) || !existsSync(abs)) return null;
34017
- const real = realpathSync(abs);
34018
- if (!within(realpathSync(pkgDir), real)) return null;
34243
+ if (!within(pkgDir, abs) || !existsSync2(abs)) return null;
34244
+ const real = realpathSync2(abs);
34245
+ if (!within(realpathSync2(pkgDir), real)) return null;
34019
34246
  const st = statSync2(real);
34020
34247
  if (!st.isFile() || st.size > MAX_SOURCE_BYTES) return null;
34021
34248
  const buf = Buffer.alloc(st.size);
@@ -34033,7 +34260,7 @@ function readLocalText(pkgDir, rel) {
34033
34260
  }
34034
34261
 
34035
34262
  // ../core/src/scanner/orchestrator.ts
34036
- import { dirname as dirname2 } from "node:path";
34263
+ import { dirname as dirname3 } from "node:path";
34037
34264
  init_heuristic_engine();
34038
34265
 
34039
34266
  // ../core/src/capabilities.ts
@@ -34741,7 +34968,7 @@ async function* pathNameFindings(root, def, ignore) {
34741
34968
  }
34742
34969
  }
34743
34970
  function lifecycleScanFindings(text, absPath, rel, def) {
34744
- const dir = dirname2(absPath);
34971
+ const dir = dirname3(absPath);
34745
34972
  return lifecycleFindings({ pkgText: text, readLocal: (r) => readLocalText(dir, r) }).map((h) => ({
34746
34973
  source: "signature",
34747
34974
  ruleId: def.id,
@@ -34950,7 +35177,7 @@ var FindingSchema = external_exports.object({
34950
35177
  source: external_exports.enum(["signature", "heuristic"]),
34951
35178
  ruleId: external_exports.string(),
34952
35179
  title: external_exports.string(),
34953
- severity: external_exports.enum(["critical", "high", "medium", "low"]),
35180
+ severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
34954
35181
  file: external_exports.string(),
34955
35182
  // The file name with bidi, zero-width and control characters shown as [U+XXXX] (m18-scanner SC-19).
34956
35183
  fileDisplay: external_exports.string().optional(),
@@ -35189,6 +35416,10 @@ var ENTRIES = {
35189
35416
  "EX-074": {
35190
35417
  headline: "This settings file makes Copilot approve every tool call",
35191
35418
  attack: "A committed setting approves all tool calls of the chat agent, so it no longer asks before it runs commands, edits files or reaches the network."
35419
+ },
35420
+ "EX-075": {
35421
+ headline: "This instruction file tells your AI to do something that has nothing to do with the code",
35422
+ attack: "Agents follow their instruction files (steering files, AGENTS.md, CONTRIBUTING.md and the like) without asking. An order there to leave a marker file, skip or weaken a test or a check, run a command that is not a build, test or lint step, or fetch a web address is carried out quietly, even when nothing in the text hides it."
35192
35423
  }
35193
35424
  };
35194
35425
  function plainFor(ruleId, fallbackTitle) {
@@ -35256,7 +35487,7 @@ var MAX_FILE_BYTES2 = 8 * 1024 * 1024;
35256
35487
  var OriginStatusSchema = external_exports.enum(["log-s", "blame", "uncommitted", "not-found", "timeout", "error"]);
35257
35488
  var TimelineThreatSchema = external_exports.object({
35258
35489
  ruleId: external_exports.string(),
35259
- severity: external_exports.enum(["critical", "high", "medium", "low"]),
35490
+ severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
35260
35491
  file: external_exports.string(),
35261
35492
  line: external_exports.number().int().positive(),
35262
35493
  title: external_exports.string(),
@@ -35356,7 +35587,7 @@ init_zod();
35356
35587
  import { createHash as createHash2, createPrivateKey, createPublicKey, generateKeyPairSync, randomBytes as randomBytes3, sign as edSign, verify as edVerify } from "node:crypto";
35357
35588
  import { closeSync as closeSync3, fstatSync as fstatSync2, lstatSync as lstatSync3, mkdirSync as mkdirSync2, openSync as openSync3, readFileSync as readFileSync5, readSync as readSync2, readdirSync as readdirSync2, renameSync, rmSync, statSync as statSync3, writeFileSync } from "node:fs";
35358
35589
  import { homedir as homedir4 } from "node:os";
35359
- import { basename as basename4, join as join11, resolve as resolve6 } from "node:path";
35590
+ import { basename as basename5, join as join11, resolve as resolve7 } from "node:path";
35360
35591
  var DEFINITIONS_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
35361
35592
  MCowBQYDK2VwAyEAn4o+dmOJXIzsygT2CF/3go/1E/bk9Ub16r4hGtJJjhM=
35362
35593
  -----END PUBLIC KEY-----
@@ -35434,7 +35665,7 @@ function parseManifest(manifestBytes) {
35434
35665
  }
35435
35666
  function installedDefinitionsRoot(env = process.env) {
35436
35667
  const fromEnv = env["EXORCIST_DEFINITIONS_HOME"];
35437
- if (fromEnv) return resolve6(fromEnv);
35668
+ if (fromEnv) return resolve7(fromEnv);
35438
35669
  return join11(env["HOME"] || env["USERPROFILE"] || homedir4(), ".exorcist", "definitions");
35439
35670
  }
35440
35671
  function verifySetFolder(dir, expectedVersion, publicKeyPem) {
@@ -35443,7 +35674,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
35443
35674
  const defsDir = join11(dir, "definitions");
35444
35675
  for (const [p, kind] of [[join11(dir, MANIFEST_NAME), "file"], [join11(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
35445
35676
  const st = lstatSync3(p);
35446
- if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail2(`${basename4(p)} is not a plain ${kind === "file" ? "file" : "folder"}`);
35677
+ if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail2(`${basename5(p)} is not a plain ${kind === "file" ? "file" : "folder"}`);
35447
35678
  }
35448
35679
  const manifestBytes = readFileSync5(join11(dir, MANIFEST_NAME));
35449
35680
  const bad = verifySignature(manifestBytes, readFileSync5(join11(dir, SIGNATURE_NAME)), publicKeyPem);
@@ -35472,7 +35703,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
35472
35703
  }
35473
35704
  }
35474
35705
  function verifyInstalledSet(dir, publicKeyPem = DEFINITIONS_PUBLIC_KEY) {
35475
- const name = basename4(dir);
35706
+ const name = basename5(dir);
35476
35707
  if (!isValidVersion(name)) return fail2(`${printable(name)} is not a version folder`);
35477
35708
  return verifySetFolder(dir, name, publicKeyPem);
35478
35709
  }
@@ -35516,6 +35747,20 @@ var BaselineSchema = external_exports.object({
35516
35747
  init_text_decode();
35517
35748
  init_image_text();
35518
35749
 
35750
+ // ../core/src/home-settings.ts
35751
+ init_zod();
35752
+ var Globs = external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]);
35753
+ var RuleSchema2 = external_exports.object({ capability: external_exports.string(), match: Globs.optional().nullable(), exclude: Globs.optional().nullable(), effect: external_exports.string() }).passthrough();
35754
+ var KiroFileSchema = external_exports.object({ rules: external_exports.array(external_exports.unknown()).optional().nullable(), policies: external_exports.array(external_exports.unknown()).optional().nullable() }).passthrough();
35755
+ var AgentSchema = external_exports.object({
35756
+ permissions: external_exports.object({ rules: external_exports.array(external_exports.unknown()).optional().nullable() }).passthrough().optional().nullable(),
35757
+ toolsSettings: external_exports.record(external_exports.unknown()).optional().nullable()
35758
+ }).passthrough();
35759
+ var HIGH_FLAGS = ["executeAllCommands"];
35760
+ var MEDIUM_FLAGS = ["editFiles", "editFilesExternally", "useMcp", "useBrowser"];
35761
+ var SAFE_FLAGS = ["executeSafeCommands", "readFiles", "readFilesExternally"];
35762
+ var ACTION_FLAGS = /* @__PURE__ */ new Set([...HIGH_FLAGS, ...MEDIUM_FLAGS, ...SAFE_FLAGS]);
35763
+
35519
35764
  // ../core/src/kiro-evidence.ts
35520
35765
  init_zod();
35521
35766
  var KiroEventSchema = external_exports.object({
@@ -35757,8 +36002,8 @@ var LockSchema = external_exports.object({
35757
36002
 
35758
36003
  // ../shield/src/vault.ts
35759
36004
  import { createHash as createHash3, randomBytes as randomBytes4 } from "node:crypto";
35760
- import { closeSync as closeSync4, constants as constants3, copyFileSync, existsSync as existsSync2, fstatSync as fstatSync3, lstatSync as lstatSync4, mkdirSync as mkdirSync3, openSync as openSync4, readFileSync as readFileSync6, readdirSync as readdirSync3, realpathSync as realpathSync2, rmSync as rmSync2, statSync as statSync4, writeFileSync as writeFileSync2, writeSync as writeSync2 } from "node:fs";
35761
- import { basename as basename5, dirname as dirname3, isAbsolute as isAbsolute7, join as join12, resolve as resolve7, sep as sep2 } from "node:path";
36005
+ import { closeSync as closeSync4, constants as constants3, copyFileSync, existsSync as existsSync3, fstatSync as fstatSync3, lstatSync as lstatSync4, mkdirSync as mkdirSync3, openSync as openSync4, readFileSync as readFileSync6, readdirSync as readdirSync3, realpathSync as realpathSync3, rmSync as rmSync2, statSync as statSync4, writeFileSync as writeFileSync2, writeSync as writeSync2 } from "node:fs";
36006
+ import { basename as basename6, dirname as dirname4, isAbsolute as isAbsolute7, join as join12, resolve as resolve8, sep as sep2 } from "node:path";
35762
36007
  init_zod();
35763
36008
  var SafeRel = external_exports.string().min(1).max(1024).refine(
35764
36009
  (p) => !isAbsolute7(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
@@ -35798,9 +36043,9 @@ var entryText = (e) => {
35798
36043
  };
35799
36044
  function ensureSafeVault(vaultDir) {
35800
36045
  const me = typeof process.getuid === "function" ? process.getuid() : void 0;
35801
- const state = dirname3(vaultDir);
36046
+ const state = dirname4(vaultDir);
35802
36047
  try {
35803
- mkdirSync3(dirname3(state), { recursive: true });
36048
+ mkdirSync3(dirname4(state), { recursive: true });
35804
36049
  for (const d of [state, vaultDir]) {
35805
36050
  const st = lstatSync4(d, { throwIfNoEntry: false });
35806
36051
  if (st === void 0) {
@@ -35827,14 +36072,14 @@ function writeFileSafe(path, text) {
35827
36072
  }
35828
36073
  var insideDir = (child, parent) => child === parent || child.startsWith(parent.endsWith(sep2) ? parent : parent + sep2);
35829
36074
  function rootFor(vaultDir, target) {
35830
- const state = dirname3(vaultDir);
35831
- if (basename5(state) !== ".exorcist") return void 0;
35832
- const project = dirname3(state);
35833
- return insideDir(resolve7(target), resolve7(project)) ? resolve7(project) : void 0;
36075
+ const state = dirname4(vaultDir);
36076
+ if (basename6(state) !== ".exorcist") return void 0;
36077
+ const project = dirname4(state);
36078
+ return insideDir(resolve8(target), resolve8(project)) ? resolve8(project) : void 0;
35834
36079
  }
35835
36080
  function realDirOf(target) {
35836
36081
  try {
35837
- return realpathSync2(dirname3(target));
36082
+ return realpathSync3(dirname4(target));
35838
36083
  } catch {
35839
36084
  return void 0;
35840
36085
  }
@@ -35855,12 +36100,12 @@ function writeManifest(vaultDir, e) {
35855
36100
  `);
35856
36101
  }
35857
36102
  function listEntries(vaultDir) {
35858
- if (!existsSync2(vaultDir)) return [];
36103
+ if (!existsSync3(vaultDir)) return [];
35859
36104
  const key = getUserKey();
35860
36105
  const out = [];
35861
36106
  for (const name of readdirSync3(vaultDir)) {
35862
36107
  const file = join12(vaultDir, name, "manifest.json");
35863
- if (!existsSync2(file)) continue;
36108
+ if (!existsSync3(file)) continue;
35864
36109
  try {
35865
36110
  const st = lstatSync4(file);
35866
36111
  if (!st.isFile()) continue;
@@ -35894,7 +36139,7 @@ function readConfig(path) {
35894
36139
  var writeConfig = (path, cfg) => writeFileSync2(path, `${JSON.stringify(cfg, null, 2)}
35895
36140
  `, "utf8");
35896
36141
  function quarantineServer(o) {
35897
- const configPath = resolve7(o.configPath);
36142
+ const configPath = resolve8(o.configPath);
35898
36143
  const cfg = readConfig(configPath);
35899
36144
  if (!cfg.ok) return cfg;
35900
36145
  const entry = cfg.value.mcpServers?.[o.serverName];
@@ -36094,8 +36339,8 @@ var MAX_HASHED_BYTES = 64 * 1024 * 1024;
36094
36339
  var MAX_EVENT_BYTES2 = 16 * 1024 * 1024;
36095
36340
 
36096
36341
  // ../shield/src/locate.ts
36097
- import { existsSync as existsSync3, readdirSync as readdirSync4, statSync as statSync5 } from "node:fs";
36098
- import { dirname as dirname4, isAbsolute as isAbsolute8, join as join13, parse as parse3, resolve as resolve8 } from "node:path";
36342
+ import { existsSync as existsSync4, readdirSync as readdirSync4, statSync as statSync5 } from "node:fs";
36343
+ import { dirname as dirname5, isAbsolute as isAbsolute8, join as join13, parse as parse3, resolve as resolve9 } from "node:path";
36099
36344
  import { fileURLToPath } from "node:url";
36100
36345
  function hasDefinitions(dir) {
36101
36346
  try {
@@ -36107,12 +36352,12 @@ function hasDefinitions(dir) {
36107
36352
  function findDefinitionsDir(o) {
36108
36353
  const env = o.env ?? process.env;
36109
36354
  const cwd = o.cwd ?? process.cwd();
36110
- if (o.explicit) return resolve8(cwd, o.explicit);
36355
+ if (o.explicit) return resolve9(cwd, o.explicit);
36111
36356
  const fromEnv = env["EXORCIST_DEFINITIONS"];
36112
- if (fromEnv) return resolve8(cwd, fromEnv);
36357
+ if (fromEnv) return resolve9(cwd, fromEnv);
36113
36358
  const installed = findActiveInstalledSet({ env, ...o.publicKeyPem ? { publicKeyPem: o.publicKeyPem } : {} });
36114
36359
  if (installed && hasDefinitions(installed.definitionsDir)) return installed.definitionsDir;
36115
- const here = dirname4(fileURLToPath(o.callerUrl));
36360
+ const here = dirname5(fileURLToPath(o.callerUrl));
36116
36361
  const candidates = [join13(here, "..", "definitions"), join13(here, "..", "..", "..", "definitions"), join13(cwd, "definitions")];
36117
36362
  return candidates.find(hasDefinitions) ?? null;
36118
36363
  }
@@ -36147,9 +36392,9 @@ function isWrapped(entry) {
36147
36392
 
36148
36393
  // src/tools.ts
36149
36394
  import { homedir as homedir5 } from "node:os";
36150
- import { basename as basename6, dirname as dirname5, isAbsolute as isAbsolute9, join as join14, relative as relative6, resolve as resolve9, sep as sep3 } from "node:path";
36395
+ import { basename as basename7, dirname as dirname6, isAbsolute as isAbsolute9, join as join14, relative as relative7, resolve as resolve10, sep as sep3 } from "node:path";
36151
36396
  var quotesWanted = (ctx2, asked) => asked === true && ctx2.noQuotes !== true;
36152
- var RANK = { critical: 0, high: 1, medium: 2, low: 3 };
36397
+ var RANK = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
36153
36398
  var HIDDEN2 = /[\u200B-\u200D\uFEFF\u202A-\u202E\u2066-\u2069\u{E0000}-\u{E007F}]/gu;
36154
36399
  var err = (text) => ({ text, isError: true });
36155
36400
  function reveal(s) {
@@ -36159,16 +36404,16 @@ function findDefinitionsDir2(cwd) {
36159
36404
  return findDefinitionsDir({ callerUrl: import.meta.url, cwd });
36160
36405
  }
36161
36406
  function resolveInside(cwd, p, roots = [], primary) {
36162
- const real = (d) => realpathSync3(d);
36163
- const extra = roots.filter((r) => existsSync4(r)).map(real);
36407
+ const real = (d) => realpathSync4(d);
36408
+ const extra = roots.filter((r) => existsSync5(r)).map(real);
36164
36409
  const first = primary !== void 0 && extra.includes(real(primary)) ? [real(primary)] : [];
36165
36410
  const bases = [.../* @__PURE__ */ new Set([...first, real(cwd), ...extra])];
36166
- const tries = isAbsolute9(p) ? [p] : bases.map((b) => resolve9(b, p));
36167
- const found = tries.find((t2) => existsSync4(t2));
36411
+ const tries = isAbsolute9(p) ? [p] : bases.map((b) => resolve10(b, p));
36412
+ const found = tries.find((t2) => existsSync5(t2));
36168
36413
  if (!found) return { ok: false, error: `Path not found: ${p}` };
36169
- const target = realpathSync3(found);
36414
+ const target = realpathSync4(found);
36170
36415
  const base = bases.find((b) => {
36171
- const rel = relative6(b, target);
36416
+ const rel = relative7(b, target);
36172
36417
  return !rel.startsWith("..") && !isAbsolute9(rel);
36173
36418
  });
36174
36419
  if (!base) {
@@ -36200,19 +36445,19 @@ var PROJECT_MARKERS = [
36200
36445
  "README"
36201
36446
  ];
36202
36447
  function looksLikeProject(dir) {
36203
- const has = (n) => existsSync4(join14(dir, n));
36448
+ const has = (n) => existsSync5(join14(dir, n));
36204
36449
  if (has("plugin.json") || has("POWER.md")) return false;
36205
36450
  return PROJECT_MARKERS.some(has);
36206
36451
  }
36207
36452
  var SENSITIVE_IN_HOME = [".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".password-store", join14("Library", "Keychains")];
36208
36453
  var SENSITIVE_ABSOLUTE = ["/etc", "/private/etc", "/System", "/var/root", "/root"];
36209
36454
  var isWithin = (base, p) => {
36210
- const rel = relative6(base, p);
36455
+ const rel = relative7(base, p);
36211
36456
  return rel === "" || !rel.startsWith("..") && !isAbsolute9(rel);
36212
36457
  };
36213
36458
  function sensitiveReason(real, home = homedir5()) {
36214
- const realHome = existsSync4(home) ? realpathSync3(home) : home;
36215
- if (dirname5(real) === real) return "it is the filesystem root";
36459
+ const realHome = existsSync5(home) ? realpathSync4(home) : home;
36460
+ if (dirname6(real) === real) return "it is the filesystem root";
36216
36461
  if (isWithin(real, realHome)) return real === realHome ? "it is the home folder" : "it contains the home folder";
36217
36462
  for (const n of SENSITIVE_IN_HOME) {
36218
36463
  const s = join14(realHome, n);
@@ -36242,8 +36487,8 @@ async function resolveAllowed(ctx2, p) {
36242
36487
  }
36243
36488
  let folder;
36244
36489
  try {
36245
- const real = realpathSync3(p);
36246
- folder = statSync6(real).isDirectory() ? real : dirname5(real);
36490
+ const real = realpathSync4(p);
36491
+ folder = statSync6(real).isDirectory() ? real : dirname6(real);
36247
36492
  } catch {
36248
36493
  return first;
36249
36494
  }
@@ -36275,16 +36520,16 @@ function usableRoots(entries, home) {
36275
36520
  continue;
36276
36521
  }
36277
36522
  } else if (/^[a-z][a-z0-9+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) continue;
36278
- if (!isAbsolute9(path) || !existsSync4(path)) continue;
36523
+ if (!isAbsolute9(path) || !existsSync5(path)) continue;
36279
36524
  let real;
36280
36525
  try {
36281
36526
  if (!statSync6(path).isDirectory()) continue;
36282
- real = realpathSync3(path);
36527
+ real = realpathSync4(path);
36283
36528
  } catch {
36284
36529
  continue;
36285
36530
  }
36286
- const realHome = existsSync4(home) ? realpathSync3(home) : home;
36287
- if (real === resolve9("/") || real === realHome || dirname5(real) === real) continue;
36531
+ const realHome = existsSync5(home) ? realpathSync4(home) : home;
36532
+ if (real === resolve10("/") || real === realHome || dirname6(real) === real) continue;
36288
36533
  if (!out.includes(real)) out.push(real);
36289
36534
  }
36290
36535
  return out;
@@ -36315,7 +36560,7 @@ function describe(findings, limit, quotes) {
36315
36560
  }
36316
36561
  function summary(findings, files) {
36317
36562
  if (findings.length === 0) return `No threats found. Scanned ${plural(files, "file")}.`;
36318
- const counts = ["critical", "high", "medium", "low"].map((s) => ({ s, n: findings.filter((f) => f.severity === s).length })).filter((c) => c.n > 0).map((c) => `${c.n} ${c.s}`).join(", ");
36563
+ const counts = ["critical", "high", "medium", "low", "info"].map((s) => ({ s, n: findings.filter((f) => f.severity === s).length })).filter((c) => c.n > 0).map((c) => `${c.n} ${c.s}`).join(", ");
36319
36564
  const withFindings = new Set(findings.map((f) => f.file)).size;
36320
36565
  return `${plural(findings.length, "threat")} in ${plural(withFindings, "file")} (${counts}). Scanned ${plural(files, "file")}.`;
36321
36566
  }
@@ -36327,8 +36572,8 @@ async function scanRepoTool(ctx2, a) {
36327
36572
  const defs = await loadDefs(ctx2);
36328
36573
  if (!defs.ok) return err(defs.error);
36329
36574
  const isFile = statSync6(inside2.path).isFile();
36330
- const root = isFile ? dirname5(inside2.path) : inside2.path;
36331
- const only = isFile ? basename6(inside2.path) : null;
36575
+ const root = isFile ? dirname6(inside2.path) : inside2.path;
36576
+ const only = isFile ? basename7(inside2.path) : null;
36332
36577
  const findings = [];
36333
36578
  let files = 0;
36334
36579
  for await (const ev of scanRepo(root, { definitionsDir: ctx2.definitionsDir })) {
@@ -36354,7 +36599,7 @@ async function scanMcpConfigTool(ctx2, a) {
36354
36599
  } catch {
36355
36600
  return err(`${a.path} is not valid JSON.`);
36356
36601
  }
36357
- const rel = relative6(inside2.base, inside2.path);
36602
+ const rel = relative7(inside2.base, inside2.path);
36358
36603
  const findings = scanText(text, "mcp-config", defs.defs, rel);
36359
36604
  const servers = Object.entries(config2.mcpServers ?? {});
36360
36605
  const local = servers.filter(([, e]) => typeof e["command"] === "string");
@@ -36403,7 +36648,7 @@ Tell the user. They can undo this with: exorcist vault restore ${r.value.id}`
36403
36648
  }
36404
36649
 
36405
36650
  // src/index.ts
36406
- var VERSION = "0.3.7";
36651
+ var VERSION = "0.3.8";
36407
36652
  var ctx = {
36408
36653
  cwd: process.cwd(),
36409
36654
  approved: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exorcist-98/mcp-server",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
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.",