fix(security): escape codegen strings and redact diagnostic body#930
Merged
fix(security): escape codegen strings and redact diagnostic body#930
Conversation
1. candidateToJs: escape single quotes in site, name, domain, and arg name/type fields to prevent syntax errors in generated JS adapters. Previously only description and help fields were escaped. 2. diagnostic: pass network request body through redactText() to prevent sensitive data (JWT, bearer tokens) from leaking into repair context. responseBody/responsePreview already used sanitizeCapturedValue which calls redactText, but the body field only had truncation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two bugs identified during post-migration first-principles review:
site,name,domain, and argname/typefields were written into generated JS adapter files without escaping single quotes. If any of these contained', the generated adapter would have a syntax error. Now all string literals in codegen use.replace(/'/g, "\\'")redactNetworkRequesttruncated thebodyfield but did not pass it throughredactText(), meaning JWTs or bearer tokens in response bodies could leak into AI repair context.responseBodyandresponsePreviewalready usedsanitizeCapturedValue→redactText, butbodywas missedTest plan
src/generate-verified.test.ts— 28 tests passedsrc/diagnostic.test.ts— 15 tests passed