fix(security): expand filter sanitization to remaining GUID sites + LIKE wildcards#61
Merged
Merged
Conversation
… LIKE wildcards Follow-ups to PR #57: - Apply sanitizeGuid() to userService.getUserProfile() and contact-logs actions (both User_GUID filters), bringing all GUID interpolations under the same validation as contactService.getContactByGuid(). - Add sanitizeLikeValue() that also escapes %, _, and \ in addition to single quotes. Use it in contactService.contactSearch() with an ESCAPE '\' clause so wildcards in user input are treated literally. - Fix misleading "UUID v4 pattern" doc comment in filter-sanitize.ts — the regex accepts any UUID variant (MP GUIDs are not guaranteed v4). - Update userService and contact-logs action tests to use valid-format GUID fixtures (required now that sanitizeGuid validates them) and add an invalid-GUID throws case for getUserProfile(). - Rename test constant in contactService.test.ts not-found case to validButUnknownGuid for clarity. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Follow-ups to #57 covering the review notes that were not addressed in that PR:
sanitizeGuid()for consistency withcontactService.getContactByGuid():userService.getUserProfile()(src/services/userService.ts:64)createContactLogandupdateContactLogactions (src/components/contact-logs/actions.ts:54,107)sanitizeLikeValue()escapes\,%,_, and'.contactSearch()now uses it with anESCAPE '\'clause so user input like50%matches a literal "50%" instead of acting as a wildcard.filter-sanitize.tscorrected — the regex accepts any UUID variant, not specifically v4 (MP GUIDs aren't guaranteed v4).userService.test.tsandcontact-logs/actions.test.ts(required now thatsanitizeGuidvalidates them), plus an invalid-GUID throws case forgetUserProfile().contactService.test.tstovalidButUnknownGuidfor intent clarity.Not addressed (out of scope)
Numeric ID interpolations in
userService.ts:75,80andcontactLogService.ts:76,99,116are TypeScriptnumber-typed and not injectable as strings.Test plan
npm run test:run— 240/240 passnpm run lint— cleancontactSearch("100%")returns rows containing literal "100%" instead of treating%as a wildcardgetUserProfile("not-a-guid")throws "Invalid GUID format"