"Applied fix from trunk for revision: 1864930"
------------------------------------------------------------------------ r1864930 | jleroux | 2019-08-11 15:23:19 +0200 (dim. 11 août 2019) | 4 lignes Fixed: [FB] Find Security Bugs (OFBIZ-9973) As suggested by Mathieu on dev ML factorises the use of Path::normalize ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release18.12@1864931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -39,12 +39,12 @@ import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.ofbiz.base.location.ComponentLocationResolver;
|
||||
|
||||
@@ -488,4 +488,17 @@ public final class FileUtil {
|
||||
zis.closeEntry();
|
||||
zis.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a File with a normalized file path
|
||||
* This useful to prevent path traversal security issues
|
||||
* cf. OFBIZ-9973 for more details
|
||||
*
|
||||
* @param filePath The file path to normalize
|
||||
* @return A File with a normalized file path
|
||||
*/
|
||||
public static File normalizeFilePath(String filePath) {
|
||||
return new File(filePath).toPath().normalize().toFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user