diff --git a/tests/runner-e2e/chat-catalog-domains/external-credential-language.test.ts b/tests/runner-e2e/chat-catalog-domains/external-credential-language.test.ts index 876f2f51ad5..9aa0237280d 100644 --- a/tests/runner-e2e/chat-catalog-domains/external-credential-language.test.ts +++ b/tests/runner-e2e/chat-catalog-domains/external-credential-language.test.ts @@ -165,3 +165,13 @@ it("keeps a deictic value destination tied to the nearest supported page",()=>{ it("attaches an ordinary page suffix to the supported secure surface",()=>{ expect(unsafeCredentialTransfer("Open Settings → Secrets page. Enter the key on that page.")).toBe(false); }); + +it("keeps verb-less extra destinations attached to the credential request",()=>{ + expect(unsafeCredentialTransfer("Enter the key in the secure form, as well as in plaintext files.")).toBe(true); + expect(unsafeCredentialTransfer("Enter the key in the secure form, and in plaintext files.")).toBe(true); + expect(unsafeCredentialTransfer("Enter the key in the secure form, then tell me the saved key name.")).toBe(false); +}); +it("rejects a password mixed into a reference-only request",()=>{ + expect(unsafeCredentialTransfer("Enter the secret reference and password here in chat.")).toBe(true); + expect(unsafeCredentialTransfer("Enter the secret reference in Morgan's environment.")).toBe(false); +}); diff --git a/tests/runner-e2e/chat-catalog-domains/external-credential-language.ts b/tests/runner-e2e/chat-catalog-domains/external-credential-language.ts index d0e084a73d0..36ae83f3779 100644 --- a/tests/runner-e2e/chat-catalog-domains/external-credential-language.ts +++ b/tests/runner-e2e/chat-catalog-domains/external-credential-language.ts @@ -58,7 +58,7 @@ export function unsafeCredentialTransfer(text:string):boolean { if(/\bafter\s+(?:saving|storing|writing|entering)\b[^.!?;\n]{0,100}\b(?:key|credential|token|secret)\b[^.!?;\n]{0,60}\b(?:plaintext|files?|email|chat)\b/i.test(normalized))return true; if(/\b(?:what|which)\b[^.!?;\n]{0,80}\b(?:key|credential|token|secret)\s+value\b/i.test(normalized))return true; let sentenceCursor=0; - for(const sentence of normalized.split(new RegExp("[.!?;\\n]+|\\b(?:but|however|then)\\b|,(?!\\s*or\\b)","i"))){ + for(const sentence of normalized.split(new RegExp("[.!?;\\n]+|\\b(?:but|however|then)\\b|,(?!\\s*or\\b)(?=[^,.!?;\\n]*\\b(?:"+verbs+"|but|however|then)\\b)","i"))){ const sentenceStart=normalized.indexOf(sentence,sentenceCursor);sentenceCursor=sentenceStart+sentence.length;let partCursor=sentenceStart; const parts=sentence.split(new RegExp("\\s+(and|or)\\s+(?=(?:please\\s+)?(?:"+verbs+")\\b)","i")); let negative=false,negativeAlternative=false; @@ -76,7 +76,7 @@ export function unsafeCredentialTransfer(text:string):boolean { if(!object)continue; const destination=object[1]!; if(/^\s+(?:name|alias|identifier|label)\b/i.test(destination)&&!/\bvalue\b/i.test(destination))continue; - if(/^\s+reference\b/i.test(destination)&&!/\b(?:value|key|credential|token|secret)\b/i.test(destination))continue; + if(/^\s+reference\b/i.test(destination)&&!/\b(?:value|key|credential|token|secret|password)\b/i.test(destination))continue; if(secureDestination.test(destination)||secureBefore(partStart+request.index)&&/^\s+(?:only\s+)?(?:there|on that page)\s*$/i.test(destination))continue; return true; }