@exorcist-98/mcp-server 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/definitions/EX-002-ai-instructions.yaml +1 -1
- package/definitions/EX-035-sandbox-mcp-off.yaml +1 -1
- package/definitions/EX-037-hide-action-from-user.yaml +8 -1
- package/definitions/EX-075-unrelated-order.yaml +37 -0
- package/dist/index.mjs +383 -141
- package/package.json +1 -1
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.
|
|
40
|
+
"exorcist": { "command": "npx", "args": ["-y", "@exorcist-98/mcp-server@0.3.9"] }
|
|
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
|
|
@@ -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 =
|
|
7086
|
+
let _sch = resolve11.call(this, root, ref);
|
|
7087
7087
|
if (_sch === void 0) {
|
|
7088
7088
|
const schema2 = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
7089
7089
|
const { schemaId } = this.opts;
|
|
@@ -7110,7 +7110,7 @@ var require_compile = __commonJS({
|
|
|
7110
7110
|
function sameSchemaEnv(s1, s2) {
|
|
7111
7111
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
7112
7112
|
}
|
|
7113
|
-
function
|
|
7113
|
+
function resolve11(root, ref) {
|
|
7114
7114
|
let sch;
|
|
7115
7115
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
7116
7116
|
ref = sch;
|
|
@@ -7974,7 +7974,7 @@ var require_fast_uri = __commonJS({
|
|
|
7974
7974
|
}
|
|
7975
7975
|
return uri;
|
|
7976
7976
|
}
|
|
7977
|
-
function
|
|
7977
|
+
function resolve11(baseURI, relativeURI, options) {
|
|
7978
7978
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
7979
7979
|
const {
|
|
7980
7980
|
parsed: baseParsed,
|
|
@@ -8010,50 +8010,50 @@ var require_fast_uri = __commonJS({
|
|
|
8010
8010
|
schemelessOptions.skipEscape = true;
|
|
8011
8011
|
return serialize(resolved, schemelessOptions);
|
|
8012
8012
|
}
|
|
8013
|
-
function resolveComponent(base,
|
|
8013
|
+
function resolveComponent(base, relative8, options, skipNormalization) {
|
|
8014
8014
|
const target = {};
|
|
8015
8015
|
if (!skipNormalization) {
|
|
8016
8016
|
base = parse4(serialize(base, options), options);
|
|
8017
|
-
|
|
8017
|
+
relative8 = parse4(serialize(relative8, options), options);
|
|
8018
8018
|
}
|
|
8019
8019
|
options = options || {};
|
|
8020
|
-
if (!options.tolerant &&
|
|
8021
|
-
target.scheme =
|
|
8022
|
-
target.userinfo =
|
|
8023
|
-
target.host =
|
|
8024
|
-
target.port =
|
|
8025
|
-
target.path = removeDotSegments(
|
|
8026
|
-
target.query =
|
|
8020
|
+
if (!options.tolerant && relative8.scheme) {
|
|
8021
|
+
target.scheme = relative8.scheme;
|
|
8022
|
+
target.userinfo = relative8.userinfo;
|
|
8023
|
+
target.host = relative8.host;
|
|
8024
|
+
target.port = relative8.port;
|
|
8025
|
+
target.path = removeDotSegments(relative8.path || "");
|
|
8026
|
+
target.query = relative8.query;
|
|
8027
8027
|
} else {
|
|
8028
|
-
if (
|
|
8029
|
-
target.userinfo =
|
|
8030
|
-
target.host =
|
|
8031
|
-
target.port =
|
|
8032
|
-
target.path = removeDotSegments(
|
|
8033
|
-
target.query =
|
|
8028
|
+
if (relative8.userinfo !== void 0 || relative8.host !== void 0 || relative8.port !== void 0) {
|
|
8029
|
+
target.userinfo = relative8.userinfo;
|
|
8030
|
+
target.host = relative8.host;
|
|
8031
|
+
target.port = relative8.port;
|
|
8032
|
+
target.path = removeDotSegments(relative8.path || "");
|
|
8033
|
+
target.query = relative8.query;
|
|
8034
8034
|
} else {
|
|
8035
|
-
if (!
|
|
8035
|
+
if (!relative8.path) {
|
|
8036
8036
|
target.path = base.path;
|
|
8037
|
-
if (
|
|
8038
|
-
target.query =
|
|
8037
|
+
if (relative8.query !== void 0) {
|
|
8038
|
+
target.query = relative8.query;
|
|
8039
8039
|
} else {
|
|
8040
8040
|
target.query = base.query;
|
|
8041
8041
|
}
|
|
8042
8042
|
} else {
|
|
8043
|
-
if (
|
|
8044
|
-
target.path = removeDotSegments(
|
|
8043
|
+
if (relative8.path[0] === "/") {
|
|
8044
|
+
target.path = removeDotSegments(relative8.path);
|
|
8045
8045
|
} else {
|
|
8046
8046
|
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
8047
8047
|
if (baseHasAuthority && !base.path) {
|
|
8048
|
-
target.path = "/" +
|
|
8048
|
+
target.path = "/" + relative8.path;
|
|
8049
8049
|
} else if (!base.path) {
|
|
8050
|
-
target.path =
|
|
8050
|
+
target.path = relative8.path;
|
|
8051
8051
|
} else {
|
|
8052
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
8052
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative8.path;
|
|
8053
8053
|
}
|
|
8054
8054
|
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
8055
8055
|
}
|
|
8056
|
-
target.query =
|
|
8056
|
+
target.query = relative8.query;
|
|
8057
8057
|
}
|
|
8058
8058
|
target.userinfo = base.userinfo;
|
|
8059
8059
|
target.host = base.host;
|
|
@@ -8061,7 +8061,7 @@ var require_fast_uri = __commonJS({
|
|
|
8061
8061
|
}
|
|
8062
8062
|
target.scheme = base.scheme;
|
|
8063
8063
|
}
|
|
8064
|
-
target.fragment =
|
|
8064
|
+
target.fragment = relative8.fragment;
|
|
8065
8065
|
return target;
|
|
8066
8066
|
}
|
|
8067
8067
|
function equal(uriA, uriB, options) {
|
|
@@ -8365,7 +8365,7 @@ var require_fast_uri = __commonJS({
|
|
|
8365
8365
|
var fastUri = {
|
|
8366
8366
|
SCHEMES,
|
|
8367
8367
|
normalize: normalize3,
|
|
8368
|
-
resolve:
|
|
8368
|
+
resolve: resolve11,
|
|
8369
8369
|
resolveComponent,
|
|
8370
8370
|
equal,
|
|
8371
8371
|
serialize,
|
|
@@ -11810,14 +11810,14 @@ var init_severity_paths = __esm({
|
|
|
11810
11810
|
|
|
11811
11811
|
// ../core/src/walker.ts
|
|
11812
11812
|
import { opendir, stat, open, realpath } from "node:fs/promises";
|
|
11813
|
-
import { join as join5, relative as
|
|
11813
|
+
import { join as join5, relative as relative3, extname, basename as basename3, isAbsolute as isAbsolute3 } from "node:path";
|
|
11814
11814
|
function isAgentFacing(rel, role) {
|
|
11815
11815
|
if (!AGENT_FACING_ROLES.has(role)) return false;
|
|
11816
11816
|
return !(role === "config" && LOCKFILE_NAMES.has(rel.split("/").pop() ?? ""));
|
|
11817
11817
|
}
|
|
11818
11818
|
function classifyFile(rel) {
|
|
11819
11819
|
const norm = rel.replace(/\\/g, "/");
|
|
11820
|
-
const base =
|
|
11820
|
+
const base = basename3(norm);
|
|
11821
11821
|
const ext = extname(norm).toLowerCase();
|
|
11822
11822
|
if (base === "AGENTS.md" || base === "AGENT.md" || base === "CLAUDE.md" || base === "CLAUDE.local.md" || base === "GEMINI.md" || base === ".cursorrules" || base === ".windsurfrules" || base === ".clinerules" || norm.startsWith(".clinerules/") || norm.startsWith(".cursor/rules/") || norm.startsWith(".windsurf/rules/") || norm.startsWith(".amazonq/rules/") || norm === ".github/copilot-instructions.md" || norm.startsWith(".github/instructions/") || norm.startsWith(".github/prompts/") || /^\.claude\/(commands|agents|skills)\//.test(norm) || base === "SKILL.md" || base === "POWER.md" || /^power\/(?:[^/]+\/)*steering\/[^/]+$/.test(norm) || base.startsWith("README") || norm.startsWith(".kiro/steering/")) return "instruction";
|
|
11823
11823
|
if (/^power\/(?:[^/]+\/)*mcp\.json$/.test(norm) || norm.endsWith(".kiro/settings/mcp.json") || norm.endsWith(".cursor/mcp.json") || norm.endsWith(".vscode/mcp.json") || norm.endsWith(".amazonq/mcp.json") || norm.endsWith(".gemini/settings.json") || norm.endsWith(".claude/settings.json") || norm.endsWith(".claude/settings.local.json") || norm === "mcp.json" || norm === ".mcp.json" || base === "claude_desktop_config.json") return "mcp-config";
|
|
@@ -11861,7 +11861,7 @@ async function* walkPathsIn(root, dir) {
|
|
|
11861
11861
|
}
|
|
11862
11862
|
for await (const entry of dh) {
|
|
11863
11863
|
const absPath = join5(dir, entry.name);
|
|
11864
|
-
const rel =
|
|
11864
|
+
const rel = relative3(root, absPath).replace(/\\/g, "/");
|
|
11865
11865
|
if (entry.isDirectory()) {
|
|
11866
11866
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
11867
11867
|
yield { rel, isDirectory: true };
|
|
@@ -11886,7 +11886,7 @@ async function* fileRecord(ctx2, rel, readPath, size, link) {
|
|
|
11886
11886
|
}
|
|
11887
11887
|
if (size > ctx2.maxFileSize) {
|
|
11888
11888
|
if (!agent) {
|
|
11889
|
-
if (!TRUNCATE_ROLES.has(role) || LOCKFILE_NAMES.has(
|
|
11889
|
+
if (!TRUNCATE_ROLES.has(role) || LOCKFILE_NAMES.has(basename3(rel))) {
|
|
11890
11890
|
ctx2.note({ kind: "skipped", rel, reason: "too large", agentFacing: false });
|
|
11891
11891
|
return;
|
|
11892
11892
|
}
|
|
@@ -11917,14 +11917,14 @@ async function* walkDir(ctx2, dir, realDir, chain, isRoot = false) {
|
|
|
11917
11917
|
dh = await opendir(dir);
|
|
11918
11918
|
} catch (err2) {
|
|
11919
11919
|
if (isRoot) throw err2;
|
|
11920
|
-
const rel =
|
|
11920
|
+
const rel = relative3(ctx2.root, dir).replace(/\\/g, "/");
|
|
11921
11921
|
ctx2.note({ kind: "unreadable", rel, reason: reasonOf(err2), agentFacing: true });
|
|
11922
11922
|
return;
|
|
11923
11923
|
}
|
|
11924
11924
|
try {
|
|
11925
11925
|
for await (const entry of dh) {
|
|
11926
11926
|
const absPath = join5(dir, entry.name);
|
|
11927
|
-
const rel =
|
|
11927
|
+
const rel = relative3(ctx2.root, absPath).replace(/\\/g, "/");
|
|
11928
11928
|
if (entry.isDirectory()) {
|
|
11929
11929
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
11930
11930
|
const real = join5(realDir, entry.name);
|
|
@@ -11964,7 +11964,7 @@ async function* walkDir(ctx2, dir, realDir, chain, isRoot = false) {
|
|
|
11964
11964
|
}
|
|
11965
11965
|
}
|
|
11966
11966
|
} catch (err2) {
|
|
11967
|
-
const rel =
|
|
11967
|
+
const rel = relative3(ctx2.root, dir).replace(/\\/g, "/");
|
|
11968
11968
|
ctx2.note({ kind: "unreadable", rel, reason: reasonOf(err2), agentFacing: true });
|
|
11969
11969
|
}
|
|
11970
11970
|
}
|
|
@@ -12006,7 +12006,7 @@ var init_walker = __esm({
|
|
|
12006
12006
|
".nyc_output"
|
|
12007
12007
|
]);
|
|
12008
12008
|
isInside = (root, target) => {
|
|
12009
|
-
const rel =
|
|
12009
|
+
const rel = relative3(root, target);
|
|
12010
12010
|
return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
|
|
12011
12011
|
};
|
|
12012
12012
|
TRUNCATE_ROLES = /* @__PURE__ */ new Set(["docs", "code", "config", "manifest"]);
|
|
@@ -20575,7 +20575,7 @@ var Protocol = class {
|
|
|
20575
20575
|
return;
|
|
20576
20576
|
}
|
|
20577
20577
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
20578
|
-
await new Promise((
|
|
20578
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
|
|
20579
20579
|
options?.signal?.throwIfAborted();
|
|
20580
20580
|
}
|
|
20581
20581
|
} catch (error2) {
|
|
@@ -20592,7 +20592,7 @@ var Protocol = class {
|
|
|
20592
20592
|
*/
|
|
20593
20593
|
request(request, resultSchema, options) {
|
|
20594
20594
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
20595
|
-
return new Promise((
|
|
20595
|
+
return new Promise((resolve11, reject2) => {
|
|
20596
20596
|
const earlyReject = (error2) => {
|
|
20597
20597
|
reject2(error2);
|
|
20598
20598
|
};
|
|
@@ -20670,7 +20670,7 @@ var Protocol = class {
|
|
|
20670
20670
|
if (!parseResult.success) {
|
|
20671
20671
|
reject2(parseResult.error);
|
|
20672
20672
|
} else {
|
|
20673
|
-
|
|
20673
|
+
resolve11(parseResult.data);
|
|
20674
20674
|
}
|
|
20675
20675
|
} catch (error2) {
|
|
20676
20676
|
reject2(error2);
|
|
@@ -20932,12 +20932,12 @@ var Protocol = class {
|
|
|
20932
20932
|
}
|
|
20933
20933
|
} catch {
|
|
20934
20934
|
}
|
|
20935
|
-
return new Promise((
|
|
20935
|
+
return new Promise((resolve11, reject2) => {
|
|
20936
20936
|
if (signal.aborted) {
|
|
20937
20937
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
20938
20938
|
return;
|
|
20939
20939
|
}
|
|
20940
|
-
const timeoutId = setTimeout(
|
|
20940
|
+
const timeoutId = setTimeout(resolve11, interval);
|
|
20941
20941
|
signal.addEventListener("abort", () => {
|
|
20942
20942
|
clearTimeout(timeoutId);
|
|
20943
20943
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -22078,7 +22078,7 @@ var McpServer = class {
|
|
|
22078
22078
|
let task = createTaskResult.task;
|
|
22079
22079
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
22080
22080
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
22081
|
-
await new Promise((
|
|
22081
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollInterval));
|
|
22082
22082
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
22083
22083
|
if (!updatedTask) {
|
|
22084
22084
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -22742,12 +22742,12 @@ var StdioServerTransport = class {
|
|
|
22742
22742
|
this.onclose?.();
|
|
22743
22743
|
}
|
|
22744
22744
|
send(message) {
|
|
22745
|
-
return new Promise((
|
|
22745
|
+
return new Promise((resolve11) => {
|
|
22746
22746
|
const json2 = serializeMessage(message);
|
|
22747
22747
|
if (this._stdout.write(json2)) {
|
|
22748
|
-
|
|
22748
|
+
resolve11();
|
|
22749
22749
|
} else {
|
|
22750
|
-
this._stdout.once("drain",
|
|
22750
|
+
this._stdout.once("drain", resolve11);
|
|
22751
22751
|
}
|
|
22752
22752
|
});
|
|
22753
22753
|
}
|
|
@@ -22759,7 +22759,7 @@ import { homedir as homedir6 } from "node:os";
|
|
|
22759
22759
|
import { delimiter } from "node:path";
|
|
22760
22760
|
|
|
22761
22761
|
// src/tools.ts
|
|
22762
|
-
import { existsSync as
|
|
22762
|
+
import { existsSync as existsSync5, readFileSync as readFileSync7, realpathSync as realpathSync4, statSync as statSync6 } from "node:fs";
|
|
22763
22763
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
22764
22764
|
|
|
22765
22765
|
// ../shield/src/canonical.ts
|
|
@@ -22788,11 +22788,49 @@ 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 (; ; ) {
|
|
22801
|
+
try {
|
|
22802
|
+
return join(realpathSync.native(cur), rest);
|
|
22803
|
+
} catch {
|
|
22804
|
+
}
|
|
22805
|
+
const up = dirname(cur);
|
|
22806
|
+
if (up === cur) return resolve(p);
|
|
22807
|
+
rest = join(basename(cur), rest);
|
|
22808
|
+
cur = up;
|
|
22809
|
+
}
|
|
22810
|
+
};
|
|
22811
|
+
const fold2 = (p) => process.platform === "darwin" || IS_WINDOWS ? p.toLowerCase() : p;
|
|
22812
|
+
const d = fold2(real(dir));
|
|
22813
|
+
const c = fold2(real(cwd));
|
|
22814
|
+
if (d === fold2(real(join(homedir(), ".config", "exorcist-98")))) return null;
|
|
22815
|
+
const rel = relative(c, d);
|
|
22816
|
+
if (rel === "" || !rel.startsWith("..") && !isAbsolute(rel)) return "it is inside the current project folder";
|
|
22817
|
+
for (let cur = d; ; cur = dirname(cur)) {
|
|
22818
|
+
if (existsSync(join(cur, ".git"))) return `it is inside a git repository (${cur})`;
|
|
22819
|
+
if (dirname(cur) === cur) break;
|
|
22820
|
+
}
|
|
22821
|
+
let st;
|
|
22822
|
+
try {
|
|
22823
|
+
st = lstatSync(dir);
|
|
22824
|
+
} catch {
|
|
22825
|
+
return null;
|
|
22826
|
+
}
|
|
22827
|
+
if (st.isSymbolicLink()) return "it is a symbolic link";
|
|
22828
|
+
if (!st.isDirectory()) return "it is not a folder";
|
|
22829
|
+
const me = uid();
|
|
22830
|
+
if (!IS_WINDOWS && me !== void 0 && st.uid !== me) return "it is not owned by you";
|
|
22831
|
+
if (!IS_WINDOWS && (st.mode & 63) !== 0) return "other users or your group can open it (a private folder is mode 0700)";
|
|
22832
|
+
return null;
|
|
22833
|
+
}
|
|
22796
22834
|
function userConfigDir(env = process.env) {
|
|
22797
22835
|
const o = env["EXORCIST_USER_DIR"];
|
|
22798
22836
|
if (o && isAbsolute(o)) return o;
|
|
@@ -22800,6 +22838,14 @@ function userConfigDir(env = process.env) {
|
|
|
22800
22838
|
const base = xdg && isAbsolute(xdg) ? xdg : join(homedir(), ".config");
|
|
22801
22839
|
return join(base, "exorcist-98");
|
|
22802
22840
|
}
|
|
22841
|
+
function userDirRefusal(env = process.env, cwd = process.cwd()) {
|
|
22842
|
+
const o = env["EXORCIST_USER_DIR"];
|
|
22843
|
+
const xdg = env["XDG_CONFIG_HOME"];
|
|
22844
|
+
const overridden = o && isAbsolute(o) || xdg && isAbsolute(xdg);
|
|
22845
|
+
if (!overridden) return null;
|
|
22846
|
+
const problem = userDirOverrideProblem(userConfigDir(env), cwd);
|
|
22847
|
+
return problem === null ? null : `the user-level folder ${userConfigDir(env)} (set by EXORCIST_USER_DIR or XDG_CONFIG_HOME) was refused: ${problem}`;
|
|
22848
|
+
}
|
|
22803
22849
|
var uid = () => typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
22804
22850
|
function ensurePrivateDir(dir) {
|
|
22805
22851
|
try {
|
|
@@ -22842,6 +22888,10 @@ function readKeyFile(path) {
|
|
|
22842
22888
|
}
|
|
22843
22889
|
var cache = /* @__PURE__ */ new Map();
|
|
22844
22890
|
function getUserKey(o = {}) {
|
|
22891
|
+
if (o.dir === void 0) {
|
|
22892
|
+
const refused = userDirRefusal();
|
|
22893
|
+
if (refused !== null) return { ok: false, error: refused };
|
|
22894
|
+
}
|
|
22845
22895
|
const dir = o.dir ?? userConfigDir();
|
|
22846
22896
|
const cached2 = cache.get(dir);
|
|
22847
22897
|
if (cached2) return { ok: true, key: cached2 };
|
|
@@ -22954,7 +23004,13 @@ var PolicySchema = external_exports.object({
|
|
|
22954
23004
|
* opt-in that only the USER-LEVEL policy can set. A project policy, signed or not,
|
|
22955
23005
|
* that asks for it is ignored with a note.
|
|
22956
23006
|
*/
|
|
22957
|
-
sessionRelease: external_exports.enum(["os", "terminal", "notification-code"]).optional()
|
|
23007
|
+
sessionRelease: external_exports.enum(["os", "terminal", "notification-code"]).optional(),
|
|
23008
|
+
/**
|
|
23009
|
+
* The event log (m19-log, LG-2). `off` stops the Shield writing events after one final event that says so.
|
|
23010
|
+
* Only the USER-LEVEL policy can set it: a project policy that sets `events` is ignored with a note, and the
|
|
23011
|
+
* environment variable EXORCIST_EVENTS is ignored (an MCP config can set a server's environment).
|
|
23012
|
+
*/
|
|
23013
|
+
events: external_exports.enum(["on", "off"]).optional()
|
|
22958
23014
|
}).strict();
|
|
22959
23015
|
|
|
22960
23016
|
// ../shield/src/approval.ts
|
|
@@ -26265,7 +26321,13 @@ var MatchSchema = external_exports.object({
|
|
|
26265
26321
|
max_length: external_exports.number().int().min(1),
|
|
26266
26322
|
classes: external_exports.array(external_exports.string()).min(1),
|
|
26267
26323
|
severity: external_exports.enum(["critical", "high", "medium", "low"])
|
|
26268
|
-
}).optional()
|
|
26324
|
+
}).optional(),
|
|
26325
|
+
// regex only: for a file whose path matches one of these patterns, the look-behinds of the regex (the order a
|
|
26326
|
+
// concealment must follow within 300 characters of one paragraph) are dropped and replaced by this: an order word
|
|
26327
|
+
// (`order_regex`) anywhere else in the file. Used for instruction files, where an order and its concealment may be
|
|
26328
|
+
// far apart (m19-scan SN-5). Both are needed for the wide reading.
|
|
26329
|
+
wide_paths: external_exports.array(external_exports.string().refine(compiles, "wide_paths entries must be valid regular expressions")).optional(),
|
|
26330
|
+
order_regex: external_exports.string().optional()
|
|
26269
26331
|
}).superRefine((val, ctx2) => {
|
|
26270
26332
|
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
26333
|
if (!hasAny) {
|
|
@@ -26283,7 +26345,7 @@ var MatchSchema = external_exports.object({
|
|
|
26283
26345
|
if ((val.exclude_regex !== void 0 || val.validate !== void 0) && val.regex === void 0 && val.json_path === void 0) {
|
|
26284
26346
|
ctx2.addIssue({ code: external_exports.ZodIssueCode.custom, message: "match.exclude_regex and match.validate need match.regex or match.json_path" });
|
|
26285
26347
|
}
|
|
26286
|
-
for (const key of ["regex", "value_regex", "exclude_regex", "file_regex", "quoted_example_cues", "negated_cues", "decoded_flag_regex"]) {
|
|
26348
|
+
for (const key of ["regex", "value_regex", "exclude_regex", "file_regex", "quoted_example_cues", "negated_cues", "decoded_flag_regex", "order_regex"]) {
|
|
26287
26349
|
const pattern = val[key];
|
|
26288
26350
|
if (pattern !== void 0 && !compiles(pattern)) {
|
|
26289
26351
|
ctx2.addIssue({
|
|
@@ -26296,7 +26358,7 @@ var MatchSchema = external_exports.object({
|
|
|
26296
26358
|
var VirusDefinitionSchema = external_exports.object({
|
|
26297
26359
|
id: external_exports.string().regex(/^EX-\d{3}$/, "id must match EX-NNN"),
|
|
26298
26360
|
title: external_exports.string().min(1, "title must not be empty"),
|
|
26299
|
-
severity: external_exports.enum(["critical", "high", "medium", "low"]),
|
|
26361
|
+
severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
|
|
26300
26362
|
applies_to: external_exports.array(external_exports.string()).min(1, "applies_to must have at least one entry"),
|
|
26301
26363
|
match: MatchSchema,
|
|
26302
26364
|
owasp: external_exports.array(external_exports.string()).min(1, "owasp must have at least one reference"),
|
|
@@ -26349,7 +26411,7 @@ async function loadDefinitions(dir) {
|
|
|
26349
26411
|
init_zod();
|
|
26350
26412
|
import { createHash } from "node:crypto";
|
|
26351
26413
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
26352
|
-
import { basename, isAbsolute as isAbsolute2, join as join3, relative, resolve } from "node:path";
|
|
26414
|
+
import { basename as basename2, isAbsolute as isAbsolute2, join as join3, relative as relative2, resolve as resolve2 } from "node:path";
|
|
26353
26415
|
var ManifestSchema = external_exports.object({
|
|
26354
26416
|
id: external_exports.string(),
|
|
26355
26417
|
kind: external_exports.enum(["mcp-server", "file", "exorcise"]),
|
|
@@ -26359,11 +26421,11 @@ var ManifestSchema = external_exports.object({
|
|
|
26359
26421
|
});
|
|
26360
26422
|
var VAULT_PATH = /^(?:(.*)\/)?\.exorcist\/vault\/([^/]+)\/(.+)$/;
|
|
26361
26423
|
var inside = (dir, p) => {
|
|
26362
|
-
const r =
|
|
26424
|
+
const r = relative2(dir, p);
|
|
26363
26425
|
return r === "" || !r.startsWith("..") && !isAbsolute2(r);
|
|
26364
26426
|
};
|
|
26365
26427
|
function vaultBackupChecker(root) {
|
|
26366
|
-
const absRoot =
|
|
26428
|
+
const absRoot = resolve2(root);
|
|
26367
26429
|
const manifests = /* @__PURE__ */ new Map();
|
|
26368
26430
|
return (rel, bytes) => {
|
|
26369
26431
|
const m = VAULT_PATH.exec(rel.replace(/\\/g, "/"));
|
|
@@ -26385,14 +26447,14 @@ function vaultBackupChecker(root) {
|
|
|
26385
26447
|
const e = manifests.get(key);
|
|
26386
26448
|
if (!e) return null;
|
|
26387
26449
|
const digest = createHash("sha256").update(bytes).digest("hex");
|
|
26388
|
-
const target =
|
|
26450
|
+
const target = resolve2(e.target);
|
|
26389
26451
|
if (e.kind === "exorcise") {
|
|
26390
26452
|
if (target !== project) return null;
|
|
26391
26453
|
const f = e.files?.find((x) => `files/${x.rel}` === inner);
|
|
26392
26454
|
return f && f.sha256 === digest ? { id, kind: e.kind } : null;
|
|
26393
26455
|
}
|
|
26394
26456
|
if (!inside(project, target)) return null;
|
|
26395
|
-
const expected = e.kind === "mcp-server" ? "entry.json" : `files/${
|
|
26457
|
+
const expected = e.kind === "mcp-server" ? "entry.json" : `files/${basename2(target)}`;
|
|
26396
26458
|
return inner === expected && e.sha256 === digest ? { id, kind: e.kind } : null;
|
|
26397
26459
|
};
|
|
26398
26460
|
}
|
|
@@ -26584,6 +26646,30 @@ var EXEC_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
26584
26646
|
"powershell",
|
|
26585
26647
|
"pwsh"
|
|
26586
26648
|
]);
|
|
26649
|
+
var INTERPRETERS = /* @__PURE__ */ new Set([
|
|
26650
|
+
"sh",
|
|
26651
|
+
"bash",
|
|
26652
|
+
"zsh",
|
|
26653
|
+
"fish",
|
|
26654
|
+
"dash",
|
|
26655
|
+
"node",
|
|
26656
|
+
"nodejs",
|
|
26657
|
+
"deno",
|
|
26658
|
+
"bun",
|
|
26659
|
+
"python",
|
|
26660
|
+
"python3",
|
|
26661
|
+
"perl",
|
|
26662
|
+
"ruby",
|
|
26663
|
+
"php",
|
|
26664
|
+
"lua",
|
|
26665
|
+
"tsx",
|
|
26666
|
+
"ts-node",
|
|
26667
|
+
"osascript",
|
|
26668
|
+
"powershell",
|
|
26669
|
+
"pwsh",
|
|
26670
|
+
"env",
|
|
26671
|
+
"xargs"
|
|
26672
|
+
]);
|
|
26587
26673
|
var NETWORK_ALLOW = /^(?:WebFetch|Bash\(\s*(?:curl|wget|ssh|scp|nc|ncat|ftp|rsync|telnet)\b)/;
|
|
26588
26674
|
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
26675
|
var ALLOW_ENTRY = /^(?:Bash|Shell|PowerShell|Run)\(([^)]*)\)$/;
|
|
@@ -26715,7 +26801,7 @@ function readProjectSettings(rel, text) {
|
|
|
26715
26801
|
const arg = (m[1] ?? "").trim();
|
|
26716
26802
|
const wild = /^(.+?)(?::\s*\*+|\s+\*+)$/.exec(arg);
|
|
26717
26803
|
const cmd = (wild ? wild[1] ?? "" : arg).trim();
|
|
26718
|
-
const bareInterpreter = !wild && EXEC_COMMANDS.has(cmd) &&
|
|
26804
|
+
const bareInterpreter = !wild && EXEC_COMMANDS.has(cmd) && INTERPRETERS.has(cmd);
|
|
26719
26805
|
if (wild && EXEC_COMMANDS.has(cmd) || bareInterpreter) add("allow-exec", JSON.stringify(e), e, loud ? "high" : "medium");
|
|
26720
26806
|
}
|
|
26721
26807
|
}
|
|
@@ -30005,6 +30091,62 @@ function getRegex(pattern, flags2) {
|
|
|
30005
30091
|
regexCache.set(key, re2);
|
|
30006
30092
|
return re2;
|
|
30007
30093
|
}
|
|
30094
|
+
function stripLookbehinds(pattern) {
|
|
30095
|
+
let out = "";
|
|
30096
|
+
let i = 0;
|
|
30097
|
+
while (i < pattern.length) {
|
|
30098
|
+
if (pattern.startsWith("(?<=", i)) {
|
|
30099
|
+
let depth = 0;
|
|
30100
|
+
let j = i;
|
|
30101
|
+
let inClass = false;
|
|
30102
|
+
for (; j < pattern.length; j++) {
|
|
30103
|
+
const c = pattern[j];
|
|
30104
|
+
if (c === "\\") {
|
|
30105
|
+
j++;
|
|
30106
|
+
continue;
|
|
30107
|
+
}
|
|
30108
|
+
if (inClass) {
|
|
30109
|
+
if (c === "]") inClass = false;
|
|
30110
|
+
continue;
|
|
30111
|
+
}
|
|
30112
|
+
if (c === "[") inClass = true;
|
|
30113
|
+
else if (c === "(") depth++;
|
|
30114
|
+
else if (c === ")") {
|
|
30115
|
+
depth--;
|
|
30116
|
+
if (depth === 0) break;
|
|
30117
|
+
}
|
|
30118
|
+
}
|
|
30119
|
+
i = j + 1;
|
|
30120
|
+
continue;
|
|
30121
|
+
}
|
|
30122
|
+
if (pattern[i] === "\\") {
|
|
30123
|
+
out += pattern.slice(i, i + 2);
|
|
30124
|
+
i += 2;
|
|
30125
|
+
continue;
|
|
30126
|
+
}
|
|
30127
|
+
out += pattern[i];
|
|
30128
|
+
i++;
|
|
30129
|
+
}
|
|
30130
|
+
return out;
|
|
30131
|
+
}
|
|
30132
|
+
function isWideFile(match, rel) {
|
|
30133
|
+
return match.order_regex !== void 0 && match.wide_paths !== void 0 && match.wide_paths.some((p) => getRegex(p, "i").test(rel));
|
|
30134
|
+
}
|
|
30135
|
+
var MAX_ORDER_HITS = 5e3;
|
|
30136
|
+
function orderSpans(order, text) {
|
|
30137
|
+
const re2 = getRegex(order, "gi");
|
|
30138
|
+
const out = [];
|
|
30139
|
+
re2.lastIndex = 0;
|
|
30140
|
+
let m;
|
|
30141
|
+
while (out.length < MAX_ORDER_HITS && (m = re2.exec(text)) !== null) {
|
|
30142
|
+
if (m[0].length === 0) {
|
|
30143
|
+
re2.lastIndex++;
|
|
30144
|
+
continue;
|
|
30145
|
+
}
|
|
30146
|
+
out.push([m.index, m.index + m[0].length]);
|
|
30147
|
+
}
|
|
30148
|
+
return out;
|
|
30149
|
+
}
|
|
30008
30150
|
function escapeCodePoint(hit) {
|
|
30009
30151
|
const hex = hit.codePoint.toString(16).toUpperCase();
|
|
30010
30152
|
return hit.codePoint > 65535 ? `\\u{${hex}}` : `\\u${hex.padStart(4, "0")}`;
|
|
@@ -30215,12 +30357,19 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
30215
30357
|
fix: def.fix
|
|
30216
30358
|
};
|
|
30217
30359
|
const mine = [];
|
|
30360
|
+
const narrow = [];
|
|
30218
30361
|
if (match.regex) {
|
|
30219
|
-
const
|
|
30362
|
+
const wide = isWideFile(match, file.rel);
|
|
30363
|
+
const re2 = getRegex(wide ? stripLookbehinds(match.regex) : match.regex, "gi");
|
|
30220
30364
|
mine.push(addLogical(re2, norm.plain));
|
|
30221
30365
|
if (vis) mine.push(addLogical(re2, vis.text));
|
|
30366
|
+
if (wide) {
|
|
30367
|
+
const own = getRegex(match.regex, "gi");
|
|
30368
|
+
narrow.push(addLogical(own, norm.plain));
|
|
30369
|
+
if (vis) narrow.push(addLogical(own, vis.text));
|
|
30370
|
+
}
|
|
30222
30371
|
}
|
|
30223
|
-
active.push({ def, base, keep, jobs: mine });
|
|
30372
|
+
active.push({ def, base, keep, jobs: mine, narrow });
|
|
30224
30373
|
}
|
|
30225
30374
|
let results = jobs.length > 0 ? guarded(jobs, limitMs) : [];
|
|
30226
30375
|
const timedOut = /* @__PURE__ */ new Set();
|
|
@@ -30245,10 +30394,10 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
30245
30394
|
}
|
|
30246
30395
|
return out2;
|
|
30247
30396
|
};
|
|
30248
|
-
for (const { def, base, keep, jobs: mine } of active) {
|
|
30397
|
+
for (const { def, base, keep, jobs: mine, narrow } of active) {
|
|
30249
30398
|
const { match } = def;
|
|
30250
30399
|
if (match.regex) {
|
|
30251
|
-
if (mine.some(timedOutLogical)) {
|
|
30400
|
+
if ([...mine, ...narrow].some(timedOutLogical)) {
|
|
30252
30401
|
findings.push({
|
|
30253
30402
|
...base,
|
|
30254
30403
|
severity: agentFacing ? base.severity : "medium",
|
|
@@ -30263,8 +30412,11 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
30263
30412
|
mine.forEach((logicalId, k) => {
|
|
30264
30413
|
const src = k === 0 || !vis ? norm.plain : vis.text;
|
|
30265
30414
|
const toPlain = k === 0 || !vis ? (i) => i : (i) => vis.map[i] ?? i;
|
|
30415
|
+
const orders = isWideFile(match, file.rel) ? orderSpans(match.order_regex, src) : null;
|
|
30416
|
+
const ownHits = narrow.length > 0 ? new Set(matchesOf(narrow[k] ?? -1).map(([i]) => i)) : null;
|
|
30266
30417
|
for (const [index2, text] of matchesOf(logicalId)) {
|
|
30267
30418
|
if (!keep(text)) continue;
|
|
30419
|
+
if (orders && !ownHits?.has(index2) && !orders.some(([s, e]) => e <= index2 || s >= index2 + text.length)) continue;
|
|
30268
30420
|
const at = toPlain(index2);
|
|
30269
30421
|
if (seen.has(at)) continue;
|
|
30270
30422
|
if (!ctx2.allows(def, text, at, src, index2)) continue;
|
|
@@ -30395,7 +30547,7 @@ function runSignatures(file, norm, defs, limitMs = REGEX_TIME_LIMIT_MS) {
|
|
|
30395
30547
|
const out = lowered.size === 0 ? findings : findings.map((f) => lowered.has(f.ruleId) ? { ...f, severity: "low" } : f);
|
|
30396
30548
|
return sameLineGroups(out, defs);
|
|
30397
30549
|
}
|
|
30398
|
-
var SEVERITY_RANK = { critical: 4, high: 3, medium: 2, low: 1 };
|
|
30550
|
+
var SEVERITY_RANK = { critical: 4, high: 3, medium: 2, low: 1, info: 0 };
|
|
30399
30551
|
function sameLineGroups(findings, defs) {
|
|
30400
30552
|
const groupOf = new Map(defs.filter((d) => d.same_line_group).map((d) => [d.id, d.same_line_group]));
|
|
30401
30553
|
if (groupOf.size === 0) return findings;
|
|
@@ -30845,11 +30997,68 @@ function extractPy(text, budget, out, dyn = []) {
|
|
|
30845
30997
|
if (r.dyn !== null) dyn.push(r.dyn);
|
|
30846
30998
|
if (r.after > 0) after = r.after;
|
|
30847
30999
|
}
|
|
30848
|
-
|
|
31000
|
+
const doc = docstringAfter(text, after, limit);
|
|
31001
|
+
if (lit === null) lit = doc;
|
|
31002
|
+
else if (doc !== null && PY_ARGS_SECTION.test(doc.value)) out.push(toFound(doc));
|
|
30849
31003
|
if (lit) out.push(toFound(lit));
|
|
30850
31004
|
}
|
|
30851
31005
|
}
|
|
30852
31006
|
}
|
|
31007
|
+
var PY_ARGS_SECTION = /^[ \t]*(?:Args|Arguments|Parameters|Params)[ \t]*:/m;
|
|
31008
|
+
var FIELD_KEYS = ["type", "enum", "items", "properties", "format", "default", "minimum", "maximum", "anyOf", "oneOf"];
|
|
31009
|
+
var SCHEMA_WORD = /properties|inputSchema|input_schema|parameters/;
|
|
31010
|
+
var MCP_TEXT = /modelcontextprotocol|FastMCP|McpServer|mcp\.server|inputSchema|input_schema|@mcp\.tool|\.tool\(|registerTool/;
|
|
31011
|
+
var nearSchema = (text, at) => SCHEMA_WORD.test(text.slice(Math.max(0, at - 3e3), at));
|
|
31012
|
+
function extractFieldsTs(text, out, dyn) {
|
|
31013
|
+
const keyBudget = { left: MAX_SITES };
|
|
31014
|
+
for (const at of indexesOf(text, "description", keyBudget)) {
|
|
31015
|
+
if (isIdent(text[at - 1])) continue;
|
|
31016
|
+
const limit = lim(text, at);
|
|
31017
|
+
let j = at + "description".length;
|
|
31018
|
+
if (text[j] === '"' || text[j] === "'") j++;
|
|
31019
|
+
j = skipTrivia(text, j, "ts", limit);
|
|
31020
|
+
if (text[j] !== ":") continue;
|
|
31021
|
+
const open4 = enclosingObject(text, at);
|
|
31022
|
+
if (open4 < 0 || !hasKeyAtTop(text, open4, FIELD_KEYS, limit)) continue;
|
|
31023
|
+
const p = skipTrivia(text, j + 1, "ts", limit);
|
|
31024
|
+
const l = isQuote(text[p]) ? readLiteral(text, p, "ts", limit) : null;
|
|
31025
|
+
if (l) {
|
|
31026
|
+
out.push(toFound(l));
|
|
31027
|
+
if (text[skipTrivia(text, l.next, "ts", limit)] === "+" && nearSchema(text, at)) dyn.push(p);
|
|
31028
|
+
} else if (nearSchema(text, at)) dyn.push(p);
|
|
31029
|
+
}
|
|
31030
|
+
const describeBudget = { left: MAX_SITES };
|
|
31031
|
+
for (const at of indexesOf(text, ".describe(", describeBudget)) {
|
|
31032
|
+
const limit = lim(text, at);
|
|
31033
|
+
const p = skipTrivia(text, at + ".describe(".length, "ts", limit);
|
|
31034
|
+
if (text[p] === ")") continue;
|
|
31035
|
+
const l = isQuote(text[p]) ? readLiteral(text, p, "ts", limit) : null;
|
|
31036
|
+
if (l) {
|
|
31037
|
+
out.push(toFound(l));
|
|
31038
|
+
if (text[skipTrivia(text, l.next, "ts", limit)] === "+") dyn.push(p);
|
|
31039
|
+
} else dyn.push(p);
|
|
31040
|
+
}
|
|
31041
|
+
}
|
|
31042
|
+
function extractFieldsPy(text, out, dyn) {
|
|
31043
|
+
const fieldBudget = { left: MAX_SITES };
|
|
31044
|
+
for (const at of indexesOf(text, "Field(", fieldBudget)) {
|
|
31045
|
+
if (isIdent(text[at - 1])) continue;
|
|
31046
|
+
const { lit, dyn: d } = findKeyString(text, at + 5, "py", lim(text, at), "=");
|
|
31047
|
+
if (lit) out.push(toFound(lit));
|
|
31048
|
+
if (d !== null) dyn.push(d);
|
|
31049
|
+
}
|
|
31050
|
+
const annBudget = { left: MAX_SITES };
|
|
31051
|
+
for (const at of indexesOf(text, "Annotated[", annBudget)) {
|
|
31052
|
+
if (isIdent(text[at - 1])) continue;
|
|
31053
|
+
const limit = lim(text, at);
|
|
31054
|
+
const first = skipTrivia(text, at + "Annotated[".length, "py", limit);
|
|
31055
|
+
const e = skipArgument(text, first, "py", limit);
|
|
31056
|
+
if (e < 0 || text[e] !== ",") continue;
|
|
31057
|
+
const p = skipTrivia(text, e + 1, "py", limit);
|
|
31058
|
+
const l = readPyString(text, p, limit);
|
|
31059
|
+
if (l) out.push(toFound(l));
|
|
31060
|
+
}
|
|
31061
|
+
}
|
|
30853
31062
|
function extractGo(text, budget, out) {
|
|
30854
31063
|
for (const at of indexesOf(text, "WithDescription(", budget)) {
|
|
30855
31064
|
if (isIdent(text[at - 1])) continue;
|
|
@@ -30859,9 +31068,10 @@ function extractGo(text, budget, out) {
|
|
|
30859
31068
|
if (l) out.push(toFound(l));
|
|
30860
31069
|
}
|
|
30861
31070
|
}
|
|
30862
|
-
function extractAll(text, lang) {
|
|
31071
|
+
function extractAll(text, lang, mcpPath = false) {
|
|
30863
31072
|
const out = [];
|
|
30864
31073
|
const dyn = [];
|
|
31074
|
+
const dynFields = [];
|
|
30865
31075
|
const budget = { left: MAX_SITES };
|
|
30866
31076
|
if (lang === "ts") {
|
|
30867
31077
|
extractTs(text, budget, out, dyn);
|
|
@@ -30872,11 +31082,20 @@ function extractAll(text, lang) {
|
|
|
30872
31082
|
extractPyConstructor(text, { left: MAX_SITES }, out, dyn);
|
|
30873
31083
|
} else if (lang === "go") extractGo(text, budget, out);
|
|
30874
31084
|
else extractOther(text, lang, budget, out);
|
|
31085
|
+
if ((lang === "ts" || lang === "py") && (mcpPath || out.length > 0 || dyn.length > 0 || MCP_TEXT.test(text))) {
|
|
31086
|
+
if (lang === "ts") extractFieldsTs(text, out, dynFields);
|
|
31087
|
+
else extractFieldsPy(text, out, dynFields);
|
|
31088
|
+
}
|
|
30875
31089
|
const seen = /* @__PURE__ */ new Set();
|
|
30876
|
-
|
|
31090
|
+
const taken = new Set(dyn);
|
|
31091
|
+
return {
|
|
31092
|
+
found: out.filter((f) => !seen.has(f.offset) && seen.add(f.offset)).sort((a, b) => a.offset - b.offset),
|
|
31093
|
+
dyn: [...taken].sort((a, b) => a - b),
|
|
31094
|
+
dynFields: [...new Set(dynFields)].filter((d) => !taken.has(d)).sort((a, b) => a - b)
|
|
31095
|
+
};
|
|
30877
31096
|
}
|
|
30878
|
-
function extract(text, lang) {
|
|
30879
|
-
return extractAll(text, lang).found;
|
|
31097
|
+
function extract(text, lang, mcpPath = false) {
|
|
31098
|
+
return extractAll(text, lang, mcpPath).found;
|
|
30880
31099
|
}
|
|
30881
31100
|
function enclosingObject(text, at) {
|
|
30882
31101
|
let depth = 0;
|
|
@@ -30997,17 +31216,22 @@ function scanDynamicToolDescriptions(file, text, defs) {
|
|
|
30997
31216
|
const lang = languageOf(file.rel);
|
|
30998
31217
|
if (!def || lang === null || typeof text !== "string" || lang !== "ts" && lang !== "py") return [];
|
|
30999
31218
|
if (!/mcp/i.test(file.rel) && !/modelcontextprotocol|FastMCP|McpServer|mcp\.server/.test(text)) return [];
|
|
31000
|
-
|
|
31219
|
+
const { dyn, dynFields } = extractAll(text, lang, true);
|
|
31220
|
+
const make = (at, span, what) => ({
|
|
31001
31221
|
source: "signature",
|
|
31002
31222
|
ruleId: def.id,
|
|
31003
31223
|
title: def.title,
|
|
31004
31224
|
severity: "medium",
|
|
31005
31225
|
file: file.rel,
|
|
31006
31226
|
...positionOf(text, at),
|
|
31007
|
-
span
|
|
31227
|
+
span,
|
|
31008
31228
|
owasp: def.owasp,
|
|
31009
|
-
fix:
|
|
31010
|
-
})
|
|
31229
|
+
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.`
|
|
31230
|
+
});
|
|
31231
|
+
return [
|
|
31232
|
+
...dyn.map((at) => make(at, "tool description built at run time: not checked", "tool description")),
|
|
31233
|
+
...dynFields.map((at) => make(at, "tool field description built at run time: not checked", "field description of a tool parameter"))
|
|
31234
|
+
];
|
|
31011
31235
|
} catch {
|
|
31012
31236
|
return [];
|
|
31013
31237
|
}
|
|
@@ -31065,7 +31289,7 @@ function scanSourceTools(file, text, defs) {
|
|
|
31065
31289
|
const lang = languageOf(file.rel);
|
|
31066
31290
|
if (!def || lang === null || typeof text !== "string") return [];
|
|
31067
31291
|
const out = [];
|
|
31068
|
-
for (const s of extract(text, lang)) {
|
|
31292
|
+
for (const s of extract(text, lang, /mcp/i.test(file.rel))) {
|
|
31069
31293
|
for (const hit of scanText(s.text, "mcp-config", [def], file.rel)) {
|
|
31070
31294
|
const idx = Math.min(Math.max(indexOfLineCol(s.text, hit.line, hit.col), 0), s.text.length);
|
|
31071
31295
|
if (isQuietHint(hit.span, s.text, idx)) continue;
|
|
@@ -31109,8 +31333,8 @@ function sandboxFindings(text, rel) {
|
|
|
31109
31333
|
return [{
|
|
31110
31334
|
source: "signature",
|
|
31111
31335
|
ruleId: SANDBOX_RULE_ID,
|
|
31112
|
-
title: mcpOff ? "
|
|
31113
|
-
severity: "
|
|
31336
|
+
title: mcpOff ? "MCP sandboxing is off in this project" : "The command sandbox is off in this project",
|
|
31337
|
+
severity: "info",
|
|
31114
31338
|
file: rel,
|
|
31115
31339
|
line,
|
|
31116
31340
|
col,
|
|
@@ -31207,8 +31431,8 @@ function checkPathSegment(name) {
|
|
|
31207
31431
|
}
|
|
31208
31432
|
|
|
31209
31433
|
// ../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
|
|
31434
|
+
import { closeSync as closeSync2, existsSync as existsSync2, lstatSync as lstatSync2, openSync as openSync2, readdirSync, readSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
31435
|
+
import { isAbsolute as isAbsolute6, join as join8, posix as posix2, relative as relative6, resolve as resolve6, sep } from "node:path";
|
|
31212
31436
|
|
|
31213
31437
|
// ../core/src/install-hooks.ts
|
|
31214
31438
|
var INSTALL_HOOKS = [
|
|
@@ -31570,7 +31794,7 @@ function pmActions(e, scripts = /* @__PURE__ */ new Set()) {
|
|
|
31570
31794
|
}
|
|
31571
31795
|
|
|
31572
31796
|
// ../core/src/shell-analyze.ts
|
|
31573
|
-
import { basename as
|
|
31797
|
+
import { basename as basename4, resolve as resolve5 } from "node:path";
|
|
31574
31798
|
|
|
31575
31799
|
// ../core/src/shell-parse.ts
|
|
31576
31800
|
var MAX_COMMAND_CHARS = 65536;
|
|
@@ -32038,15 +32262,15 @@ function parseShell(command, sub = false) {
|
|
|
32038
32262
|
init_zod();
|
|
32039
32263
|
import { readFileSync as readFileSync4, statSync } from "node:fs";
|
|
32040
32264
|
import { homedir as homedir3 } from "node:os";
|
|
32041
|
-
import { isAbsolute as isAbsolute5, join as join7, normalize as normalize2, relative as
|
|
32265
|
+
import { isAbsolute as isAbsolute5, join as join7, normalize as normalize2, relative as relative5, resolve as resolve4 } from "node:path";
|
|
32042
32266
|
|
|
32043
32267
|
// ../core/src/user-dir-guard.ts
|
|
32044
32268
|
import { homedir as homedir2 } from "node:os";
|
|
32045
|
-
import { dirname, isAbsolute as isAbsolute4, join as join6, relative as
|
|
32269
|
+
import { dirname as dirname2, isAbsolute as isAbsolute4, join as join6, relative as relative4, resolve as resolve3 } from "node:path";
|
|
32046
32270
|
function userKeyDirs(env = process.env) {
|
|
32047
32271
|
const out = /* @__PURE__ */ new Set();
|
|
32048
32272
|
const o = env["EXORCIST_USER_DIR"];
|
|
32049
|
-
if (o && isAbsolute4(o)) out.add(
|
|
32273
|
+
if (o && isAbsolute4(o)) out.add(resolve3(o));
|
|
32050
32274
|
const xdg = env["XDG_CONFIG_HOME"];
|
|
32051
32275
|
out.add(join6(xdg && isAbsolute4(xdg) ? xdg : join6(homedir2(), ".config"), "exorcist-98"));
|
|
32052
32276
|
out.add(join6(homedir2(), ".config", "exorcist-98"));
|
|
@@ -32106,13 +32330,13 @@ function insideProject(raw, cwd) {
|
|
|
32106
32330
|
}
|
|
32107
32331
|
if (!isAbsolute5(p)) return true;
|
|
32108
32332
|
if (cwd === void 0) return !raw.startsWith("~");
|
|
32109
|
-
const rel =
|
|
32333
|
+
const rel = relative5(cwd, resolve4(p));
|
|
32110
32334
|
return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
|
|
32111
32335
|
}
|
|
32112
32336
|
function withinProject(raw, cwd) {
|
|
32113
32337
|
if (raw === "" || /[$`~]|:\/\//.test(raw)) return false;
|
|
32114
32338
|
if (cwd === void 0) return !isAbsolute5(raw) && !normalize2(raw).split(/[\\/]/).includes("..");
|
|
32115
|
-
const rel =
|
|
32339
|
+
const rel = relative5(cwd, resolve4(cwd, raw));
|
|
32116
32340
|
return rel === "" || !rel.startsWith("..") && !isAbsolute5(rel);
|
|
32117
32341
|
}
|
|
32118
32342
|
var anyInside = (list, cwd) => list.split(/[:;]/).some((p) => insideProject(p, cwd));
|
|
@@ -32629,7 +32853,7 @@ var reject = (reason, fix = FIX_SIMPLE) => {
|
|
|
32629
32853
|
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
32854
|
var SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "ksh", "ash", "csh", "tcsh", "fish"]);
|
|
32631
32855
|
var NODE_LIKE = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno"]);
|
|
32632
|
-
var
|
|
32856
|
+
var INTERPRETERS2 = /* @__PURE__ */ new Set(["node", "nodejs", "tsx", "ts-node", "bun", "deno", "python", "python3", "ruby", "perl", "php", "lua", "sh", "bash", "zsh", "dash", "ksh"]);
|
|
32633
32857
|
var KNOWN_PROGRAMS = /* @__PURE__ */ new Set([
|
|
32634
32858
|
// shell builtins and plain utilities
|
|
32635
32859
|
"cd",
|
|
@@ -32941,7 +33165,7 @@ var WRAP_SPECS = {
|
|
|
32941
33165
|
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
33166
|
var SHELL_VALUE_FLAGS = /* @__PURE__ */ new Set(["-o", "+o", "-O", "+O", "--rcfile", "--init-file"]);
|
|
32943
33167
|
function progName(raw) {
|
|
32944
|
-
const b =
|
|
33168
|
+
const b = basename4(raw.replace(/\\/g, "/"));
|
|
32945
33169
|
return b.replace(/\.(exe|cmd|bat|ps1)$/i, "").toLowerCase();
|
|
32946
33170
|
}
|
|
32947
33171
|
var wordsText = (ws) => ws.map((w) => w.text);
|
|
@@ -33061,7 +33285,7 @@ function checkSpecial(prog, f, words2, ctx2) {
|
|
|
33061
33285
|
if (prog === "less" || prog === "more" || prog === "man") {
|
|
33062
33286
|
if (args.some((a) => a.startsWith("--lesskey") || a === "+!" || a.startsWith("+!"))) reject("a pager was given commands to run", FIX_READ_TOOL);
|
|
33063
33287
|
}
|
|
33064
|
-
if (
|
|
33288
|
+
if (INTERPRETERS2.has(prog) || /^python[0-9.]*$/.test(prog)) {
|
|
33065
33289
|
const inlineFlag = (a) => {
|
|
33066
33290
|
if (NODE_LIKE.has(prog) || prog === "nodejs") return a === "-e" || a === "--eval" || a === "-p" || a === "--print" || a === "-pe" || a === "-ep";
|
|
33067
33291
|
if (/^python/.test(prog)) return a === "-c" || /^-[A-Za-z]*c$/.test(a) && a.length <= 4 && a.startsWith("-") && !a.startsWith("--");
|
|
@@ -33246,7 +33470,7 @@ function resolveWords(words2, f, ctx2) {
|
|
|
33246
33470
|
}
|
|
33247
33471
|
pushExec(ctx2, f, words2, raw);
|
|
33248
33472
|
const e = lastExec(ctx2);
|
|
33249
|
-
if (ctx2.mode === "script" && (
|
|
33473
|
+
if (ctx2.mode === "script" && (INTERPRETERS2.has(prog) || /^python/.test(prog))) {
|
|
33250
33474
|
const flags2 = /* @__PURE__ */ new Set(["-e", "-c", "-p", "--eval", "--print", "-r", "-E"]);
|
|
33251
33475
|
const k = e.args.findIndex((a) => flags2.has(a.text));
|
|
33252
33476
|
const flag = e.args[k]?.text;
|
|
@@ -34008,14 +34232,14 @@ function describeHit(h) {
|
|
|
34008
34232
|
}
|
|
34009
34233
|
function readLocalText(pkgDir, rel) {
|
|
34010
34234
|
try {
|
|
34011
|
-
const abs =
|
|
34235
|
+
const abs = resolve6(pkgDir, rel);
|
|
34012
34236
|
const within = (root, p) => {
|
|
34013
|
-
const r =
|
|
34237
|
+
const r = relative6(root, p);
|
|
34014
34238
|
return r !== "" && !r.startsWith("..") && !isAbsolute6(r) && !r.split(sep).includes("..");
|
|
34015
34239
|
};
|
|
34016
|
-
if (!within(pkgDir, abs) || !
|
|
34017
|
-
const real =
|
|
34018
|
-
if (!within(
|
|
34240
|
+
if (!within(pkgDir, abs) || !existsSync2(abs)) return null;
|
|
34241
|
+
const real = realpathSync2(abs);
|
|
34242
|
+
if (!within(realpathSync2(pkgDir), real)) return null;
|
|
34019
34243
|
const st = statSync2(real);
|
|
34020
34244
|
if (!st.isFile() || st.size > MAX_SOURCE_BYTES) return null;
|
|
34021
34245
|
const buf = Buffer.alloc(st.size);
|
|
@@ -34033,7 +34257,7 @@ function readLocalText(pkgDir, rel) {
|
|
|
34033
34257
|
}
|
|
34034
34258
|
|
|
34035
34259
|
// ../core/src/scanner/orchestrator.ts
|
|
34036
|
-
import { dirname as
|
|
34260
|
+
import { dirname as dirname3 } from "node:path";
|
|
34037
34261
|
init_heuristic_engine();
|
|
34038
34262
|
|
|
34039
34263
|
// ../core/src/capabilities.ts
|
|
@@ -34741,7 +34965,7 @@ async function* pathNameFindings(root, def, ignore) {
|
|
|
34741
34965
|
}
|
|
34742
34966
|
}
|
|
34743
34967
|
function lifecycleScanFindings(text, absPath, rel, def) {
|
|
34744
|
-
const dir =
|
|
34968
|
+
const dir = dirname3(absPath);
|
|
34745
34969
|
return lifecycleFindings({ pkgText: text, readLocal: (r) => readLocalText(dir, r) }).map((h) => ({
|
|
34746
34970
|
source: "signature",
|
|
34747
34971
|
ruleId: def.id,
|
|
@@ -34950,7 +35174,7 @@ var FindingSchema = external_exports.object({
|
|
|
34950
35174
|
source: external_exports.enum(["signature", "heuristic"]),
|
|
34951
35175
|
ruleId: external_exports.string(),
|
|
34952
35176
|
title: external_exports.string(),
|
|
34953
|
-
severity: external_exports.enum(["critical", "high", "medium", "low"]),
|
|
35177
|
+
severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
|
|
34954
35178
|
file: external_exports.string(),
|
|
34955
35179
|
// The file name with bidi, zero-width and control characters shown as [U+XXXX] (m18-scanner SC-19).
|
|
34956
35180
|
fileDisplay: external_exports.string().optional(),
|
|
@@ -35189,6 +35413,10 @@ var ENTRIES = {
|
|
|
35189
35413
|
"EX-074": {
|
|
35190
35414
|
headline: "This settings file makes Copilot approve every tool call",
|
|
35191
35415
|
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."
|
|
35416
|
+
},
|
|
35417
|
+
"EX-075": {
|
|
35418
|
+
headline: "This instruction file tells your AI to do something that has nothing to do with the code",
|
|
35419
|
+
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
35420
|
}
|
|
35193
35421
|
};
|
|
35194
35422
|
function plainFor(ruleId, fallbackTitle) {
|
|
@@ -35256,7 +35484,7 @@ var MAX_FILE_BYTES2 = 8 * 1024 * 1024;
|
|
|
35256
35484
|
var OriginStatusSchema = external_exports.enum(["log-s", "blame", "uncommitted", "not-found", "timeout", "error"]);
|
|
35257
35485
|
var TimelineThreatSchema = external_exports.object({
|
|
35258
35486
|
ruleId: external_exports.string(),
|
|
35259
|
-
severity: external_exports.enum(["critical", "high", "medium", "low"]),
|
|
35487
|
+
severity: external_exports.enum(["critical", "high", "medium", "low", "info"]),
|
|
35260
35488
|
file: external_exports.string(),
|
|
35261
35489
|
line: external_exports.number().int().positive(),
|
|
35262
35490
|
title: external_exports.string(),
|
|
@@ -35356,7 +35584,7 @@ init_zod();
|
|
|
35356
35584
|
import { createHash as createHash2, createPrivateKey, createPublicKey, generateKeyPairSync, randomBytes as randomBytes3, sign as edSign, verify as edVerify } from "node:crypto";
|
|
35357
35585
|
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
35586
|
import { homedir as homedir4 } from "node:os";
|
|
35359
|
-
import { basename as
|
|
35587
|
+
import { basename as basename5, join as join11, resolve as resolve7 } from "node:path";
|
|
35360
35588
|
var DEFINITIONS_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
35361
35589
|
MCowBQYDK2VwAyEAn4o+dmOJXIzsygT2CF/3go/1E/bk9Ub16r4hGtJJjhM=
|
|
35362
35590
|
-----END PUBLIC KEY-----
|
|
@@ -35434,7 +35662,7 @@ function parseManifest(manifestBytes) {
|
|
|
35434
35662
|
}
|
|
35435
35663
|
function installedDefinitionsRoot(env = process.env) {
|
|
35436
35664
|
const fromEnv = env["EXORCIST_DEFINITIONS_HOME"];
|
|
35437
|
-
if (fromEnv) return
|
|
35665
|
+
if (fromEnv) return resolve7(fromEnv);
|
|
35438
35666
|
return join11(env["HOME"] || env["USERPROFILE"] || homedir4(), ".exorcist", "definitions");
|
|
35439
35667
|
}
|
|
35440
35668
|
function verifySetFolder(dir, expectedVersion, publicKeyPem) {
|
|
@@ -35443,7 +35671,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
|
|
|
35443
35671
|
const defsDir = join11(dir, "definitions");
|
|
35444
35672
|
for (const [p, kind] of [[join11(dir, MANIFEST_NAME), "file"], [join11(dir, SIGNATURE_NAME), "file"], [defsDir, "dir"]]) {
|
|
35445
35673
|
const st = lstatSync3(p);
|
|
35446
|
-
if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail2(`${
|
|
35674
|
+
if (kind === "file" ? !st.isFile() : !st.isDirectory()) return fail2(`${basename5(p)} is not a plain ${kind === "file" ? "file" : "folder"}`);
|
|
35447
35675
|
}
|
|
35448
35676
|
const manifestBytes = readFileSync5(join11(dir, MANIFEST_NAME));
|
|
35449
35677
|
const bad = verifySignature(manifestBytes, readFileSync5(join11(dir, SIGNATURE_NAME)), publicKeyPem);
|
|
@@ -35472,7 +35700,7 @@ function verifySetFolder(dir, expectedVersion, publicKeyPem) {
|
|
|
35472
35700
|
}
|
|
35473
35701
|
}
|
|
35474
35702
|
function verifyInstalledSet(dir, publicKeyPem = DEFINITIONS_PUBLIC_KEY) {
|
|
35475
|
-
const name =
|
|
35703
|
+
const name = basename5(dir);
|
|
35476
35704
|
if (!isValidVersion(name)) return fail2(`${printable(name)} is not a version folder`);
|
|
35477
35705
|
return verifySetFolder(dir, name, publicKeyPem);
|
|
35478
35706
|
}
|
|
@@ -35516,6 +35744,20 @@ var BaselineSchema = external_exports.object({
|
|
|
35516
35744
|
init_text_decode();
|
|
35517
35745
|
init_image_text();
|
|
35518
35746
|
|
|
35747
|
+
// ../core/src/home-settings.ts
|
|
35748
|
+
init_zod();
|
|
35749
|
+
var Globs = external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]);
|
|
35750
|
+
var RuleSchema2 = external_exports.object({ capability: external_exports.string(), match: Globs.optional().nullable(), exclude: Globs.optional().nullable(), effect: external_exports.string() }).passthrough();
|
|
35751
|
+
var KiroFileSchema = external_exports.object({ rules: external_exports.array(external_exports.unknown()).optional().nullable(), policies: external_exports.array(external_exports.unknown()).optional().nullable() }).passthrough();
|
|
35752
|
+
var AgentSchema = external_exports.object({
|
|
35753
|
+
permissions: external_exports.object({ rules: external_exports.array(external_exports.unknown()).optional().nullable() }).passthrough().optional().nullable(),
|
|
35754
|
+
toolsSettings: external_exports.record(external_exports.unknown()).optional().nullable()
|
|
35755
|
+
}).passthrough();
|
|
35756
|
+
var HIGH_FLAGS = ["executeAllCommands"];
|
|
35757
|
+
var MEDIUM_FLAGS = ["editFiles", "editFilesExternally", "useMcp", "useBrowser"];
|
|
35758
|
+
var SAFE_FLAGS = ["executeSafeCommands", "readFiles", "readFilesExternally"];
|
|
35759
|
+
var ACTION_FLAGS = /* @__PURE__ */ new Set([...HIGH_FLAGS, ...MEDIUM_FLAGS, ...SAFE_FLAGS]);
|
|
35760
|
+
|
|
35519
35761
|
// ../core/src/kiro-evidence.ts
|
|
35520
35762
|
init_zod();
|
|
35521
35763
|
var KiroEventSchema = external_exports.object({
|
|
@@ -35757,8 +35999,8 @@ var LockSchema = external_exports.object({
|
|
|
35757
35999
|
|
|
35758
36000
|
// ../shield/src/vault.ts
|
|
35759
36001
|
import { createHash as createHash3, randomBytes as randomBytes4 } from "node:crypto";
|
|
35760
|
-
import { closeSync as closeSync4, constants as constants3, copyFileSync, existsSync as
|
|
35761
|
-
import { basename as
|
|
36002
|
+
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";
|
|
36003
|
+
import { basename as basename6, dirname as dirname4, isAbsolute as isAbsolute7, join as join12, resolve as resolve8, sep as sep2 } from "node:path";
|
|
35762
36004
|
init_zod();
|
|
35763
36005
|
var SafeRel = external_exports.string().min(1).max(1024).refine(
|
|
35764
36006
|
(p) => !isAbsolute7(p) && !p.includes("\\") && !p.includes("\0") && p.split("/").every((seg) => seg !== "" && seg !== "." && seg !== ".."),
|
|
@@ -35798,9 +36040,9 @@ var entryText = (e) => {
|
|
|
35798
36040
|
};
|
|
35799
36041
|
function ensureSafeVault(vaultDir) {
|
|
35800
36042
|
const me = typeof process.getuid === "function" ? process.getuid() : void 0;
|
|
35801
|
-
const state =
|
|
36043
|
+
const state = dirname4(vaultDir);
|
|
35802
36044
|
try {
|
|
35803
|
-
mkdirSync3(
|
|
36045
|
+
mkdirSync3(dirname4(state), { recursive: true });
|
|
35804
36046
|
for (const d of [state, vaultDir]) {
|
|
35805
36047
|
const st = lstatSync4(d, { throwIfNoEntry: false });
|
|
35806
36048
|
if (st === void 0) {
|
|
@@ -35827,14 +36069,14 @@ function writeFileSafe(path, text) {
|
|
|
35827
36069
|
}
|
|
35828
36070
|
var insideDir = (child, parent) => child === parent || child.startsWith(parent.endsWith(sep2) ? parent : parent + sep2);
|
|
35829
36071
|
function rootFor(vaultDir, target) {
|
|
35830
|
-
const state =
|
|
35831
|
-
if (
|
|
35832
|
-
const project =
|
|
35833
|
-
return insideDir(
|
|
36072
|
+
const state = dirname4(vaultDir);
|
|
36073
|
+
if (basename6(state) !== ".exorcist") return void 0;
|
|
36074
|
+
const project = dirname4(state);
|
|
36075
|
+
return insideDir(resolve8(target), resolve8(project)) ? resolve8(project) : void 0;
|
|
35834
36076
|
}
|
|
35835
36077
|
function realDirOf(target) {
|
|
35836
36078
|
try {
|
|
35837
|
-
return
|
|
36079
|
+
return realpathSync3(dirname4(target));
|
|
35838
36080
|
} catch {
|
|
35839
36081
|
return void 0;
|
|
35840
36082
|
}
|
|
@@ -35855,12 +36097,12 @@ function writeManifest(vaultDir, e) {
|
|
|
35855
36097
|
`);
|
|
35856
36098
|
}
|
|
35857
36099
|
function listEntries(vaultDir) {
|
|
35858
|
-
if (!
|
|
36100
|
+
if (!existsSync3(vaultDir)) return [];
|
|
35859
36101
|
const key = getUserKey();
|
|
35860
36102
|
const out = [];
|
|
35861
36103
|
for (const name of readdirSync3(vaultDir)) {
|
|
35862
36104
|
const file = join12(vaultDir, name, "manifest.json");
|
|
35863
|
-
if (!
|
|
36105
|
+
if (!existsSync3(file)) continue;
|
|
35864
36106
|
try {
|
|
35865
36107
|
const st = lstatSync4(file);
|
|
35866
36108
|
if (!st.isFile()) continue;
|
|
@@ -35894,7 +36136,7 @@ function readConfig(path) {
|
|
|
35894
36136
|
var writeConfig = (path, cfg) => writeFileSync2(path, `${JSON.stringify(cfg, null, 2)}
|
|
35895
36137
|
`, "utf8");
|
|
35896
36138
|
function quarantineServer(o) {
|
|
35897
|
-
const configPath =
|
|
36139
|
+
const configPath = resolve8(o.configPath);
|
|
35898
36140
|
const cfg = readConfig(configPath);
|
|
35899
36141
|
if (!cfg.ok) return cfg;
|
|
35900
36142
|
const entry = cfg.value.mcpServers?.[o.serverName];
|
|
@@ -36094,8 +36336,8 @@ var MAX_HASHED_BYTES = 64 * 1024 * 1024;
|
|
|
36094
36336
|
var MAX_EVENT_BYTES2 = 16 * 1024 * 1024;
|
|
36095
36337
|
|
|
36096
36338
|
// ../shield/src/locate.ts
|
|
36097
|
-
import { existsSync as
|
|
36098
|
-
import { dirname as
|
|
36339
|
+
import { existsSync as existsSync4, readdirSync as readdirSync4, statSync as statSync5 } from "node:fs";
|
|
36340
|
+
import { dirname as dirname5, isAbsolute as isAbsolute8, join as join13, parse as parse3, resolve as resolve9 } from "node:path";
|
|
36099
36341
|
import { fileURLToPath } from "node:url";
|
|
36100
36342
|
function hasDefinitions(dir) {
|
|
36101
36343
|
try {
|
|
@@ -36107,12 +36349,12 @@ function hasDefinitions(dir) {
|
|
|
36107
36349
|
function findDefinitionsDir(o) {
|
|
36108
36350
|
const env = o.env ?? process.env;
|
|
36109
36351
|
const cwd = o.cwd ?? process.cwd();
|
|
36110
|
-
if (o.explicit) return
|
|
36352
|
+
if (o.explicit) return resolve9(cwd, o.explicit);
|
|
36111
36353
|
const fromEnv = env["EXORCIST_DEFINITIONS"];
|
|
36112
|
-
if (fromEnv) return
|
|
36354
|
+
if (fromEnv) return resolve9(cwd, fromEnv);
|
|
36113
36355
|
const installed = findActiveInstalledSet({ env, ...o.publicKeyPem ? { publicKeyPem: o.publicKeyPem } : {} });
|
|
36114
36356
|
if (installed && hasDefinitions(installed.definitionsDir)) return installed.definitionsDir;
|
|
36115
|
-
const here =
|
|
36357
|
+
const here = dirname5(fileURLToPath(o.callerUrl));
|
|
36116
36358
|
const candidates = [join13(here, "..", "definitions"), join13(here, "..", "..", "..", "definitions"), join13(cwd, "definitions")];
|
|
36117
36359
|
return candidates.find(hasDefinitions) ?? null;
|
|
36118
36360
|
}
|
|
@@ -36147,9 +36389,9 @@ function isWrapped(entry) {
|
|
|
36147
36389
|
|
|
36148
36390
|
// src/tools.ts
|
|
36149
36391
|
import { homedir as homedir5 } from "node:os";
|
|
36150
|
-
import { basename as
|
|
36392
|
+
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
36393
|
var quotesWanted = (ctx2, asked) => asked === true && ctx2.noQuotes !== true;
|
|
36152
|
-
var RANK = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
36394
|
+
var RANK = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
|
|
36153
36395
|
var HIDDEN2 = /[\u200B-\u200D\uFEFF\u202A-\u202E\u2066-\u2069\u{E0000}-\u{E007F}]/gu;
|
|
36154
36396
|
var err = (text) => ({ text, isError: true });
|
|
36155
36397
|
function reveal(s) {
|
|
@@ -36159,16 +36401,16 @@ function findDefinitionsDir2(cwd) {
|
|
|
36159
36401
|
return findDefinitionsDir({ callerUrl: import.meta.url, cwd });
|
|
36160
36402
|
}
|
|
36161
36403
|
function resolveInside(cwd, p, roots = [], primary) {
|
|
36162
|
-
const real = (d) =>
|
|
36163
|
-
const extra = roots.filter((r) =>
|
|
36404
|
+
const real = (d) => realpathSync4(d);
|
|
36405
|
+
const extra = roots.filter((r) => existsSync5(r)).map(real);
|
|
36164
36406
|
const first = primary !== void 0 && extra.includes(real(primary)) ? [real(primary)] : [];
|
|
36165
36407
|
const bases = [.../* @__PURE__ */ new Set([...first, real(cwd), ...extra])];
|
|
36166
|
-
const tries = isAbsolute9(p) ? [p] : bases.map((b) =>
|
|
36167
|
-
const found = tries.find((t2) =>
|
|
36408
|
+
const tries = isAbsolute9(p) ? [p] : bases.map((b) => resolve10(b, p));
|
|
36409
|
+
const found = tries.find((t2) => existsSync5(t2));
|
|
36168
36410
|
if (!found) return { ok: false, error: `Path not found: ${p}` };
|
|
36169
|
-
const target =
|
|
36411
|
+
const target = realpathSync4(found);
|
|
36170
36412
|
const base = bases.find((b) => {
|
|
36171
|
-
const rel =
|
|
36413
|
+
const rel = relative7(b, target);
|
|
36172
36414
|
return !rel.startsWith("..") && !isAbsolute9(rel);
|
|
36173
36415
|
});
|
|
36174
36416
|
if (!base) {
|
|
@@ -36200,19 +36442,19 @@ var PROJECT_MARKERS = [
|
|
|
36200
36442
|
"README"
|
|
36201
36443
|
];
|
|
36202
36444
|
function looksLikeProject(dir) {
|
|
36203
|
-
const has = (n) =>
|
|
36445
|
+
const has = (n) => existsSync5(join14(dir, n));
|
|
36204
36446
|
if (has("plugin.json") || has("POWER.md")) return false;
|
|
36205
36447
|
return PROJECT_MARKERS.some(has);
|
|
36206
36448
|
}
|
|
36207
36449
|
var SENSITIVE_IN_HOME = [".ssh", ".aws", ".gnupg", ".kube", ".docker", ".azure", ".config", ".password-store", join14("Library", "Keychains")];
|
|
36208
36450
|
var SENSITIVE_ABSOLUTE = ["/etc", "/private/etc", "/System", "/var/root", "/root"];
|
|
36209
36451
|
var isWithin = (base, p) => {
|
|
36210
|
-
const rel =
|
|
36452
|
+
const rel = relative7(base, p);
|
|
36211
36453
|
return rel === "" || !rel.startsWith("..") && !isAbsolute9(rel);
|
|
36212
36454
|
};
|
|
36213
36455
|
function sensitiveReason(real, home = homedir5()) {
|
|
36214
|
-
const realHome =
|
|
36215
|
-
if (
|
|
36456
|
+
const realHome = existsSync5(home) ? realpathSync4(home) : home;
|
|
36457
|
+
if (dirname6(real) === real) return "it is the filesystem root";
|
|
36216
36458
|
if (isWithin(real, realHome)) return real === realHome ? "it is the home folder" : "it contains the home folder";
|
|
36217
36459
|
for (const n of SENSITIVE_IN_HOME) {
|
|
36218
36460
|
const s = join14(realHome, n);
|
|
@@ -36242,8 +36484,8 @@ async function resolveAllowed(ctx2, p) {
|
|
|
36242
36484
|
}
|
|
36243
36485
|
let folder;
|
|
36244
36486
|
try {
|
|
36245
|
-
const real =
|
|
36246
|
-
folder = statSync6(real).isDirectory() ? real :
|
|
36487
|
+
const real = realpathSync4(p);
|
|
36488
|
+
folder = statSync6(real).isDirectory() ? real : dirname6(real);
|
|
36247
36489
|
} catch {
|
|
36248
36490
|
return first;
|
|
36249
36491
|
}
|
|
@@ -36275,16 +36517,16 @@ function usableRoots(entries, home) {
|
|
|
36275
36517
|
continue;
|
|
36276
36518
|
}
|
|
36277
36519
|
} else if (/^[a-z][a-z0-9+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) continue;
|
|
36278
|
-
if (!isAbsolute9(path) || !
|
|
36520
|
+
if (!isAbsolute9(path) || !existsSync5(path)) continue;
|
|
36279
36521
|
let real;
|
|
36280
36522
|
try {
|
|
36281
36523
|
if (!statSync6(path).isDirectory()) continue;
|
|
36282
|
-
real =
|
|
36524
|
+
real = realpathSync4(path);
|
|
36283
36525
|
} catch {
|
|
36284
36526
|
continue;
|
|
36285
36527
|
}
|
|
36286
|
-
const realHome =
|
|
36287
|
-
if (real ===
|
|
36528
|
+
const realHome = existsSync5(home) ? realpathSync4(home) : home;
|
|
36529
|
+
if (real === resolve10("/") || real === realHome || dirname6(real) === real) continue;
|
|
36288
36530
|
if (!out.includes(real)) out.push(real);
|
|
36289
36531
|
}
|
|
36290
36532
|
return out;
|
|
@@ -36315,7 +36557,7 @@ function describe(findings, limit, quotes) {
|
|
|
36315
36557
|
}
|
|
36316
36558
|
function summary(findings, files) {
|
|
36317
36559
|
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(", ");
|
|
36560
|
+
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
36561
|
const withFindings = new Set(findings.map((f) => f.file)).size;
|
|
36320
36562
|
return `${plural(findings.length, "threat")} in ${plural(withFindings, "file")} (${counts}). Scanned ${plural(files, "file")}.`;
|
|
36321
36563
|
}
|
|
@@ -36327,8 +36569,8 @@ async function scanRepoTool(ctx2, a) {
|
|
|
36327
36569
|
const defs = await loadDefs(ctx2);
|
|
36328
36570
|
if (!defs.ok) return err(defs.error);
|
|
36329
36571
|
const isFile = statSync6(inside2.path).isFile();
|
|
36330
|
-
const root = isFile ?
|
|
36331
|
-
const only = isFile ?
|
|
36572
|
+
const root = isFile ? dirname6(inside2.path) : inside2.path;
|
|
36573
|
+
const only = isFile ? basename7(inside2.path) : null;
|
|
36332
36574
|
const findings = [];
|
|
36333
36575
|
let files = 0;
|
|
36334
36576
|
for await (const ev of scanRepo(root, { definitionsDir: ctx2.definitionsDir })) {
|
|
@@ -36354,7 +36596,7 @@ async function scanMcpConfigTool(ctx2, a) {
|
|
|
36354
36596
|
} catch {
|
|
36355
36597
|
return err(`${a.path} is not valid JSON.`);
|
|
36356
36598
|
}
|
|
36357
|
-
const rel =
|
|
36599
|
+
const rel = relative7(inside2.base, inside2.path);
|
|
36358
36600
|
const findings = scanText(text, "mcp-config", defs.defs, rel);
|
|
36359
36601
|
const servers = Object.entries(config2.mcpServers ?? {});
|
|
36360
36602
|
const local = servers.filter(([, e]) => typeof e["command"] === "string");
|
|
@@ -36403,7 +36645,7 @@ Tell the user. They can undo this with: exorcist vault restore ${r.value.id}`
|
|
|
36403
36645
|
}
|
|
36404
36646
|
|
|
36405
36647
|
// src/index.ts
|
|
36406
|
-
var VERSION = "0.3.
|
|
36648
|
+
var VERSION = "0.3.9";
|
|
36407
36649
|
var ctx = {
|
|
36408
36650
|
cwd: process.cwd(),
|
|
36409
36651
|
approved: [],
|