mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +00:00
Reviewed verification allocations
- Dependency hashing reuses one read buffer per artifact - Hash tests cover mixed entry sizes
This commit is contained in:
commit
43cb336b85
2 files changed
+17
-1
No files matched your search
@@ -231,11 +231,11 @@ public final class GenerationBuildRevision {
|
|||||||
throw new IOException("Duplicate dependency artifact entry: " + name);
|
throw new IOException("Duplicate dependency artifact entry: " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
byte[] buffer = new byte[16 * 1024];
|
||||||
for (Map.Entry<String, ZipEntry> entry : entries.entrySet()) {
|
for (Map.Entry<String, ZipEntry> entry : entries.entrySet()) {
|
||||||
update(digest, entry.getKey());
|
update(digest, entry.getKey());
|
||||||
try (InputStream input = zip.getInputStream(entry.getValue())) {
|
try (InputStream input = zip.getInputStream(entry.getValue())) {
|
||||||
MessageDigest content = digest();
|
MessageDigest content = digest();
|
||||||
byte[] buffer = new byte[16 * 1024];
|
|
||||||
int read;
|
int read;
|
||||||
while ((read = input.read(buffer)) != -1) {
|
while ((read = input.read(buffer)) != -1) {
|
||||||
content.update(buffer, 0, read);
|
content.update(buffer, 0, read);
|
||||||
|
|||||||
@@ -58,6 +58,22 @@ public class GenerationBuildRevisionTest {
|
|||||||
GenerationBuildRevision.capture(fixture.options(), dependencies)));
|
GenerationBuildRevision.capture(fixture.options(), dependencies)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void hashesLargeShortAndEmptyEntriesIndependently() throws Exception {
|
||||||
|
Path dependency = temporary.newFile("multiple-entries.jar").toPath();
|
||||||
|
Map<String, String> contents = Map.of("example/Large.class", "abc".repeat(11_000),
|
||||||
|
"example/Short.class", "tail", "example/Zero.class", "");
|
||||||
|
try (ZipOutputStream output = new ZipOutputStream(Files.newOutputStream(dependency))) {
|
||||||
|
for (String name : List.of("example/Zero.class", "example/Short.class", "example/Large.class")) {
|
||||||
|
output.putNextEntry(new ZipEntry(name));
|
||||||
|
output.write(contents.get(name).getBytes(StandardCharsets.UTF_8));
|
||||||
|
output.closeEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertEquals("49217af891afa3111d1f70a390acacc8bad700528b61b1ecc5637c060aeb52cd",
|
||||||
|
GenerationBuildRevision.artifactHash(dependency));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rejectsChangedAddedAndDeletedGenerationSources() throws Exception {
|
public void rejectsChangedAddedAndDeletedGenerationSources() throws Exception {
|
||||||
Fixture fixture = fixture();
|
Fixture fixture = fixture();
|
||||||
|
|||||||
Reference in new issue
Block a user