use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.
the class FileUtilsTestCase method doesNotUnzipExternalPaths.
@Test
public void doesNotUnzipExternalPaths() throws Exception {
final String resourceName = "dummy.xml";
final String resourceAlias = Paths.get("folder", "..", "..", resourceName).toString();
final File compressedFile = new File(toDir, "test.zip");
compress(compressedFile, new ZipResource[] { new ZipResource(resourceName, resourceName), new ZipResource(resourceName, resourceAlias) });
thrownException.expect(InvalidZipFileException.class);
thrownException.expectMessage("External paths are not allowed: " + resourceAlias);
unzip(compressedFile, toDir);
// make sure it did not extract other archive files
assertThat(new File(toDir, resourceName).exists(), is(false));
}
use of org.mule.tck.ZipUtils.ZipResource in project mule by mulesoft.
the class FileUtilsTestCase method doesNotUnzipAbsolutePaths.
@Test
public void doesNotUnzipAbsolutePaths() throws Exception {
final String resourceName = "dummy.xml";
final String resourceAlias = new File(resourceName).getAbsolutePath();
final File compressedFile = new File(toDir, "test.zip");
compress(compressedFile, new ZipResource[] { new ZipResource(resourceName, resourceName), new ZipResource(resourceName, resourceAlias) });
thrownException.expect(InvalidZipFileException.class);
thrownException.expectMessage("Absolute paths are not allowed: " + resourceAlias);
unzip(compressedFile, toDir);
// make sure it did not extract other archive files
assertThat(new File(toDir, resourceName).exists(), is(false));
}
Aggregations