|
4 | 4 | import java.io.BufferedOutputStream; |
5 | 5 | import java.io.File; |
6 | 6 | import java.io.FileOutputStream; |
| 7 | +import java.io.IOException; |
7 | 8 | import java.io.InputStream; |
8 | 9 | import java.io.OutputStream; |
9 | 10 | import java.util.Enumeration; |
| 11 | +import java.util.List; |
| 12 | +import java.util.Optional; |
10 | 13 | import java.util.jar.JarEntry; |
11 | 14 | import java.util.jar.JarFile; |
12 | 15 | import java.util.zip.ZipEntry; |
13 | 16 | import java.util.zip.ZipFile; |
14 | 17 | import java.util.zip.ZipInputStream; |
| 18 | +import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry; |
| 19 | +import org.apache.commons.compress.archivers.sevenz.SevenZFile; |
| 20 | +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; |
| 21 | +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; |
| 22 | +import org.apache.commons.compress.archivers.tar.TarFile; |
15 | 23 |
|
16 | 24 | public class ZipEntryCheck { |
17 | 25 |
|
@@ -93,3 +101,61 @@ public String compliant() throws java.lang.Exception { |
93 | 101 | } |
94 | 102 |
|
95 | 103 | } |
| 104 | + |
| 105 | +class TarUtilities { |
| 106 | + private TarUtilities() { |
| 107 | + /* This utility class should not be instantiated */ |
| 108 | + } |
| 109 | + |
| 110 | + public static List<TarArchiveEntry> getAllEntries(TarFile file) { |
| 111 | + return file.getEntries(); // Noncompliant {{Make sure that expanding this archive file is safe here.}} |
| 112 | + // ^^^^^^^^^^ |
| 113 | + } |
| 114 | + |
| 115 | + public static Optional<TarArchiveEntry> getNext(TarArchiveInputStream stream) throws IOException { |
| 116 | + return Optional.of(stream.getNextEntry()); // Noncompliant {{Make sure that expanding this archive file is safe here.}} |
| 117 | + // ^^^^^^^^^^^^ |
| 118 | + } |
| 119 | + |
| 120 | + public static long getEntrySize(TarArchiveEntry entry) { |
| 121 | + return entry.getSize(); // Noncompliant {{Make sure that expanding this archive file is safe here.}} |
| 122 | + // ^^^^^^^ |
| 123 | + } |
| 124 | +} |
| 125 | + |
| 126 | +class SevenZUtilities { |
| 127 | + private SevenZUtilities() { |
| 128 | + /* This utility class should not be instantiated */ |
| 129 | + } |
| 130 | + |
| 131 | + public static Iterable<SevenZArchiveEntry> getAllEntries(SevenZFile file) { |
| 132 | + return file.getEntries(); // Noncompliant {{Make sure that expanding this archive file is safe here.}} |
| 133 | + // ^^^^^^^^^^ |
| 134 | + } |
| 135 | + |
| 136 | + public static long getEntrySize(SevenZArchiveEntry entry) { |
| 137 | + return entry.getSize(); // Noncompliant {{Make sure that expanding this archive file is safe here.}} |
| 138 | + // ^^^^^^^ |
| 139 | + } |
| 140 | +} |
| 141 | + |
| 142 | +class ApacheCommonsZipUtilities { |
| 143 | + private ApacheCommonsZipUtilities() { |
| 144 | + /* This utility class should not be instantiated */ |
| 145 | + } |
| 146 | + |
| 147 | + public static Enumeration<org.apache.commons.compress.archivers.zip.ZipArchiveEntry> getAllEntries(org.apache.commons.compress.archivers.zip.ZipFile file) { |
| 148 | + return file.getEntries(); // Noncompliant {{Make sure that expanding this archive file is safe here.}} |
| 149 | + // ^^^^^^^^^^ |
| 150 | + } |
| 151 | + |
| 152 | + public static Optional<org.apache.commons.compress.archivers.zip.ZipArchiveEntry> getNext(org.apache.commons.compress.archivers.zip.ZipArchiveInputStream stream) throws IOException { |
| 153 | + return Optional.of(stream.getNextEntry()); // Noncompliant {{Make sure that expanding this archive file is safe here.}} |
| 154 | + // ^^^^^^^^^^^^ |
| 155 | + } |
| 156 | + |
| 157 | + public static long getEntrySize(org.apache.commons.compress.archivers.zip.ZipArchiveEntry entry) { |
| 158 | + return entry.getSize(); // Noncompliant {{Make sure that expanding this archive file is safe here.}} |
| 159 | + // ^^^^^^^ |
| 160 | + } |
| 161 | +} |
0 commit comments