Skip to content

Commit 3c68524

Browse files
CopilotBioPhoton
andcommitted
fix(utils): improve validation error messages for clarity
Co-authored-by: BioPhoton <10064416+BioPhoton@users.noreply.github.com>
1 parent da64de1 commit 3c68524

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/utils/src/lib/wal-sharded.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ function validateGroupId(groupId: string): void {
4343

4444
// Reject path separators (both forward and backward slashes)
4545
if (groupId.includes('/') || groupId.includes('\\')) {
46-
throw new Error(
47-
'groupId cannot contain path separators (/ or \\): path traversal detected',
48-
);
46+
throw new Error('groupId cannot contain path separators (/ or \\)');
4947
}
5048

5149
// Reject relative path components
5250
if (groupId === '..' || groupId === '.') {
53-
throw new Error('groupId cannot be "." or "..": path traversal detected');
51+
throw new Error('groupId cannot be "." or ".."');
5452
}
5553

5654
// Reject null bytes which can be used to bypass validation

packages/utils/src/lib/wal-sharded.unit.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ describe('ShardedWal', () => {
7777
describe('path traversal validation', () => {
7878
it('should reject groupId with forward slashes', () => {
7979
expect(() => getShardedWal({ groupId: '../etc/passwd' })).toThrow(
80-
'groupId cannot contain path separators',
80+
'groupId cannot contain path separators (/ or \\)',
8181
);
8282
});
8383

8484
it('should reject groupId with backward slashes', () => {
8585
expect(() => getShardedWal({ groupId: '..\\windows\\system32' })).toThrow(
86-
'groupId cannot contain path separators',
86+
'groupId cannot contain path separators (/ or \\)',
8787
);
8888
});
8989

@@ -134,7 +134,7 @@ describe('ShardedWal', () => {
134134
getShardedWal({
135135
measureNameEnvVar: 'CP_PROFILER_MEASURE_NAME',
136136
}),
137-
).toThrow('groupId cannot contain path separators');
137+
).toThrow('groupId cannot contain path separators (/ or \\)');
138138
});
139139
});
140140

0 commit comments

Comments
 (0)