mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-23 07:00:24 +03:00
c2b830f279
fix arbitrary create attachemnt file upload
30 lines
1001 B
TypeScript
30 lines
1001 B
TypeScript
/**
|
|
* Validates if a string is a valid UUID v4
|
|
* @param {string} uuid The string to validate
|
|
* @returns {boolean} True if valid UUID, false otherwise
|
|
*/
|
|
export const isValidUUID = (uuid: string): boolean => {
|
|
// UUID v4 regex pattern
|
|
const uuidV4Pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
|
return uuidV4Pattern.test(uuid)
|
|
}
|
|
|
|
/**
|
|
* Validates if a string contains path traversal attempts
|
|
* @param {string} path The string to validate
|
|
* @returns {boolean} True if path traversal detected, false otherwise
|
|
*/
|
|
export const isPathTraversal = (path: string): boolean => {
|
|
// Check for common path traversal patterns
|
|
const dangerousPatterns = [
|
|
'..', // Directory traversal
|
|
'/', // Root directory
|
|
'\\', // Windows root directory
|
|
'%2e', // URL encoded .
|
|
'%2f', // URL encoded /
|
|
'%5c' // URL encoded \
|
|
]
|
|
|
|
return dangerousPatterns.some((pattern) => path.toLowerCase().includes(pattern))
|
|
}
|