feat: add content sanitization for user-provided content#210
Open
github-actions[bot] wants to merge 1 commit into
Open
feat: add content sanitization for user-provided content#210github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Co-authored-by: shaftoe <shaftoe@users.noreply.github.com>
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
Implements content sanitization for all user-provided text before it enters the LLM prompt context. Closes #209.
Approach: No 3rd party library
Regarding the question about using 3rd party libraries — after evaluating the options, a self-contained utility is the better fit here:
sanitize-html: 7 dependencies (includingpostcss,htmlparser2), designed for HTML sanitization — overkill for stripping HTML comments from Markdown textdeghost: The most relevant library (zero-dep invisible Unicode stripper), but it's v0.0.1 with a single publisher and zero track record. That's a supply-chain risk for a GitHub Action.The regexes target immutable standards (Unicode character categories, HTML comment syntax) — they require the same "maintenance" as knowing that
\nmeans newline. No library update will ever improve<!--[\s\S]*?-->.Changes
New file:
src/platform/github/sanitize.tssanitizeContent(text: string): string— strips three categories of hidden content:<!-- ... -->) — invisible in rendered Markdown but visible to LLMs\n,\r,\t)Integration points
src/platform/github/context.ts— sanitizes issue/PR bodies (viaCONTEXT_EXTRACTORS) and comment bodies (ingetComment())src/platform/github/tools/thread.ts— sanitizes:buildThreadResult()transformComment()fetchPRReviewComments()Tests:
tests/platform/github/sanitize.spec.ts22 test cases covering:
\n,\r,\t)Validation