Skip to content

Commit 2413bd3

Browse files
committed
fix: reject consecutive dots in s3Path bucket name
1 parent b34e0e6 commit 2413bd3

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
44
const ISO_TIMESTAMP_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,6})?(Z|[+-]\d{2}:\d{2})$/;
55
const IDENTIFIER_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z_][a-zA-Z0-9_]*){0,2}$/;
66
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
7-
const S3_PATH_REGEX = /^s3:\/\/[a-z0-9][a-z0-9.-]{1,61}[a-z0-9](\/[a-zA-Z0-9._\-/=]*)?$/;
7+
const S3_PATH_REGEX = /^s3:\/\/(?![^/]*\.\.)[a-z0-9][a-z0-9.-]{1,61}[a-z0-9](\/[a-zA-Z0-9._\-/=]*)?$/;
88

99
export interface TypeDescriptor<T = unknown> {
1010
readonly __phantom?: T;

tests/schema.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,9 @@ describe('schema.s3Path', () => {
204204
expect(schema.s3Path.validate('')).toBe(false);
205205
expect(schema.s3Path.validate(123)).toBe(false);
206206
});
207+
208+
it('rejects bucket names with consecutive dots', () => {
209+
expect(schema.s3Path.validate('s3://my..bucket/path')).toBe(false);
210+
expect(schema.s3Path.validate('s3://my..bucket')).toBe(false);
211+
});
207212
});

0 commit comments

Comments
 (0)