fix: escape special chars in db password regex character classes - #71
Open
Christian-Sidak wants to merge 1 commit into
Open
fix: escape special chars in db password regex character classes#71Christian-Sidak wants to merge 1 commit into
Christian-Sidak wants to merge 1 commit into
Conversation
The database password patterns contained several characters that are
only valid as literals inside a regex character class when escaped
under strict ECMA-262 rules (the 'v' / Unicode Sets flag):
[ ( ) { } |
These appeared unescaped in the OpenAPI spec and in the generated
Zod schemas, causing LLM provider tool-schema validators to reject
the entire tools/list response with "is not a regex" errors.
Changes:
- Fix src/generated/openapi.json: escape all 19 occurrences of the
bad pattern across the libsql, mariadb, mongo, mysql, postgres and
redis database tools.
- Fix src/generated/tools.ts: same 19 occurrences in the committed
generated file.
- Fix scripts/generate-tools.ts: add sanitizeRegexPattern() /
sanitizeSchemaPatterns() so future pnpm generate runs always emit
v-flag-valid patterns, preventing regressions when the OpenAPI spec
is re-fetched from upstream.
The corrected pattern compiles under both the 'u' and 'v' flags while
matching the same set of passwords as before.
Fixes Dokploy#70
Signed-off-by: Christian Sidak <christian@sentineltech.eu>
Signed-off-by: Christian-Sidak <61099993+Christian-Sidak@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
v/ Unicode Sets flag):(,),{,},|, and[.tools/listwith "is not a regex" when anypatternfield fails to compile as a valid ECMA-262 regex.generate-tools.tsso futurepnpm generateruns always emit v-flag-valid patterns.Changes
src/generated/openapi.json-- 19 pattern values updated (the committed snapshot of the upstream spec)src/generated/tools.ts-- 19 corresponding Zod.regex()calls updatedscripts/generate-tools.ts-- addedsanitizeRegexPattern()+sanitizeSchemaPatterns()helpers; applied during schema-to-Zod conversion so the fix is durable across futurepnpm fetch-openapi && pnpm generaterunsThe corrected pattern compiles under both the
uandvflags and matches the same set of passwords as before (square brackets, curly braces, pipe, and parens are still accepted as password characters -- they just need to be escaped in the regex source).Test plan
[x] All 45 existing tests pass (
vitest run), including the"no tool inputSchema exposes patterns invalid under strict regex syntax"test that usesnew RegExp(value, "v")to verify every exposed pattern.[x] Verified the corrected pattern passes
new RegExp(pattern, "v")andnew RegExp(pattern, "u")in Node.js.[x] Verified the regex still correctly allows passwords with
[,],{,},|,(,)and rejects passwords with spaces.[x] No competing open PRs for this issue (checked before starting).
Fixes #70