Compare commits

..

4 Commits

Author SHA1 Message Date
mpeltriaux 8de467ec24 Merge pull request '# OGR failure' (#590) from bugfix_malicious_geometry into master
Reviewed-on: #590
2026-09-17 16:29:20 +02:00
mpeltriaux 238a9c4db8 # OGR failure
* catches error in case of malicious input geometry
* updates translations
2026-09-17 16:28:39 +02:00
mpeltriaux 7fe5340995 Merge pull request '# Bugfix' (#588) from bugfix_empty_geometry_error into master
Reviewed-on: #588
2026-09-15 18:02:35 +02:00
mpeltriaux 606f1ed311 # Bugfix
* fixes bug where empty geometry on SimpleGeomForm could lead to error
2026-09-15 18:01:35 +02:00
3 changed files with 31 additions and 6 deletions
+24 -3
View File
@@ -180,6 +180,24 @@ class GeometryProcessor:
is_area_valid = geom.area > 1 # > 1m² (SRID:25832)
return is_area_valid
@staticmethod
def is_valid_geometry(geom: gdal.OGRGeometry) -> bool:
""" Checks whether the geometry is technically valid
Args:
geom (OGRGeometry): The geom
Returns:
"""
try:
# Check geometry validity by triggering some low cost processing like centroid calculation
geom.centroid
geom.boundary
return True
except gdal.GDALException as e:
return False
class GeoJsonValidator:
""" GeoJson Validator validates geojson (e.g. from API or form input)
@@ -257,10 +275,10 @@ class GeoJsonValidator:
Returns:
"""
features = self._input_geojson.get("features", None)
features = self._input_geojson.get("features", [])
is_input_geojson_empty = len(self._input_geojson) == 0
no_features_in_input_found = features is None
no_features_in_input_found = len(features) == 0
if not is_input_geojson_empty and no_features_in_input_found:
# check if _input_geojson is a feature itself
@@ -273,7 +291,6 @@ class GeoJsonValidator:
else:
self.__add_error("Input does not seem to be geojson")
return
try:
validated_features = self.__validate_single_features(features)
except AssertionError as e:
@@ -306,6 +323,10 @@ class GeoJsonValidator:
g = gdal.OGRGeometry(feature_geom, srs=self._srs)
if g.empty:
continue
if not GeometryProcessor.is_valid_geometry(g):
raise AssertionError(_("This feature holds malicious parts and can not be processed!"))
g = GeometryProcessor.cast_to_rlp_srid(g)
if not GeometryProcessor.is_valid_25832(g):
raise AssertionError(_("This feature does not hold valid EPSG:25832 coordinates:\n {}".format(g.geojson)))
Binary file not shown.
+7 -3
View File
@@ -45,7 +45,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-09-13 12:06+0200\n"
"POT-Creation-Date: 2026-09-17 16:25+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -2012,7 +2012,11 @@ msgstr "In Zwischenablage kopiert"
msgid "Search"
msgstr "Suchen"
#: konova/utils/geometry/geometry_validator.py:311
#: konova/utils/geometry/geometry_validator.py:328
msgid "This feature holds malicious parts and can not be processed!"
msgstr "Teile der Geometrie sind ungültig und können nicht verarbeitet werden!"
#: konova/utils/geometry/geometry_validator.py:332
msgid ""
"This feature does not hold valid EPSG:25832 coordinates:\n"
" {}"
@@ -2020,7 +2024,7 @@ msgstr ""
"Dieses Feature enthält keine validen EPSG:25832 Koordinaten:\n"
" {}"
#: konova/utils/geometry/geometry_validator.py:319
#: konova/utils/geometry/geometry_validator.py:340
msgid "Only surfaces allowed. Points or lines must be buffered."
msgstr ""
"Nur Flächen erlaubt. Punkte oder Linien müssen zu Flächen gepuffert werden."