Exemplo n.º 1
0
        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));
                }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public string UnpackTo([InjectSource] ZipArchiveEntry zipArchiveEntry, string destinationDirectory)
        {
            var fileInfo = SchemaZipHelper.UnpackZipEntry(zipArchiveEntry, zipArchiveEntry.FullName, destinationDirectory);

            return(fileInfo.FullName);
        }
Exemplo n.º 4
0
        public ExtendedFileInfo GetZipEntryFileInfo([InjectSource] ZipArchiveEntry zipArchiveEntry)
        {
            var fileInfo = SchemaZipHelper.UnpackZipEntry(zipArchiveEntry, zipArchiveEntry.FullName, Path.GetTempPath());

            return(new ExtendedFileInfo(fileInfo, fileInfo.DirectoryName));
        }
Exemplo n.º 5
0
 public FileInfo GetZipEntryFileInfo([InjectSource] ZipArchiveEntry zipArchiveEntry)
 {
     return(SchemaZipHelper.UnpackZipEntry(zipArchiveEntry, zipArchiveEntry.FullName, Path.GetTempPath()));
 }