HyukjinKwon opened a new pull request, #930:
URL: https://github.com/apache/spark-connect-rust/pull/930

   ### What changes were proposed in this pull request?
   
   A follow-up of SPARK-62220 (#925). It fixes the findings 4 to 7 and 10 of 
the independent review of SPARK-62220's first commit, which #925's KD row 
"Custom gRPC channels" listed "until SPARK-62252", and the three LOWs of the 
review's security re-check of its second commit.
   
   | finding | before | now | tests |
   |---|---|---|---|
   | 4: a Unix path of bytes that are not UTF-8 | read as U+FFFD, so 
`unix:/tmp/%FF.sock` and `b"unix:/tmp/\xff.sock"` connected to another socket | 
the target is of bytes: its authority and its path percent-decode to bytes; the 
URI of a Unix socket in gRPC's texts is percent-encoded as gRPC's 
`URI::ToString` encodes a path (`unix:/tmp/%EF%BF%BD.sock`) | 
`grpc_target::a_target_is_of_bytes_up_to_its_first_nul`, 
`connector::a_connect_that_fails_as_it_starts_has_grpc_core_s_text` |
   | 5: a NUL in the endpoint | read past it | the target ends at its first 
NUL, as gRPC's core reads a C string (`localhost\0garbage:17843` is 
`localhost`, of the port 443) | 
`grpc_target::a_target_is_of_bytes_up_to_its_first_nul` |
   | 6: the metadata of the requests in the background | the `ExecutePlan` of a 
finalizer carried the builder's parameters and the token, none of a 
`metadata()` of its own; the deletion of a native ML object read `metadata()` 
on a thread of the transport (`Dummy-1`) | the first attempt of the 
`ExecutePlan` of a finalizer reads `metadata()` on the thread of the finalizer, 
with the GIL and of a pending exception kept (`MetadataSource::metadata_now`, 
`deliver::preserving_pending_exception`), and its retries as they are sent; a 
request that is sent as the interpreter exits, whose `metadata()` cannot be 
read then, is not sent | the review's `p_headers.py` and `p_mlnative.py` 
(below) |
   | 7: the keys of `metadata()` that gRPC's core sets itself | sent (`te`, 
`grpc-timeout`, `content-length`, ...), of which the server failed some calls, 
and the fields of a connection that HTTP/2 forbids were dropped | neither those 
keys nor those of the parameters are sent, as gRPC sends its own; a field of a 
connection (`connection`, `keep-alive`, `proxy-connection`, 
`transfer-encoding`, `upgrade`) fails the call of `INTERNAL`, as gRPC's server 
resets the stream that grpcio sends it on | 
`metadata::the_keys_that_grpc_sets_itself_are_not_sent_of_a_source`, 
`metadata::a_field_of_a_connection_fails_its_call_as_grpcs_server_resets_it` |
   | 10: the LOWs | a refused target past about 8 KB failed of 
`RESOURCE_EXHAUSTED`; a key or a value of None of `metadata()` raised 
`TypeError`; a builder that the program gave, of `ChannelBuilder`'s 
`metadata()`, was read once; `xds:` failed of `Misformatted domain name`; a 
full Unix backlog failed of `EINVAL`; a request at exit carried none of a 
`metadata()` of its own | `UNKNOWN` of any length, as gRPC's channel; None is 
empty, as grpcio's `_encode`; read for each call too, as PySpark's client reads 
it, of a parameter set since (so a key that gRPC does not take fails each call 
of `INTERNAL`, `Invalid metadata`, as grpcio's, where it failed the creation of 
the session); `xds:` fails each call of `UNAVAILABLE` of grpcio's text of no 
bootstrap of xDS (`Failed to create XdsClient: Environment variables 
GRPC_XDS_BOOTSTRAP or GRPC_XDS_BOOTSTRAP_CONFIG not defined`), and 
`google-c2p:` is its name of DNS, as off Google's cloud; `ENOTCONN`, of the 
write of the preface; not sent | `grpc_ta
 rget::the_targets_of_xds_and_google_c2p_are_read_as_grpcio_reads_them`, 
`test_a_channel_builder_is_read_as_pysparks_client_reads_it`, 
`test_no_connection_string_nor_endpoint_sets_the_channel_of_a_builder` |
   | re-check 1: the proxy of a loopback host | never proxied (`127.0.0.1`, 
`localhost`, `x*y.localhost`, a `no_proxy` entry of a port), and `[::1%25lo]` 
was not in `no_proxy=::1/128` | proxied as gRPC's proxy mapper proxies it, of 
the local credentials of the connection to the proxy; a host of a CIDR range is 
read as gRPC's `StringToSockaddr` reads it, of a zone; the `CONNECT` names its 
server up to a NUL (`localhost` of `localhost%00:17843`). The Rust API keeps 
one exception: a channel of no credentials of the binding that sends its token 
in plaintext (its rule of a token to `localhost`, of no local credentials) 
connects to a loopback host directly, as a proxy would get the token in the 
clear (documented in `ChannelBuilder::secure` and `docs/configuration.md`) | 
`proxy::loopback_hosts_are_proxied_but_of_a_token_in_plaintext`, 
`proxy::no_proxy_lists`, `grpc_target::the_names_of_a_target_are_grpcs` |
   | re-check 2: a wildcard of one label | `xyz.localhost` of a certificate of 
