Repository navigation
fix(checks): fail closed on a redact error and carry the session caller on replies - #10
Conversation
… or on cancel (ENG-965)
…end (ENG-961)" This reverts commit a731dd9.
PR Summary by QodoFail closed on redaction errors and preserve caller context on replies
AI Description
Diagram
High-Level Assessment
Files changed (17)
|
Code Review by Qodo
1.
|
…ed mid-call (ENG-965)
|
Code review by qodo was updated up to the latest commit 94811bb |
|
Code review by qodo was updated up to the latest commit 861b327 |
|
Code review by qodo was updated up to the latest commit 826f2e6 |
|
Code review by qodo was updated up to the latest commit 7d089fd |
|
Code review by qodo was updated up to the latest commit 8048505 |
The redactor fails closed and masks every result string, and replies the gateway sends on its own carry the session's caller.
checks/redact.go: maskscontent[].text,content[].resource.text,contents[].textand every string value ofstructuredContentintools/call,resources/readandtasks/resultresults.structuredContentis scanned once; keys, numbers and unmasked strings stay byte for byte. Nesting past 128 levels, or a canceled request, denies the result.content,contents,structuredContent,textandresourceare read. Object keys, other spellings and a duplicate of one of those keys are not masked. README and the hook godoc say so.-32010"result withheld: redaction failed" and the session lives. Themcp.tool_deniedevent (ruleredact) has the same fixed reason. The hook's own error can quote the text, so it never enters a reply, an event or a log line.mcp.redactedstays one event per message;redactionssums every field.fieldnames the masked fields, comma-joined when there are several.context.Background(). They now carry the values of the session's latest POST, so aTokenSourceresolves the same caller. The S2C pipeline gets the same context.ssestream opens once per session with the opener's credential; a rotated token reaches message POSTs, not that stream.structuredContenttable of 1,000 rows by 10 columns makes 10,000 calls, and hoop's agent hook makes one DLP network call per string.mcp.MethodTasksResult. Nothing else changes.Part of ENG-965
Part of ENG-961
Testing
Result: PII in structured results, embedded resources and task results is now masked, a failing masker blocks the result instead of leaking it, and the gateway's own replies to a server carry the caller's latest token.
Tested on
dbdf63ab3(QA round 2 atd5d7e0ddb; later commits are docs only) againstv0.1.7, through a test host that embeds the gateway with a regex Redact hook. Test data only.94811bb(Qodo review) withholds a result with an ambiguous key or a hook canceled mid-call; unit tests only.861b327and826f2e6report a message refused before the pipeline (invalid params, folded field, unknown tool) to the observer as a deny with no tool:TestAMessageRefusedBeforeThePipelineIsObserved, which fails without it.7d089fd(hoop QA) withholds a result, or a read field, of an unexpected type:TestRedactDeniesAFieldOfAnUnexpectedType, whose 9 deny cases fail without it.structuredContent,resource.textandtasks/result; on the branch they are masked, and keys, a 20-digit id,42,trueandnullare unchanged.resources/readwas already masked.-32010, the next call on the session works, and the audit reason holds no text.sampling/createMessagedenial and the 6 dropped-ping replies carry the latest POST's token.What it solves: teams that put an MCP server behind hoop with masking on get no PII through structured or task results and no leak on a masker outage. Users get it when hoop bumps to this release.
TestRedactHookErrorDeniesResult; through the gateway, session survives:TestRedactHookErrorWithholdsResultTestRedactStructuredContentEveryString(exact bytes out),TestRedactNestedResourceText,TestRedactResourcesRead,TestRedactTasksResult; through the gateway:TestRedactMasksTasksResultTestRedactStructuredContentDepthCap; cancel:TestRedactStopsOnCancel. QA's 9000-deep probe: 0.69 s before, 0.3 ms now.TestRedactCountsPerMessageTestServerRequestReplyCarriesSessionCaller(real passthrough source, upstream sees the token),TestDroppedServerRequestReplyCarriesSessionCallerTestSSEStreamUsesSessionOpenerCredentialTestSSEStreamUsesSessionOpenerCredential, which pins existing behaviour.