@Test public void testForbiddenPath() throws IllegalArgumentException, IOException, NoSuchAuthorityCodeException, CQLException { final File file = TestData.file(this, "sample"); final String absolutePath = FilenameUtils.separatorsToUnix(file.getAbsolutePath()); final String string = "PATH='" + absolutePath + "/folder1/../../forbiddenFolder/classifiedFile.tif'"; Filter filter = CQL.toFilter(string); final ImageCollectionReader reader = new ImageCollectionReader(file); final ParameterValue<Filter> ff = ImageCollectionFormat.FILTER.createValue(); ff.setValue(filter); GeneralParameterValue[] params = new GeneralParameterValue[] {ff}; if (reader != null) { GridCoverage2D coverage = null; boolean exception = true; try { coverage = (GridCoverage2D) reader.read(params); exception = false; } catch (DataSourceException exc){ assertTrue(exception); } } }
@Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); }
ImageCollectionReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); } }
ImageCollectionReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); } ImageCollectionReader(Object input);  ImageCollectionReader(Object input, Hints uHints); }
ImageCollectionReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); } ImageCollectionReader(Object input);  ImageCollectionReader(Object input, Hints uHints); @Override int getGridCoverageCount(); @Override void dispose(); Format getFormat(); @Override GridCoverage2D read(GeneralParameterValue[] params); }
ImageCollectionReader extends AbstractGridCoverage2DReader implements GridCoverageReader { @Override public GridCoverage2D read(GeneralParameterValue[] params) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Reading image from " + sourceURL.toString() + "\nHighest res " + highestRes[0] + " " + highestRes[1]); } final Collection<GridCoverage2D> response = rasterManager.read(params); if (response.isEmpty()){ if (LOGGER.isLoggable(Level.FINE)){ LOGGER.fine("The response is empty. ==> returning a null GridCoverage"); } return null; } else return response.iterator().next(); } ImageCollectionReader(Object input);  ImageCollectionReader(Object input, Hints uHints); @Override int getGridCoverageCount(); @Override void dispose(); Format getFormat(); @Override GridCoverage2D read(GeneralParameterValue[] params);  }