Commit a1b6aaa
committed
Address review of #1668: redirect re-validation + drop scheme widening
Merge origin/main into the SSRF-hardening branch and address the
Copilot review comments.
Redirect handling (review #1, #2):
- urllib3 path: stop delegating redirect-follow to urllib3.
_HTTPSource now GETs with redirect=False and walks the 3xx chain
in Python, re-validating each Location against _validate_http_url.
Caps the chain at _HTTP_MAX_REDIRECTS (5). A public URL can no
longer 3xx into a loopback or private IP.
- stdlib path: install _ValidatingRedirectHandler on a module-level
opener so the stdlib fallback gets the same per-hop re-validation
and redirect cap. read_range / read_all both go through it now.
Scheme allow-list (review #3):
- Drop XRSPATIAL_GEOTIFF_ALLOWED_SCHEMES. _HTTPSource is a urllib3 /
urllib Range-GET implementation; widening the validator without
widening the source just moved the failure to connect time. fsspec
handles every other scheme:// via _open_source's _CloudSource branch.
Env-var clamp (review #4):
- _max_tile_bytes_from_env now falls back to the default for zero or
negative values, matching the timeout helpers. The previous
max(1, val) clamp silently rejected every tile on a typoed
XRSPATIAL_COG_MAX_TILE_BYTES=-1.
Docs and comments (review #5, #6):
- "Security and I/O limits" docs: explain that non-http(s) schemes
dispatch via fsspec and that the redirect cap re-validates each
hop. Drop the misleading XRSPATIAL_GEOTIFF_ALLOWED_SCHEMES example.
- test_read_to_array_rejects_file_url: comment corrected to match
_open_source routing file:// through fsspec, and the expected-
exception list now includes ImportError.
Merge conflict resolution against origin/main:
- __init__.py and test_features.py: keep both GeoTIFFFallbackWarning
(#1662) and UnsafeURLError in __all__ / TestPublicAPI.expected.
- _reader.py _read_strips: byte-cap (this PR) and RowsPerStrip<=0
guard (#1666) both kept; cap runs first.
- docs/geotiff.rst: "Security and I/O limits" and "Strict mode" live
as sibling sections.
xrspatial/geotiff/tests/: 1611 passed (3 pre-existing matplotlib
palette failures unchanged).23 files changed
Lines changed: 2592 additions & 131 deletions
File tree
- .claude
- docs/source/reference
- xrspatial/geotiff
- tests
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
4 | 3 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
0 commit comments