dwsmith1983 opened a new pull request, #3748:
URL: https://github.com/apache/iceberg-rust/pull/3748

   ## Which issue does this PR close?
   
   - Closes #3746.
   
   ## What changes are included in this PR?
   
   Errors in `crates/storage/opendal` printed the location they were given. A 
location with userinfo, like `s3://alice:SECRET@bucket/t/f.parquet`, always 
fails the bucket prefix check, so the password ended up in the error every time 
it was used. Query strings (presigned signatures, SAS tokens) were echoed the 
same way.
   
   This moves the HDFS masking helper from #3111 to `utils::redact_path`, has 
it drop the query and fragment as well, and sends every error that prints a 
location through it. Besides the sites listed in the issue, that picks up a few 
more in `hf.rs`, `gcs.rs`, `oss.rs`, `resolving.rs` and `azdls.rs`.
   
   I didn't use `Url::set_password(None)` and `set_query(None)`. Two of these 
errors fire because the path failed to parse, and the HDFS helper already 
handles passwords containing a raw `/` or `://`, which a URL parser splits in 
the wrong place.
   
   The trade-off is that some messages lose context, though none of them leak:
   
   - Everything up to the last `@` is treated as userinfo, so an `@` in a key 
masks what comes before it. Hugging Face paths with a revision are the common 
case: `hf://datasets/u/r@main/f` shows up as `hf://***@main/f`.
   - When an `@` comes after the first `?` or `#`, there's no safe way to tell 
a password from a query. GCS V2 signed URLs do this 
(`?GoogleAccessId=sa@...&Signature=...`), so in that case only the scheme is 
kept: `gs://***`.
   - A `?` or `#` that really is part of an object key cuts the rest of the key 
from the message.
   
   Masking only up to the first `/` would keep more of the path, but it would 
leak a password containing a `/`, which the HDFS tests from #3111 check for.
   
   Not covered here: errors that opendal builds itself still show the relative 
path it was given, and that path keeps any `?...` because S3 treats it as part 
of the key. That one needs its own discussion.
   
   ## Are these changes tested?
   
   Yes. Unit tests for `redact_path` cover userinfo, queries and fragments, 
passwords with `?`, `#`, `/` or `@` in them, signed URLs with an `@` in the 
query, and the hf revision case. Tests on `create_operator`, `relativize_path`, 
`extract_scheme` and `AzureStoragePath` check the full error message for S3, 
GCS, OSS and HF paths carrying a password and a query, and they fail without 
the fix. The existing HDFS masking tests still pass, with one expected value 
updated for the `#` case.
   
   ## AI Disclosure
   
   <!--
   
https://iceberg.apache.org/contribute/#guidelines-for-ai-assisted-contributions
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to