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

Stream compression after sasl #616

Merged
merged 14 commits into from
Mar 31, 2016
Merged

Conversation

ludwikbukowski
Copy link
Contributor

@ludwikbukowski ludwikbukowski force-pushed the stream-compression-after-SASL branch 2 times, most recently from 2e16000 to ab60c8c Compare December 9, 2015 18:12
@michalwski
Copy link
Contributor

I think you have to change rebar.config in test/ejabberd_tests to use escalus from your branch.

stream_start_features_before_bind(S);
{_, _} ->
{_, <<>>, _} ->
stream_start_features_before_auth(S);
Copy link
Contributor

Choose a reason for hiding this comment

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

In this branch the user is authenticated so it's misleading to use function named *_before_auth (even if the output is the same). Maybe the function name should be changed to reflect both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right it can lead to confusion

@ludwikbukowski ludwikbukowski force-pushed the stream-compression-after-SASL branch 3 times, most recently from 8505806 to e85a282 Compare December 10, 2015 16:29
Value.

%% tests for different order feature negotiation
tls_compression_authenticate(Config) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

According to XEP-0138 we shouldn't allow compression before authentication. It may be used by malicious and not-registered users to attack the server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hence order of feature negotiation should be also changed in escalus_connection:start function:
https://github.com/esl/escalus/blob/master/src/escalus_connection.erl#L70

I've done it here esl/escalus#88

@ludwikbukowski
Copy link
Contributor Author

I will try do some code refactoring so its still WIP

@ludwikbukowski ludwikbukowski force-pushed the stream-compression-after-SASL branch from 6dfb78b to 3349951 Compare February 17, 2016 11:40
@michalwski michalwski mentioned this pull request Feb 22, 2016
7 tasks
@michalwski michalwski added this to the MongooseIM 1.7.0 milestone Feb 22, 2016
@@ -772,7 +756,7 @@ wait_for_session_or_sm({xmlstreamelement, El}, StateData0) ->
#iq{type = set, xmlns = ?NS_SESSION} ->
maybe_open_session(El, StateData);
_ ->
fsm_next_state(wait_for_session_or_sm, StateData)
maybe_do_compress(El, wait_for_session_or_sm, StateData)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should end up in the same state after enabling the compression, but this time compression shouldn't be allowed. How else the binding process will happen?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, sorry, forgot that you have to open session after enabling a feature... no comment then...

@@ -734,7 +718,7 @@ wait_for_bind_or_resume({xmlstreamelement, El}, StateData) ->
StateData#state{resource = R, jid = JID})
end;
_ ->
fsm_next_state(wait_for_bind_or_resume, StateData)
maybe_do_compress(El, wait_for_bind_or_resume, StateData)
end;

wait_for_bind_or_resume(timeout, StateData) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this name is not valid any more. Now we can do bind or resume or compression here. How about naming it wait_for_feature_after_auth?

@ludwikbukowski
Copy link
Contributor Author

Why tests don't pass?

@michalwski
Copy link
Contributor

Alternatively, we can rebase this branch on top of rel-1.7. The amount of changes and possible conflicts (while rebasing) will be comparable.

@ludwikbukowski ludwikbukowski force-pushed the stream-compression-after-SASL branch 4 times, most recently from 56960ca to 546a708 Compare March 21, 2016 11:01
maybe_do_compress(El, NextState, StateData) ->
SockMod = (StateData#state.sockmod):get_sockmod(StateData#state.socket),
{Zlib, _} = StateData#state.zlib,
#xmlel{name = Name, attrs = Attrs, children = _} = El,
Copy link
Contributor

Choose a reason for hiding this comment

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

How about moving this matching to the function's head?
Also this part:

children = _

is redundant

@@ -57,6 +60,13 @@ groups() ->
invalid_stream_namespace]},
{pre_xmpp_1_0, [], [pre_xmpp_1_0_stream]},
{starttls, test_cases()},
{feature_order, [stream_features_test,
Copy link
Contributor

Choose a reason for hiding this comment

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

As we are in process of adopting parallel tests I strongly recommend using the parallel property for this group and escalus_fresh module. You can take a look at this SUITE [1] for inspiration how to use it (also outside story - test case server_announces_csi).

[1]. https://github.com/esl/MongooseIM/blob/684bc0fbcab4c6e298961bcb7a0147c2b0678c0a/test/ejabberd_tests/tests/xep_0352_csi_SUITE.erl

@michalwski
Copy link
Contributor

Additionally I have a general comment/tip. Please set your IDE to use 4 spaces for tab and re-indent your changes. Currently you have 2 spaces.

Joseph Yiasemides and others added 12 commits March 29, 2016 14:16
Introduce a suite to test the order of stream feature advertisment and
negotiation. To begin with test the stream compression feature.
…to negotiate compression after tls.

There were matches on `tls` module which does not exist.
Fixed test for compression-authentication order

Authentication before compression in stream_features_test
* Introducing state "wait_for_feature_before_auth" instead of "wait_for_feature_request"
* Introducing state "waif_for_feature_after_auth" instead of "wait_for_bind_or_resume"
@ludwikbukowski ludwikbukowski force-pushed the stream-compression-after-SASL branch from b4e811c to 629010e Compare March 29, 2016 13:19
@michalwski michalwski merged commit 9f845ae into master Mar 31, 2016
@michalwski michalwski deleted the stream-compression-after-SASL branch March 31, 2016 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants