Skip to content

Commit 9a63eca

Browse files
committed
test(agent-bff): document the deliberate non-string html cast
1 parent 20b2eb4 commit 9a63eca

5 files changed

Lines changed: 0 additions & 16 deletions

File tree

packages/agent-bff/src/action/action-execute-mapper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ export function mapActionExecuteResult(raw: unknown): ActionExecuteMapped {
9292
type: 'success',
9393
message: typeof body.success === 'string' ? body.success : null,
9494
invalidated: relationships.filter((name): name is string => typeof name === 'string'),
95-
// Untrusted agent output sanitized at the BFF boundary (PRD-1095); a non-string value
96-
// relays as null exactly as before.
9795
html: sanitizeActionHtml(body.html),
9896
},
9997
};

packages/agent-bff/src/action/action-routes-middleware.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ async function handleExecute({
138138
}
139139

140140
if (error instanceof ActionFormValidationError) {
141-
// The agent's Error-result html is the same untrusted output as the success html, so it
142-
// goes through the same sanitizer; a non-string value yields no details rather than a 500.
143141
const html = sanitizeActionHtml(error.html);
144142

145143
throw actionError(error.message, html === null ? undefined : { html });
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import sanitizeHtml from 'sanitize-html';
22

3-
/**
4-
* The agent's action-result html is untrusted output: an action can interpolate record data into
5-
* it, so the BFF sanitizes it at this trust boundary before relaying (PRD-1095). The library's
6-
* default allowlist keeps rich text (paragraphs, emphasis, links, tables, lists) and drops active
7-
* content: script/style/iframe/svg/img tags, on* attributes, javascript:/data: URLs. A non-string
8-
* value is an unchecked agent-JSON cast, not html: null is relayed instead of throwing inside the
9-
* sanitizer.
10-
*/
113
export default function sanitizeActionHtml(html: unknown): string | null {
124
return typeof html === 'string' ? sanitizeHtml(html) : null;
135
}

packages/agent-bff/test/action/action-execute-mapper.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ describe('mapActionExecuteResult', () => {
1919
});
2020
});
2121

22-
// PRD-1095: the agent's html is untrusted output (it can interpolate record data), so the BFF
23-
// sanitizes it with an allowlist before relaying. Safe markup survives; active markup does not.
2422
it('sanitizes the success html: safe markup kept, active markup stripped', () => {
2523
expect(
2624
mapActionExecuteResult({

packages/agent-bff/test/action/action-routes-middleware.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,6 @@ describe('action execute', () => {
665665
});
666666
});
667667

668-
// PRD-1095: the same untrusted agent html travels in a native action Error's details; the
669-
// sanitizer applies here too, and a non-string html yields no details rather than a 500.
670668
it('sanitizes the html carried by a native action Error in details', async () => {
671669
const form = makeAction({
672670
execute: jest.fn(async () => {

0 commit comments

Comments
 (0)