T-9: Multi-host MongoDB URI bypasses the dev QA-Mongo guard
This commit is contained in:
parent
677658a32f
commit
4b46e809be
5 changed files with 134 additions and 7 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue