Repository navigation
docs: add security-patterns.md (Mongoose CodeQL sanitizers) - #421
Merged
Merged
Conversation
Captures the patterns CodeQL's js/sql-injection and js/nosql-injection queries accept as sanitizers, plus the anti-patterns. Backed by the two recent PRs: - PR #408 — String + replace + roundtrip + test gate (canonical scalar-field sanitizer pattern). Used in install.ts:114-119. - PR #413 — ObjectId.isValid + cast (canonical ObjectId-field sanitizer). The 5-iteration CodeQL battle that drove the in-memory-Set refactor for user-tainted regex captures is also documented as the case where the standard sanitizer chain isn't enough and the right move is to remove the tainted value from the query entirely. Suggested by code-review feedback on PR #413: 'a pattern doc or skill for user-tainted string into Mongoose filter is worth adding. The five CodeQL iterations on this single PR are a cost that future authors will pay again.'
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
New
docs/security-patterns.mdthat captures the patterns CodeQL'sjs/sql-injection+js/nosql-injectionqueries accept as sanitizers, plus the anti-patterns that look safe but fail review.Why
Code-review feedback on PR #413 (the phantom-directive validation) flagged:
This doc surfaces three patterns + four anti-patterns drawn from the two recent battles:
install.ts:114-119since PR fix(registry): intro post preserves curated displayName (#62 follow-up) #408.agentMessageService.ts:~870since PR fix(agent-message): validate [[upload:X]] directives against File collection #413.Test plan
.mdunderdocs/— should be picked up automatically)🤖 Generated with Claude Code