-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
155 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/extension/wps/wps-core/src/test/java/org/geoserver/wps/ppio/ShapeZipPPIOTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* (c) 2018 Open Source Geospatial Foundation - all rights reserved | ||
* This code is licensed under the GPL 2.0 license, available at the root | ||
* application directory. | ||
*/ | ||
package org.geoserver.wps.ppio; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import org.junit.Test; | ||
|
||
public class ShapeZipPPIOTest { | ||
|
||
@Test | ||
public void testDecodeBadEntryName() throws Exception { | ||
try (InputStream input = getClass().getResourceAsStream("/bad-zip-file.zip")) { | ||
new ShapeZipPPIO(null).decode(input); | ||
fail("Expected decompression to fail"); | ||
} catch (IOException e) { | ||
assertTrue(e.getMessage().startsWith("Entry is outside of the target directory")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/rest/src/test/java/org/geoserver/rest/util/IOUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* (c) 2018 Open Source Geospatial Foundation - all rights reserved | ||
* This code is licensed under the GPL 2.0 license, available at the root | ||
* application directory. | ||
*/ | ||
package org.geoserver.rest.util; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.zip.ZipFile; | ||
import org.geoserver.platform.GeoServerResourceLoader; | ||
import org.geoserver.platform.resource.Resource; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class IOUtilsTest { | ||
|
||
@Rule public TemporaryFolder temp = new TemporaryFolder(new File("target")); | ||
|
||
@Test | ||
public void testInflateBadEntryName() throws IOException { | ||
File destDir = temp.newFolder("d1").toPath().toFile(); | ||
destDir.mkdirs(); | ||
Resource directory = new GeoServerResourceLoader(destDir).get(""); | ||
try (InputStream input = getClass().getResourceAsStream("/bad-zip-file.zip")) { | ||
File file = new File(destDir, "bad-zip-file.zip"); | ||
IOUtils.copyStream(input, new FileOutputStream(file), false, true); | ||
IOUtils.inflate(new ZipFile(file), directory, null, null, null, null, false, false); | ||
fail("Expected decompression to fail"); | ||
} catch (IOException e) { | ||
assertTrue(e.getMessage().startsWith("Entry is outside of the target directory")); | ||
} | ||
} | ||
} |