Disables jar signing for train docs

This commit is contained in:
Marcin Grzejszczak
2023-02-07 16:26:05 +01:00
parent acccdd1f0d
commit ecbeb68df6
3 changed files with 18 additions and 16 deletions

View File

@@ -20,6 +20,8 @@
<handlebars.version>4.3.0</handlebars.version> <handlebars.version>4.3.0</handlebars.version>
<asciidoctorj.version>2.5.3</asciidoctorj.version> <asciidoctorj.version>2.5.3</asciidoctorj.version>
<commons-io.version>2.11.0</commons-io.version> <commons-io.version>2.11.0</commons-io.version>
<maven-gpg-plugin.phase>none</maven-gpg-plugin.phase>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
@@ -115,10 +117,9 @@
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-deploy-plugin</artifactId> <artifactId>maven-deploy-plugin</artifactId>
</plugin> <goals>
<plugin> <goal>deploy-file</goal>
<groupId>org.apache.maven.plugins</groupId> </goals>
<artifactId>maven-gpg-plugin</artifactId>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@@ -68,13 +68,13 @@ final class ZipCategory {
if (!entry.isDirectory()) { if (!entry.isDirectory()) {
final File destinationFile = new File(destination, entry.getName()); final File destinationFile = new File(destination, entry.getName());
/* /*
* If we see the relative traversal string of ".." we need to make sure * If we see the relative traversal string of ".." we need to make
* that the outputdir + name doesn't leave the outputdir. * sure that the outputdir + name doesn't leave the outputdir.
*/ */
String zipEntryName = entry.getName(); String zipEntryName = entry.getName();
if (!destinationFile.toPath().normalize().startsWith(destination.toPath())) { if (!destinationFile.toPath().normalize().startsWith(destination.toPath())) {
throw new ZipException("The file " + zipEntryName + throw new ZipException("The file " + zipEntryName
" is trying to leave the target output directory of " + destination); + " is trying to leave the target output directory of " + destination);
} }
if (destinationFile.getParentFile() != null) { if (destinationFile.getParentFile() != null) {
destinationFile.getParentFile().mkdirs(); destinationFile.getParentFile().mkdirs();

View File

@@ -34,25 +34,26 @@ class ZipCategoryTests {
// when: // when:
ZipCategory.unzipTo(zipFile, tempDir); ZipCategory.unzipTo(zipFile, tempDir);
// then: // then:
BDDAssertions.then(tempDir.listFiles()) BDDAssertions.then(tempDir.listFiles()).hasOnlyOneElementSatisfying(file -> {
.hasOnlyOneElementSatisfying(file -> { BDDAssertions.then(file).hasName("file.txt").hasContent("test");
BDDAssertions.then(file).hasName("file.txt") });
.hasContent("test");
});
} }
@Test @Test
void should_not_allow_malicious_traversal() throws Exception { void should_not_allow_malicious_traversal() throws Exception {
// given: // given:
File zipFile = new File(ZipCategoryTests.class.getClassLoader().getResource("zip/zip-malicious-traversal.zip").toURI()); File zipFile = new File(
ZipCategoryTests.class.getClassLoader().getResource("zip/zip-malicious-traversal.zip").toURI());
File tempDir = Files.createTempDirectory("foo").toFile(); File tempDir = Files.createTempDirectory("foo").toFile();
tempDir.deleteOnExit(); tempDir.deleteOnExit();
// when: // when:
try { try {
ZipCategory.unzipTo(zipFile, tempDir); ZipCategory.unzipTo(zipFile, tempDir);
Assertions.fail("Should throw exception"); Assertions.fail("Should throw exception");
} catch (Exception e) { }
BDDAssertions.then(e.getCause()).hasMessageContaining("is trying to leave the target output directory"); catch (Exception e) {
BDDAssertions.then(e.getCause()).hasMessageContaining("is trying to leave the target output directory");
} }
} }
} }