T-28: Dev QA-Mongo guard bypass: raw '#' or a second '@' in the host list (guard and driver split the URI authority differently)
This commit is contained in:
parent
34023ee88a
commit
2206515681
4 changed files with 300 additions and 24 deletions
|
|
@ -615,12 +615,31 @@ describe('Config Schemas', () => {
|
|||
expect(seedListEmptyPort.uri).toBe('mongodb://u:p@mongo1.prod.internal:,[::1]:/stock');
|
||||
});
|
||||
|
||||
it('should accept percent-encoded @ in credentials, passwordless user, and @/# after / or ?', () => {
|
||||
const validUris = [
|
||||
'mongodb://dev_admin:p%40ss@localhost:27018/stock_dev',
|
||||
'mongodb://dev_admin:p%40ss@localhost:27018/stock_dev?appName=a@b#note',
|
||||
'mongodb://localhost:27018?authSource=admin#frag',
|
||||
'mongodb://dev_user@localhost:27018/stock_dev',
|
||||
];
|
||||
for (const uri of validUris) {
|
||||
const config = mongodbConfigSchema.parse({
|
||||
uri,
|
||||
readUri: uri,
|
||||
database: 'stock_dev',
|
||||
});
|
||||
expect(config.uri).toBe(uri);
|
||||
expect(config.readUri).toBe(uri);
|
||||
}
|
||||
});
|
||||
|
||||
it('should validate URI format', () => {
|
||||
const invalidUris = [
|
||||
'invalid-uri',
|
||||
'http://localhost:27017/stock',
|
||||
'mongodb://',
|
||||
'mongodb://u:p@',
|
||||
'mongodb://@localhost:27018/stock',
|
||||
'mongodb://u:p@localhost:27017,',
|
||||
'mongodb://u:p@:27017/stock',
|
||||
'mongodb://u:p@localhost:0/stock',
|
||||
|
|
@ -628,9 +647,20 @@ describe('Config Schemas', () => {
|
|||
'mongodb://u:p@[::1]:0/stock',
|
||||
'mongodb://u:p@[::1]:99999/stock',
|
||||
'mongodb://u:p@localhost:abc/stock',
|
||||
'mongodb://localhost:27018#,localhost/stock',
|
||||
'mongodb://localhost:27018#frag',
|
||||
'mongodb://u:p@localhost:27018#x,127.0.0.1/stock',
|
||||
'mongodb://u:p@localhost:27017@x:27018/stock',
|
||||
'mongodb://trading_admin:p@ss@localhost:27018/stock_dev',
|
||||
'mongodb://u:p@local\nhost:27017/stock',
|
||||
'mongodb://u:p@local\thost:27017/stock',
|
||||
'mongodb://u:p@localhost:27018/stock\x00',
|
||||
'mongodb://u:p@localhost:27018/stock?a=1\rb=2',
|
||||
'mongodb+srv://u:p@localhost:/stock',
|
||||
'mongodb+srv://u:p@localhost:27017/stock',
|
||||
'mongodb+srv://u:p@host1.example.com,host2.example.com/stock',
|
||||
'mongodb+srv://u:p@cluster.example.com#x/stock',
|
||||
'mongodb+srv://u:p@cluster.example.com@other.example.com/stock',
|
||||
];
|
||||
for (const uri of invalidUris) {
|
||||
expect(() =>
|
||||
|
|
@ -639,6 +669,13 @@ describe('Config Schemas', () => {
|
|||
database: 'testdb',
|
||||
})
|
||||
).toThrow();
|
||||
expect(() =>
|
||||
mongodbConfigSchema.parse({
|
||||
uri: 'mongodb://localhost:27018/stock_dev',
|
||||
readUri: uri,
|
||||
database: 'testdb',
|
||||
})
|
||||
).toThrow();
|
||||
}
|
||||
expect(() =>
|
||||
mongodbConfigSchema.parse({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue