Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@

// Additional checks for suspicious patterns
const suspiciousPatterns = [
/\x00/, // Null bytes

Check failure on line 181 in server.js

View workflow job for this annotation

GitHub Actions / test (18.x)

Unexpected control character(s) in regular expression: \x00

Check failure on line 181 in server.js

View workflow job for this annotation

GitHub Actions / test (20.x)

Unexpected control character(s) in regular expression: \x00
/[<>"|*?]/, // Dangerous file characters
/^\//, // Absolute paths
/^[a-zA-Z]:\\/, // Windows absolute paths
Expand Down Expand Up @@ -220,6 +220,9 @@

// Validate individual comments
for (const [file, comment] of Object.entries(comments)) {
if (!DiffService.isValidFilePath(file)) {
return { valid: false, error: 'Invalid file path in comments' };
}
if (typeof comment !== 'string' || comment.length > 10000) {
return { valid: false, error: 'Comment too long (max 10,000 characters)' };
}
Expand Down Expand Up @@ -247,7 +250,7 @@
return { valid: false, error: 'Too many excluded files (max 1000)' };
}

if (!excludedFiles.every(f => typeof f === 'string' && f.length < 500)) {
if (!excludedFiles.every(f => typeof f === 'string' && f.length < 500 && DiffService.isValidFilePath(f))) {
return { valid: false, error: 'Invalid excluded file entries' };
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/diffService.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class DiffService {
}

// Prevent dangerous characters that could be used for command injection
const dangerousChars = /[;&|`$(){}[\]<>]/;
const dangerousChars = /[;&|`$(){}[\]<>'"]/;
if (dangerousChars.test(filePath)) {
return false;
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// Additional checks for suspicious patterns
const suspiciousPatterns = [
/\x00/, // Null bytes

Check failure on line 34 in src/utils/validation.js

View workflow job for this annotation

GitHub Actions / test (18.x)

Unexpected control character(s) in regular expression: \x00

Check failure on line 34 in src/utils/validation.js

View workflow job for this annotation

GitHub Actions / test (20.x)

Unexpected control character(s) in regular expression: \x00
/[<>"|*?]/, // Dangerous file characters
/^\//, // Absolute paths
/^[a-zA-Z]:\\/, // Windows absolute paths
Expand Down Expand Up @@ -75,6 +75,9 @@
}

for (const [file, comment] of Object.entries(comments)) {
if (file.includes('..') || file.startsWith('/') || file.includes('\\') || /[;&|`$(){}[\]<>'"]/.test(file)) {
return { valid: false, error: 'Invalid file path in comments' };
}
if (typeof comment !== 'string' || comment.length > 10000) {
return { valid: false, error: 'Comment too long (max 10,000 characters)' };
}
Expand Down Expand Up @@ -102,7 +105,7 @@
return { valid: false, error: 'Too many excluded files (max 1000)' };
}

if (!excludedFiles.every(f => typeof f === 'string' && f.length < 500)) {
if (!excludedFiles.every(f => typeof f === 'string' && f.length < 500 && !(f.includes('..') || f.startsWith('/') || f.includes('\\') || /[;&|`$(){}[\]<>'"]/.test(f)))) {
return { valid: false, error: 'Invalid excluded file entries' };
}
}
Expand Down
Loading