T-9: Multi-host MongoDB URI bypasses the dev QA-Mongo guard

This commit is contained in:
Studio 2026-11-27 11:17:59 -05:00
parent 677658a32f
commit 4b46e809be
5 changed files with 134 additions and 7 deletions

View file

@ -55,6 +55,9 @@ function isValidMongoHostSegment(segment: string, allowPort: boolean): boolean {
return false;
}
const portStr = after.slice(1);
if (portStr === '') {
return true;
}
if (!/^\d+$/.test(portStr)) {
return false;
}
@ -72,7 +75,13 @@ function isValidMongoHostSegment(segment: string, allowPort: boolean): boolean {
const host = segment.slice(0, colonIdx);
const portStr = segment.slice(colonIdx + 1);
if (!host || !/^\d+$/.test(portStr)) {
if (!host) {
return false;
}
if (portStr === '') {
return true;
}
if (!/^\d+$/.test(portStr)) {
return false;
}
const port = Number(portStr);