Reject manifest metadata as storage paths
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-18 07:28:50 +02:00
parent 556eeb21af
commit dbdc594f94
2 changed files with 24 additions and 3 deletions
@@ -187,6 +187,8 @@ def test_manifest_ids_dates_and_labels_are_not_treated_as_paths(tmp_path: Path)
"generated_at": "2026-07-18T00:00:00Z", "generated_at": "2026-07-18T00:00:00Z",
"label": "Belgium", "label": "Belgium",
"output_path": "scope.geojson", "output_path": "scope.geojson",
"output_checksum_sha256": "a" * 64,
"output_crs": "EPSG:4326",
} }
), ),
encoding="utf-8", encoding="utf-8",
+22 -3
View File
@@ -143,18 +143,37 @@ def _iter_strings(value: Any) -> Iterable[str]:
yield from _iter_strings(nested) yield from _iter_strings(nested)
def _manifest_key_is_path(key: str) -> bool:
exact = {
"path",
"paths",
"file",
"files",
"filename",
"filenames",
"artifact",
"artifacts",
"manifest",
"manifests",
"storage_path",
"source_tile_path",
"mask_path",
"output_path",
}
return key in exact or key.endswith(("_path", "_paths", "_file", "_files", "_filename", "_filenames"))
def _iter_manifest_path_values(value: Any, parent_key: str = "") -> Iterable[str]: def _iter_manifest_path_values(value: Any, parent_key: str = "") -> Iterable[str]:
path_tokens = ("path", "file", "artifact", "manifest", "output")
if isinstance(value, dict): if isinstance(value, dict):
for key, nested in value.items(): for key, nested in value.items():
normalized_key = str(key).strip().lower() normalized_key = str(key).strip().lower()
if isinstance(nested, str) and any(token in normalized_key for token in path_tokens): if isinstance(nested, str) and _manifest_key_is_path(normalized_key):
yield nested yield nested
else: else:
yield from _iter_manifest_path_values(nested, normalized_key) yield from _iter_manifest_path_values(nested, normalized_key)
elif isinstance(value, (list, tuple)): elif isinstance(value, (list, tuple)):
for nested in value: for nested in value:
if isinstance(nested, str) and any(token in parent_key for token in path_tokens): if isinstance(nested, str) and _manifest_key_is_path(parent_key):
yield nested yield nested
else: else:
yield from _iter_manifest_path_values(nested, parent_key) yield from _iter_manifest_path_values(nested, parent_key)