`*.localhost` failed the handshake of `UNAVAILABLE`, which the default policy 
retries | the name is checked as gRPC checks it twice (`tls_names`, a reader of 
the subject alternative names and the common name of the certificate): once the 
handshake is done, as `HostNameCertificateVerifier`, which takes it, and for 
each call, as `SslCheckCallHost`, which does not, so each call fails of 
`UNAUTHENTICATED` (`call host does not match SSL server name`), which is not 
retried | 
`connector::a_call_host_that_the_certificate_is_not_of_fails_each_call_of_unauthenticated`,
 the `tls_names` tests |
   | re-check 3: the long form of an IPv6 address | `[0:0:0:0:0:0:0:1]` passed 
a certificate of `IP:::1` | an IP address of the certificate is its text, as 
`inet_ntop` writes it, as gRPC compares it | the `tls_names` tests, 
`connector::the_tls_of_a_target_of_grpc_verifies_grpcs_name_of_it` |
   
   The KD row "Custom gRPC channels" loses those differences. It keeps, of 
these paths: a retry of the `ExecutePlan` of a finalizer, which reads 
`metadata()` on a thread of the transport, where PySpark's finalizer retries on 
its own thread; a session of a connection string, which takes the metadata of 
its calls of the parameters of the connection string as it is made, and does 
not call `ChannelBuilder.metadata()`, and whose key that gRPC does not take 
fails the creation of the session of `ValueError`, where grpcio fails each call 
of `INTERNAL`; a `grpc-status` of `metadata()`, which is not sent, where 
grpcio's call waits forever; and a target of `xds:` of a bootstrap of xDS in 
the environment, which fails each call, as the transport has no client of xDS. 
`docs/compatibility.md` describes the reads of the endpoint and the checks of 
the TLS name; `docs/configuration.md` the proxy of a loopback host.
   
   ### Why are the changes needed?
   
   So that the endpoint, the metadata and the TLS of a channel builder are 
those of PySpark's channel in the cases that the review found different, and 
the KD row lists no difference that is not inherent.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as the table says. Among them: a builder that the program gave the 
session is read for each call, so a key of its parameters that gRPC does not 
take fails each call of `INTERNAL` (`Invalid metadata`), as grpcio's, where it 
failed the creation of the session; a loopback host is proxied as grpcio 
proxies it, unless `no_proxy` lists it (`no_proxy=localhost,127.0.0.0/8,::1`); 
and a certificate of a wildcard of one label, or an IPv6 address of its long 
form, is checked as grpcio checks it.
   
   ### How was this patch tested?
   
   - **New and changed Rust tests** in `spark-connect-core`: `tls_names` (4: 
the names of a certificate as BoringSSL gives them, the text of `inet_ntop`, 
the two checks of gRPC), `proxy` (the loopback rule, zones and ports of 
`no_proxy`), `connector` (the call host of a wildcard of one label, the TLS of 
`127.000.000.001` and of a name in brackets, the text of a Unix address), 
`grpc_target` (bytes and NUL, `xds:` and `google-c2p:`, the `CONNECT` server up 
to a NUL), `metadata` (the reserved keys, the fields of a connection).
   - **Changed offline tests**: 
`test_a_channel_builder_is_read_as_pysparks_client_reads_it` (the default 
`metadata()` of a given builder for each call, none of a connection string), 
`test_no_connection_string_nor_endpoint_sets_the_channel_of_a_builder` (a key 
that gRPC does not take fails each call of a given builder, as grpcio's, and 
the creation of a session of a connection string).
   - **Probes of both clients** against a Spark 4.3.0 server, of the review's 
probes, on my own helpers (ports 18611-18645 and 18630):
     - `p_tls_edges.py`: 20 of 20 match grpcio (the security re-check found 17 
for #925);
     - the cases of `p_proxy2.py`: 24 of 24 match, of their outcomes and of the 
`CONNECT` lines that the proxy received (16 for #925);
     - `p_bytes.py`, `p_prtable.py`, `p_params_later.py`, `p_clone.py`, 
`p_reads.py`, `p_nested.py`, `p_exit.py` and `p_unreach.py` match; `p_long.py` 
but its 3,000-address list, whose `:authority` HTTP cannot hold (inherent, in 
the KD row); `p_backlog.py` but its timing.
   - **`cargo test -p apache-spark-connect -p apache-spark-connect-core 
--release`**: (running; filled in when it ends).
   - **The Rust and Python gates** (`gates.sh build rust py`): (running; filled 
in when they end).
   - **`test_dropin_e2e.py`** against a Spark 4.3.0 server: (running; filled in 
when it ends).
   - No dependency changes; `LICENSE-binary` and the JNI inventory are 
unchanged.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   
   This pull request and its description were written by Isaac.
   


-- 
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