diff --git a/extension/jest.config.cjs b/extension/jest.config.cjs index 6b16a30..8d044db 100644 --- a/extension/jest.config.cjs +++ b/extension/jest.config.cjs @@ -105,10 +105,10 @@ module.exports = { lines: 68, }, "./src/rules/": { - statements: 90, - branches: 77, - functions: 95, - lines: 90, + statements: 91, + branches: 78, + functions: 96, + lines: 91, }, }, }; diff --git a/extension/src/rules/__tests__/prompt-injection-redact.test.ts b/extension/src/rules/__tests__/prompt-injection-redact.test.ts index 0b12ac6..70382fe 100644 --- a/extension/src/rules/__tests__/prompt-injection-redact.test.ts +++ b/extension/src/rules/__tests__/prompt-injection-redact.test.ts @@ -176,4 +176,40 @@ describe("prompt-injection-redact", () => { expect(document.querySelector(`.${PLACEHOLDER_CLASS}`)).toBeNull(); expect(document.body.textContent).toContain(FIXTURES.IGNORE_ALL); }); + + describe("findContainer escalation", () => { + // When injection text lives directly in
with no block-level + // ancestor, the rule must not redact — wrapping in a placeholder + // would black out the whole page. findContainer returns null on the + // BODY/HTML guard. + it("does not redact text that is a direct child of ", () => { + document.body.innerHTML = ""; + document.body.append(document.createTextNode(FIXTURES.IGNORE_ALL)); + + promptInjectionRedactRule.apply(document.body); + + expect(document.querySelector(`.${PLACEHOLDER_CLASS}`)).toBeNull(); + expect(document.body.textContent).toContain(FIXTURES.IGNORE_ALL); + }); + + // When the only ancestor is a non-block element (a bare