Package com.atlassian.confluence.util
Class FilesystemUtils
- java.lang.Object
-
- com.atlassian.confluence.util.FilesystemUtils
-
public final class FilesystemUtils extends Object
- Since:
- 7.19.18
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>
FORBIDDEN_PATH_CONTAINS
static List<String>
FORBIDDEN_PATH_ENDINGS
static List<String>
FORBIDDEN_PATH_EQUALS
-
Constructor Summary
Constructors Constructor Description FilesystemUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
containsEncodedPathTraversal(String str)
Checks if the given string contains any of the forbidden path traversal patterns.static boolean
containsPathTraversal(String str)
Checks if the given string contains any of the forbidden path traversal patterns.static boolean
isSafePath(String path)
Ensures the path is safe and is not vulnerable to path traversal vulnerabilities.static boolean
isSafePath(Path path)
static boolean
isSafeTitleForFilesystem(String title)
Ensure the title is safe to be written to the file system.
-
-
-
Method Detail
-
isSafeTitleForFilesystem
public static boolean isSafeTitleForFilesystem(String title)
Ensure the title is safe to be written to the file system.- Parameters:
title
- The title to check- Returns:
- True if the title is safe for the filesystem, false otherwise
-
containsPathTraversal
public static boolean containsPathTraversal(String str)
Checks if the given string contains any of the forbidden path traversal patterns.- Parameters:
str
- The string to check- Returns:
- True if the string contains any of the forbidden path traversal patterns
-
containsEncodedPathTraversal
public static boolean containsEncodedPathTraversal(String str)
Checks if the given string contains any of the forbidden path traversal patterns. The string is first decoded usingHtmlUtil.loopedUrlDecode(String)
.- Parameters:
str
- The string to check- Returns:
- True if the string contains any of the forbidden path traversal patterns
-
isSafePath
public static boolean isSafePath(String path)
Ensures the path is safe and is not vulnerable to path traversal vulnerabilities. On top of filesystem specific checks it also rejects any paths containing risky path elements known to cause path traversal issues in different file systems (e.g. `..`, `/..`, `..\`).- Parameters:
path
- The path to check- Returns:
- True if the path is safe
-
isSafePath
public static boolean isSafePath(Path path)
- Parameters:
path
- The path to check- Returns:
- True if the path is safe
- See Also:
isSafePath(String)
-
-