public void DecompressZipSlipVulnerabilityTest() { var tempDir = "./Temp"; using (var file = File.OpenRead("./Files.zip")) { using (var zip = new ZipArchive(file)) { Assert.ThrowsException <InvalidOperationException>(() => SchemaZipHelper.UnpackZipEntry(zip.Entries[0], "../test.abc", tempDir)); } } }
public void DecompressZipWithHelperTest() { var tempDir = "./Temp"; using (var file = File.OpenRead("./Files.zip")) { using (var zip = new ZipArchive(file)) { var unpackedFile = SchemaZipHelper.UnpackZipEntry(zip.Entries[0], "test.abc", tempDir); unpackedFile.Delete(); } } Directory.Delete(tempDir); }
public string UnpackTo([InjectSource] ZipArchiveEntry zipArchiveEntry, string destinationDirectory) { var fileInfo = SchemaZipHelper.UnpackZipEntry(zipArchiveEntry, zipArchiveEntry.FullName, destinationDirectory); return(fileInfo.FullName); }
public ExtendedFileInfo GetZipEntryFileInfo([InjectSource] ZipArchiveEntry zipArchiveEntry) { var fileInfo = SchemaZipHelper.UnpackZipEntry(zipArchiveEntry, zipArchiveEntry.FullName, Path.GetTempPath()); return(new ExtendedFileInfo(fileInfo, fileInfo.DirectoryName)); }
public FileInfo GetZipEntryFileInfo([InjectSource] ZipArchiveEntry zipArchiveEntry) { return(SchemaZipHelper.UnpackZipEntry(zipArchiveEntry, zipArchiveEntry.FullName, Path.GetTempPath())); }