Computer scienceBackendNode.jsSecurity

Path traversal

Security analyst

Report a typo

As a security analyst, you need to create a simple function that detects potential path traversal patterns in a given file path. The function should return true if the path contains any sequences like ../ indicating directory traversal.

Sample Input 1:

/uploads/../../../etc/passwd

Sample Output 1:

true

Sample Input 2:

/uploads/etc/passwd

Sample Output 2:

false
Write a program in JavaScript
// Function to detect path traversal
function detectPathTraversal(filePath) {

}

Create a free account to access the full topic