@Test public void checkValidRootPaths() { for(String rootPath : validPaths) { assertThatCode(() -> SafeFileChecker.checkSafeFilePath(rootPath, VALID_SUBPATH)) .doesNotThrowAnyException(); } }
public static void checkSafeFilePath(String path) throws IOException { checkNullParameter(path); try { File sanityCheckedFile = doSanityCheck(path); doCanonicalPathCheck(sanityCheckedFile.getPath()); doDirCheck(sanityCheckedFile.getParent()); doFilenameCheck(sanityCheckedFile.getName()); } catch (Exception ex) { throw new IOException(ex); } }
SafeFileChecker { public static void checkSafeFilePath(String path) throws IOException { checkNullParameter(path); try { File sanityCheckedFile = doSanityCheck(path); doCanonicalPathCheck(sanityCheckedFile.getPath()); doDirCheck(sanityCheckedFile.getParent()); doFilenameCheck(sanityCheckedFile.getName()); } catch (Exception ex) { throw new IOException(ex); } } }
SafeFileChecker { public static void checkSafeFilePath(String path) throws IOException { checkNullParameter(path); try { File sanityCheckedFile = doSanityCheck(path); doCanonicalPathCheck(sanityCheckedFile.getPath()); doDirCheck(sanityCheckedFile.getParent()); doFilenameCheck(sanityCheckedFile.getName()); } catch (Exception ex) { throw new IOException(ex); } } private  SafeFileChecker(); }
SafeFileChecker { public static void checkSafeFilePath(String path) throws IOException { checkNullParameter(path); try { File sanityCheckedFile = doSanityCheck(path); doCanonicalPathCheck(sanityCheckedFile.getPath()); doDirCheck(sanityCheckedFile.getParent()); doFilenameCheck(sanityCheckedFile.getName()); } catch (Exception ex) { throw new IOException(ex); } } private  SafeFileChecker(); static void checkSafeFilePath(String path); static void checkSafePluginsFilesPath(String path); static void checkSafeFilePath(String rootPath, String... subPaths); }
SafeFileChecker { public static void checkSafeFilePath(String path) throws IOException { checkNullParameter(path); try { File sanityCheckedFile = doSanityCheck(path); doCanonicalPathCheck(sanityCheckedFile.getPath()); doDirCheck(sanityCheckedFile.getParent()); doFilenameCheck(sanityCheckedFile.getName()); } catch (Exception ex) { throw new IOException(ex); } } private  SafeFileChecker(); static void checkSafeFilePath(String path); static void checkSafePluginsFilesPath(String path); static void checkSafeFilePath(String rootPath, String... subPaths);  }