azkaban.utils.Utils.unzip()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中azkaban.utils.Utils.unzip()方法的一些代码示例,展示了Utils.unzip()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.unzip()方法的具体详情如下:
包路径:azkaban.utils.Utils
类名称:Utils
方法名:unzip

Utils.unzip介绍

暂无

代码示例

代码示例来源:origin: azkaban/azkaban

private File unzipFile(final File archiveFile) throws IOException {
 final ZipFile zipfile = new ZipFile(archiveFile);
 final File unzipped = Utils.createTempDir(this.tempDir);
 Utils.unzip(zipfile, unzipped);
 zipfile.close();
 return unzipped;
}

代码示例来源:origin: azkaban/azkaban

/**
  * An insecure zip file may hold path traversal filenames. During unzipping, the filename gets
  * concatenated to the target directory. The final path may end up outside the target directory,
  * causing security issues.
  *
  * @throws IOException the io exception
  */
 @Test
 public void testUnzipInsecureFile() throws IOException {
  final File zipFile = new File("myTest.zip");
  try {
   try (final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile))) {
    final ZipEntry entry = new ZipEntry("../../../../../evil.txt");
    out.putNextEntry(entry);
   }

   final ZipFile source = new ZipFile(zipFile);
   final File dest = Utils.createTempDir();
   assertThatThrownBy(() -> Utils.unzip(source, dest)).isInstanceOf(IOException.class)
     .hasMessageContaining("Extracting zip entry would have resulted in a file outside the "
       + "specified destination directory.");
  } finally {
   if (zipFile.exists()) {
    zipFile.delete();
   }
  }
 }
}

代码示例来源:origin: com.linkedin.azkaban/azkaban

private File unzipFile(File archiveFile) throws IOException {
  ZipFile zipfile = new ZipFile(archiveFile);
  File unzipped = Utils.createTempDir(tempDir);
  Utils.unzip(zipfile, unzipped);
  return unzipped;
}

代码示例来源:origin: com.linkedin.azkaban/azkaban-common

private File unzipFile(final File archiveFile) throws IOException {
 final ZipFile zipfile = new ZipFile(archiveFile);
 final File unzipped = Utils.createTempDir(this.tempDir);
 Utils.unzip(zipfile, unzipped);
 zipfile.close();
 return unzipped;
}

代码示例来源:origin: com.linkedin.azkaban/azkaban

logger.info("Downloading zip file.");
ZipFile zip = new ZipFile(projectFileHandler.getLocalFile());
Utils.unzip(zip, tempDir);

相关文章