Package fr.gouv.vitam.common.security
Class SafeFileChecker
java.lang.Object
fr.gouv.vitam.common.security.SafeFileChecker
Checker for Sanity of file manipulation to avoid Path Traversal vulnerability
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic FilecheckSafeDirPath(String safeRootPath, String... subPaths) Directory path sanity checker.static FilecheckSafeFilePath(String safeRootPath, String... subPaths) File path sanity checker.static voidcheckSafeRessourceFilePath(String resourceName) Path sanity for class-path resources Checks filename authorized patterns, path traversal attacks & ESAPI sanity checks
-
Field Details
-
FILENAME_PATTERN
-
LOCAL_ENVIRONMENT
- See Also:
-
-
Method Details
-
checkSafeFilePath
public static File checkSafeFilePath(String safeRootPath, String... subPaths) throws IllegalPathException File path sanity checker. Checks folder & filename authorized patterns, path traversal attacks & ESAPI sanity checks- Parameters:
safeRootPath- first or initial part(s) of a path representing a FileSystem resourcesubPaths- sub path parts. Every part should be a single folder level, except last part which is the actual filename.- Returns:
- the resolved
File - Throws:
IllegalPathException- thrown when any check fails with UnChecked or Runtime exception
-
checkSafeDirPath
public static File checkSafeDirPath(String safeRootPath, String... subPaths) throws IllegalPathException Directory path sanity checker. Checks folder authorized patterns, path traversal attacks & ESAPI sanity checks- Parameters:
safeRootPath- first or initial part(s) of a path representing a FileSystem resourcesubPaths- sub path parts. Every part should be a single folder level.- Returns:
- the resolved directory
File - Throws:
IllegalPathException- thrown when any check fails with UnChecked or Runtime exception
-
checkSafeRessourceFilePath
Path sanity for class-path resources Checks filename authorized patterns, path traversal attacks & ESAPI sanity checks- Parameters:
resourceName- the resource file name to check- Throws:
IllegalPathException- thrown when any check fails with UnChecked or Runtime exception
-