Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tsl typo and comment about address validation #238

Merged
merged 2 commits into from
Dec 23, 2022
Merged

Conversation

kentonv
Copy link
Member

@kentonv kentonv commented Dec 22, 2022

This addresses my unresolved comments from #162.

I actually don't know what the right answer is here but I wanted to add some discussion and remove the suggestion of delegating to KJ's `parseAddress()` which doesn't seem like the right answer.
@kentonv kentonv requested a review from dom96 December 22, 2022 20:59
@@ -62,8 +62,8 @@ class PipelinedAsyncIoStream final : public kj::AsyncIoStream, public kj::Refcou
};

struct SocketOptions {
bool tsl; // TODO(later): TCP socket options need to be implemented.
JSG_STRUCT(tsl);
jsg::Unimplemented tls; // TODO(later): TCP socket options need to be implemented.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +20 to +34
// Note that we intentionally leave it up to the connect() implementation to decide what is a
// valid address. This means that people using `workerd`, for example, can arrange to connect
// to Unix sockets (if they define a "Network" service that permits local connections, which
// the default internet service will not). Also, hypothetically, in W2W communications, the
// address could be an arbitrary string which the receiving Worker can validate however it wants.
//
// TODO(soon): This results in an "internal error" in the case that the address couldn't parse,
// which is not a great experience. Should we attempt to validate the address here to give a
// better error? But that takes away the backend's flexibility to define its own address
// format. Maybe that's good though? It's more consistent with fetch(), which requires a
// valid URL even for W2W. The only other way we can get good errors here is if we use string
// matching to detect KJ's invalid-address error message, which seems pretty gross but could
// work. Note that if we do decide to validate addresses, we should not try to use KJ's
// `parseAddress()` but instead decide for ourselves what format we want to permit here, maybe
// as a regex.
Copy link
Collaborator

@dom96 dom96 Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I didn't consider leaving this to the connect implementation. But that sounds fair enough.

When I wrote this comment my primary concern was something like: connect("blah.org HTTP/1.1\r\nARBITRARY_HTTP_HEADERS_HERE"). Without validation this would mean the Worker can send arbitrary http headers to the proxy. But I suppose we should ensure this cannot happen in HttpClient (maybe HttpClient already does this?).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah hopefully HttpClient already prevents this. If it doesn't that is a bug we need to fix.

@dom96 dom96 merged commit 684caf6 into main Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants