fix: input hardening (CRIT-2, HIGH-2, HIGH-3, HIGH-5)#22
Merged
SPerekrestova merged 5 commits intomainfrom Mar 25, 2026
Merged
Conversation
Add min_length=1 and max_length=200 per-item validation to the drugs list in InteractionsRequest. Previously empty strings were accepted and produced garbage interaction results from OpenFDA. Fixes QA report HIGH-2. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevents server crash (HTTP 500) when NER model receives very large input. 5000 chars covers any realistic pill label or packaging text. Fixes QA report CRIT-2. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevents reflected XSS if raw_text is rendered in a browser without escaping. Tags are removed but text content is preserved. Fixes QA report HIGH-3. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
NER model sometimes extracts hyphens, dots, or other garbage from packaging text (e.g. NDC codes). These are now rejected before RxNorm lookup. Catches the '-' drug bug from QA report. Fixes QA report HIGH-5 (partial — full fix via NER fine-tuning). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use StringConstraints(strip_whitespace=True) so " " is stripped to "" and then rejected by min_length=1. Caught by code review. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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
/interactions(HIGH-2)/analyzetext input to prevent server crash (CRIT-2)raw_textresponse to prevent reflected XSS (HIGH-3)-and...(HIGH-5 partial)strip_whitespace(from code review)Test plan
<script>tags stripped from/analyzeresponse-no longer appears in drug results🤖 Generated with Claude Code