From 4d4bf0e2697d5adf7ab91ba90f1f09a06bf15820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Thu, 21 Dec 2023 18:25:31 +0100 Subject: [PATCH 1/5] Update c2s and transport modules with the new exml - Replace max_child_size with max_element_size - Replace 'child element too big' with 'element too big' - Remove unsupported and obsolete exml options: autoreset, start_tag --- src/c2s/mongoose_c2s.erl | 4 ++-- src/mod_websockets.erl | 10 +++++----- src/mongoose_transport.erl | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/c2s/mongoose_c2s.erl b/src/c2s/mongoose_c2s.erl index 870f7d250d2..90abd45dcfb 100644 --- a/src/c2s/mongoose_c2s.erl +++ b/src/c2s/mongoose_c2s.erl @@ -89,7 +89,7 @@ init({SocketModule, SocketOpts, LOpts}) -> handle_event(internal, {connect, {SocketModule, SocketOpts}}, connect, StateData = #c2s_data{listener_opts = #{shaper := ShaperName, max_stanza_size := MaxStanzaSize} = LOpts}) -> - {ok, Parser} = exml_stream:new_parser([{max_child_size, MaxStanzaSize}]), + {ok, Parser} = exml_stream:new_parser([{max_element_size, MaxStanzaSize}]), Shaper = mongoose_shaper:new(ShaperName), C2SSocket = mongoose_c2s_socket:new(SocketModule, SocketOpts, LOpts), StateData1 = StateData#c2s_data{socket = C2SSocket, parser = Parser, shaper = Shaper}, @@ -112,7 +112,7 @@ handle_event(internal, #xmlstreamstart{}, _, StateData) -> handle_event(internal, #xmlstreamend{}, _, StateData) -> send_trailer(StateData), {stop, {shutdown, stream_end}}; -handle_event(internal, #xmlstreamerror{name = <<"child element too big">> = Err}, _, StateData) -> +handle_event(internal, #xmlstreamerror{name = <<"element too big">> = Err}, _, StateData) -> c2s_stream_error(StateData, mongoose_xmpp_errors:policy_violation(StateData#c2s_data.lang, Err)); handle_event(internal, #xmlstreamerror{name = Err}, _, StateData) -> c2s_stream_error(StateData, mongoose_xmpp_errors:xml_not_well_formed(StateData#c2s_data.lang, Err)); diff --git a/src/mod_websockets.erl b/src/mod_websockets.erl index 26aea154acb..4f3ed564b28 100644 --- a/src/mod_websockets.erl +++ b/src/mod_websockets.erl @@ -181,7 +181,7 @@ process_client_elements(Elements, #ws_state{fsm_pid = FSM} = State) -> process_parse_error(_Reason, #ws_state{fsm_pid = undefined} = State) -> {stop, State}; process_parse_error(Reason, #ws_state{fsm_pid = FSM} = State) -> - send_to_fsm(FSM, {xmlstreamerror, Reason}), + send_to_fsm(FSM, #xmlstreamerror{name = iolist_to_binary(Reason)}), {ok, State}. send_to_fsm(FSM, Element) -> @@ -271,14 +271,14 @@ replace_stream_ns(Element) -> end. get_parser_opts(Text, #ws_state{ max_stanza_size = infinity }) -> - [{max_child_size, 0} | get_parser_opts(Text)]; + [{max_element_size, 0} | get_parser_opts(Text)]; get_parser_opts(Text, #ws_state{ max_stanza_size = MaxStanzaSize }) -> - [{max_child_size, MaxStanzaSize} | get_parser_opts(Text)]. + [{max_element_size, MaxStanzaSize} | get_parser_opts(Text)]. get_parser_opts(<<">) -> - [{infinite_stream, true}, {autoreset, true}]; % new-type WS + [{infinite_stream, true}]; % new-type WS get_parser_opts(_) -> - [{start_tag, <<"stream:stream">>}]. % old-type WS + []. % old-type WS %%-------------------------------------------------------------------- %% Helpers diff --git a/src/mongoose_transport.erl b/src/mongoose_transport.erl index 46f6d9e42cf..b1aea5102b8 100644 --- a/src/mongoose_transport.erl +++ b/src/mongoose_transport.erl @@ -435,7 +435,7 @@ new_parser(MaxStanzaSize) -> infinity -> 0; _ -> MaxStanzaSize end, - {ok, NewParser} = exml_stream:new_parser([{max_child_size, MaxSize}]), + {ok, NewParser} = exml_stream:new_parser([{max_element_size, MaxSize}]), NewParser. -spec reset_parser(state()) -> state(). From 1560697ff23882cc62c2ac1529170186b2c855f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Thu, 21 Dec 2023 18:28:36 +0100 Subject: [PATCH 2/5] Add more tests for max_stanza_size - Test with websockets, because they don't get chunked input and were failing before fixing exml. - Test the limit for stream opening tag as well. --- big_tests/tests/mim_c2s_SUITE.erl | 22 ++++++++++++++--- big_tests/tests/websockets_SUITE.erl | 37 +++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/big_tests/tests/mim_c2s_SUITE.erl b/big_tests/tests/mim_c2s_SUITE.erl index 2f846477002..18aa02ea6f0 100644 --- a/big_tests/tests/mim_c2s_SUITE.erl +++ b/big_tests/tests/mim_c2s_SUITE.erl @@ -8,6 +8,7 @@ -include_lib("escalus/include/escalus.hrl"). -include_lib("escalus/include/escalus_xmlns.hrl"). -define(BAD_RESOURCE, <<"\x{EFBB}"/utf8>>). +-define(MAX_STANZA_SIZE, 1024). -import(distributed_helper, [mim/0]). @@ -28,7 +29,8 @@ groups() -> client_sets_stream_from_server_answers_with_to, stream_from_does_not_match_sasl_jid_results_in_stream_error, two_users_can_log_and_chat, - too_big_stanza_rejected, + too_big_stanza_is_rejected, + too_big_opening_tag_is_rejected, message_sent_to_malformed_jid_results_in_error, verify_session_establishment_is_not_announced, invalid_resource_fails_to_log @@ -60,7 +62,8 @@ init_per_group(basic, Config) -> Config1 = save_c2s_listener(Config), Config2 = escalus_users:update_userspec(Config1, alice, connection_steps, Steps), Config3 = escalus_users:update_userspec(Config2, bob, connection_steps, Steps), - configure_c2s_listener(Config3, #{backwards_compatible_session => false, max_stanza_size => 1024}), + configure_c2s_listener(Config3, #{backwards_compatible_session => false, + max_stanza_size => ?MAX_STANZA_SIZE}), Config3; init_per_group(backwards_compatible_session, Config) -> Config. @@ -128,15 +131,26 @@ two_users_can_log_and_chat(Config) -> escalus:assert(is_chat_message, [<<"Hi!">>], escalus_client:wait_for_stanza(Alice)) end). -too_big_stanza_rejected(Config) -> +too_big_stanza_is_rejected(Config) -> AliceSpec = escalus_fresh:create_fresh_user(Config, alice), {ok, Alice, _Features} = escalus_connection:start(AliceSpec), - BigBody = base16:encode(crypto:strong_rand_bytes(1024)), + BigBody = base16:encode(crypto:strong_rand_bytes(?MAX_STANZA_SIZE)), escalus_client:send(Alice, escalus_stanza:chat_to(Alice, BigBody)), escalus:assert(is_stream_error, [<<"policy-violation">>, <<>>], escalus_client:wait_for_stanza(Alice)), escalus:assert(is_stream_end, escalus_client:wait_for_stanza(Alice)), true = escalus_connection:wait_for_close(Alice, timer:seconds(1)). +too_big_opening_tag_is_rejected(Config) -> + AliceSpec = escalus_fresh:create_fresh_user(Config, alice), + {ok, Alice, _Features} = escalus_connection:start(AliceSpec, []), + BigAttrs = [{<<"bigattr">>, base16:encode(crypto:strong_rand_bytes(?MAX_STANZA_SIZE))}], + escalus_client:send(Alice, #xmlel{name = <<"stream:stream">>, attrs = BigAttrs}), + escalus:assert(is_stream_start, escalus_client:wait_for_stanza(Alice)), + escalus:assert(is_stream_error, [<<"xml-not-well-formed">>, <<>>], + escalus_client:wait_for_stanza(Alice)), + escalus:assert(is_stream_end, escalus_client:wait_for_stanza(Alice)), + true = escalus_connection:wait_for_close(Alice, timer:seconds(1)). + message_sent_to_malformed_jid_results_in_error(Config) -> escalus:fresh_story(Config, [{alice, 1}, {bob, 1}], fun(Alice, Bob) -> % Alice sends message with malformed "to" diff --git a/big_tests/tests/websockets_SUITE.erl b/big_tests/tests/websockets_SUITE.erl index 4756bddc44a..1758ce71b42 100644 --- a/big_tests/tests/websockets_SUITE.erl +++ b/big_tests/tests/websockets_SUITE.erl @@ -20,11 +20,14 @@ -include_lib("escalus/include/escalus.hrl"). -include_lib("common_test/include/ct.hrl"). +-import(distributed_helper, [mim/0]). + %%-------------------------------------------------------------------- %% Suite configuration %%-------------------------------------------------------------------- -define(REGISTRATION_TIMEOUT, 2). %% seconds +-define(MAX_STANZA_SIZE, 200). all() -> [metrics_test, @@ -38,7 +41,8 @@ groups() -> test_cases() -> [chat_msg, escape_chat_msg, - escape_attrs]. + escape_attrs, + too_big_stanza_is_rejected]. suite() -> escalus:suite(). @@ -49,9 +53,12 @@ suite() -> init_per_suite(Config) -> Config1 = escalus:init_per_suite(Config), - escalus:create_users(Config1, escalus:get_users([alice, geralt, geralt_s, carol])). + Config2 = setup_listeners(Config1), + escalus:create_users(Config2, escalus:get_users([alice, geralt, geralt_s, carol])). end_per_suite(Config) -> + Listeners = ?config(original_listeners, Config), + [mongoose_helper:restart_listener(mim(), Listener) || Listener <- Listeners], Config1 = escalus:delete_users(Config, escalus:get_users([alice, geralt, geralt_s, carol])), escalus:end_per_suite(Config1). @@ -63,7 +70,6 @@ init_per_group(GroupName, Config) -> [{user, geralt} | Config] end. - end_per_group(_GroupName, _Config) -> ok. @@ -73,6 +79,19 @@ init_per_testcase(CaseName, Config) -> end_per_testcase(CaseName, Config) -> escalus:end_per_testcase(CaseName, Config). +setup_listeners(Config) -> + Listeners = mongoose_helper:get_listeners(mim(), #{module => ejabberd_cowboy}), + [mongoose_helper:restart_listener(mim(), update_listener(Listener)) || Listener <- Listeners], + [{original_listeners, Listeners} | Config]. + +update_listener(Listener = #{handlers := Handlers}) -> + Listener#{handlers := lists:map(fun update_handler/1, Handlers)}. + +update_handler(Handler = #{module := mod_websockets}) -> + Handler#{max_stanza_size := ?MAX_STANZA_SIZE}; +update_handler(Handler) -> + Handler. + %%-------------------------------------------------------------------- %% Message tests %%-------------------------------------------------------------------- @@ -96,6 +115,18 @@ metrics_test(Config) -> end). +too_big_stanza_is_rejected(Config) -> + escalus:story( + Config, [{alice, 1}, {?config(user, Config), 1}], + fun(Alice, Geralt) -> + BigBody = base16:encode(crypto:strong_rand_bytes(?MAX_STANZA_SIZE)), + escalus_client:send(Geralt, escalus_stanza:chat_to(Alice, BigBody)), + escalus:assert(is_stream_error, [<<"policy-violation">>, <<>>], escalus_client:wait_for_stanza(Geralt)), + escalus:assert(is_stream_end, escalus_client:wait_for_stanza(Geralt)), + true = escalus_connection:wait_for_close(Geralt, timer:seconds(1)), + escalus_assert:has_no_stanzas(Alice) + end). + chat_msg(Config) -> escalus:story(Config, [{alice, 1}, {?config(user, Config), 1}, {carol, 1}], fun(Alice, Geralt, Carol) -> From 486f6045f63d427ae7de12b47b304d4576feb930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Thu, 21 Dec 2023 18:30:22 +0100 Subject: [PATCH 3/5] Use the new exml and escalus (temporarily) - exml has the fix for max_element_size - escalus has the fix for handling the 'close' element in websockets --- big_tests/rebar.config | 2 +- big_tests/rebar.lock | 7 ++++--- rebar.config | 2 +- rebar.lock | 7 ++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/big_tests/rebar.config b/big_tests/rebar.config index f359d0cf45d..c0c8a7d784e 100644 --- a/big_tests/rebar.config +++ b/big_tests/rebar.config @@ -16,7 +16,7 @@ {proper, "1.4.0"}, {gun, "2.0.0-rc.2"}, {fusco, "0.1.1"}, - {escalus, "4.2.10"}, + {escalus, {git, "https://github.com/esl/escalus.git", {branch, "fix-ws-close"}}}, {cowboy, "2.9.0"}, {csv, "3.0.3", {pkg, csve}}, {amqp_client, "3.12.6"}, diff --git a/big_tests/rebar.lock b/big_tests/rebar.lock index 86d5c7ed90b..d6d1452ba69 100644 --- a/big_tests/rebar.lock +++ b/big_tests/rebar.lock @@ -8,7 +8,10 @@ {pkg,<<"credentials_obfuscation">>,<<"3.4.0">>}, 1}, {<<"csv">>,{pkg,<<"csve">>,<<"3.0.3">>},0}, - {<<"escalus">>,{pkg,<<"escalus">>,<<"4.2.10">>},0}, + {<<"escalus">>, + {git,"https://github.com/esl/escalus.git", + {ref,"b3d9b0f1f10ec98a22b3119a046af7310f89fe4c"}}, + 0}, {<<"esip">>,{pkg,<<"esip">>,<<"1.0.48">>},0}, {<<"exml">>,{pkg,<<"hexml">>,<<"3.3.3">>},0}, {<<"fast_pbkdf2">>,{pkg,<<"fast_pbkdf2">>,<<"1.0.3">>},2}, @@ -41,7 +44,6 @@ {<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>}, {<<"credentials_obfuscation">>, <<"34E18B126B3AEFD6E8143776FBE1CECEEA6792307C99AC5EE8687911F048CFD7">>}, {<<"csv">>, <<"69E7D9B3FDC72016644368762C6A3E6CBFEB85BCCADBF1BD99AB6C827E360E04">>}, - {<<"escalus">>, <<"3640C7EA77BCE0E5191751D9A02EF3A68CD0005F2705EC19026DFD96577D0434">>}, {<<"esip">>, <<"3B3B3AFC798BE9458517D4FD2730674322368E54C2C1211AA630327354946D1B">>}, {<<"exml">>, <<"C64FE46373886FD62F3F753D8031034E231DC0C138F9CD3539F738EF220F0960">>}, {<<"fast_pbkdf2">>, <<"4F09D6C6C20DBEE1970E0A6AE91432E1B7731F88426C671D083BAC31FFA1FDAD">>}, @@ -73,7 +75,6 @@ {<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>}, {<<"credentials_obfuscation">>, <<"738ACE0ED5545D2710D3F7383906FC6F6B582D019036E5269C4DBD85DBCED566">>}, {<<"csv">>, <<"741D1A55AABADAA3E0FE13051050101A73E90C4570B9F9403A939D9546813521">>}, - {<<"escalus">>, <<"08A84CAB2EDCE5F69EA5B93F039E6D7047FB3FF10CBD5B5AB855EE3144743B56">>}, {<<"esip">>, <<"02B9FC6E071415CBC62105F5115AEB68D11184BDAD3960DA7B62EA3E99E7FCCF">>}, {<<"exml">>, <<"CB54BF62E2902B52FE9CAF7E65176E764E8A10CCC51DE2DEDC0FC5C8D9F91AC6">>}, {<<"fast_pbkdf2">>, <<"2900431E2E6402F23A92754448BBD949DA366BC9C984FDC791DDCFCC41042434">>}, diff --git a/rebar.config b/rebar.config index 33afbeac85d..92d7c81c26d 100644 --- a/rebar.config +++ b/rebar.config @@ -53,7 +53,7 @@ [ %%% Stateless parsers {base16, "2.0.1"}, - {exml, "3.3.3", {pkg, hexml}}, + {exml, {git, "https://github.com/esl/exml.git", {branch, "max-element-size"}}}, {jiffy, "1.1.1"}, {jid, "2.0.0", {pkg, mongoose_jid}}, {tomerl, "0.5.0"}, diff --git a/rebar.lock b/rebar.lock index 988b92ca7ea..fab1afc4bde 100644 --- a/rebar.lock +++ b/rebar.lock @@ -31,7 +31,10 @@ {<<"eredis">>,{pkg,<<"eredis">>,<<"1.7.0">>},0}, {<<"erl_csv">>,{pkg,<<"erl_csv">>,<<"0.3.1">>},0}, {<<"erlcloud">>,{pkg,<<"erlcloud">>,<<"3.6.5">>},0}, - {<<"exml">>,{pkg,<<"hexml">>,<<"3.3.3">>},0}, + {<<"exml">>, + {git,"https://github.com/esl/exml.git", + {ref,"b9500bd9cef5a37782734f51310f9e713097dfb9"}}, + 0}, {<<"exometer_core">>, {git,"https://github.com/esl/exometer_core.git", {ref,"123daa053a4abb3ff4bdbf52f08344da535294e9"}}, @@ -148,7 +151,6 @@ {<<"eredis">>, <<"7A9B2B51ECDE73AF3399B344C6C7FA5141E6C77DF5FACE86E41E8365A1E5B08F">>}, {<<"erl_csv">>, <<"5AD1BB8093D198191384F2E96EB879B08B23F14E5F6FAD8D80BDC3EB623DE8DA">>}, {<<"erlcloud">>, <<"75B93168BF6F9CD4573B261D8F83FD2C89F7809AFEAAADABFA39ECE3F75F3055">>}, - {<<"exml">>, <<"C64FE46373886FD62F3F753D8031034E231DC0C138F9CD3539F738EF220F0960">>}, {<<"fast_pbkdf2">>, <<"4F09D6C6C20DBEE1970E0A6AE91432E1B7731F88426C671D083BAC31FFA1FDAD">>}, {<<"fast_scram">>, <<"BD0B946911B07D36EC22AD950FF22F77F27B94E4E24452AF966597C6D8CB5E7F">>}, {<<"fast_tls">>, <<"85FA7F3112EA4FF5CCB4F3ABADC130A8C855AD74EB00869487399CB0C322D208">>}, @@ -212,7 +214,6 @@ {<<"eredis">>, <<"A49E7B11A2E1DF91EC3DA565DBD1A9530C95A5AC03127D3810D735F9EABF6F2E">>}, {<<"erl_csv">>, <<"21186276E59258F6F35F1CA2ECDFA995508B2E0055D502DCA1DCD09E3231F445">>}, {<<"erlcloud">>, <<"9E482E6B1C956A649AE878CBE46494BC36E6CAFA1C677B30158C0ED4BAD789E9">>}, - {<<"exml">>, <<"CB54BF62E2902B52FE9CAF7E65176E764E8A10CCC51DE2DEDC0FC5C8D9F91AC6">>}, {<<"fast_pbkdf2">>, <<"2900431E2E6402F23A92754448BBD949DA366BC9C984FDC791DDCFCC41042434">>}, {<<"fast_scram">>, <<"D45B746B8D17C0F73A94CBDB526E115A4AEDFECB4D42CA935BCB1195D783B4E1">>}, {<<"fast_tls">>, <<"AA08CCA89B4044E74F1F12E399817D8BEAEAE3EE006C98A893C0BFB1D81FBA51">>}, From 192063377cddee97f3958980293d732b91838150 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Fri, 22 Dec 2023 17:23:37 +0100 Subject: [PATCH 4/5] Update escalus and exml to the latest oficial releases --- big_tests/rebar.config | 4 ++-- big_tests/rebar.lock | 37 ++++++++++++++++++------------------- rebar.config | 2 +- rebar.lock | 7 +++---- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/big_tests/rebar.config b/big_tests/rebar.config index c0c8a7d784e..c766219e207 100644 --- a/big_tests/rebar.config +++ b/big_tests/rebar.config @@ -10,13 +10,13 @@ {deps, [ {lager, "3.9.2"}, {base16, "2.0.1"}, - {exml, "3.3.3", {pkg, hexml}}, + {exml, "3.4.0", {pkg, hexml}}, {bbmustache, "1.12.2"}, {jiffy, "1.1.1"}, {proper, "1.4.0"}, {gun, "2.0.0-rc.2"}, {fusco, "0.1.1"}, - {escalus, {git, "https://github.com/esl/escalus.git", {branch, "fix-ws-close"}}}, + {escalus, "4.2.11"}, {cowboy, "2.9.0"}, {csv, "3.0.3", {pkg, csve}}, {amqp_client, "3.12.6"}, diff --git a/big_tests/rebar.lock b/big_tests/rebar.lock index d6d1452ba69..ed402ca0d3a 100644 --- a/big_tests/rebar.lock +++ b/big_tests/rebar.lock @@ -8,14 +8,11 @@ {pkg,<<"credentials_obfuscation">>,<<"3.4.0">>}, 1}, {<<"csv">>,{pkg,<<"csve">>,<<"3.0.3">>},0}, - {<<"escalus">>, - {git,"https://github.com/esl/escalus.git", - {ref,"b3d9b0f1f10ec98a22b3119a046af7310f89fe4c"}}, - 0}, + {<<"escalus">>,{pkg,<<"escalus">>,<<"4.2.11">>},0}, {<<"esip">>,{pkg,<<"esip">>,<<"1.0.48">>},0}, - {<<"exml">>,{pkg,<<"hexml">>,<<"3.3.3">>},0}, + {<<"exml">>,{pkg,<<"hexml">>,<<"3.4.0">>},0}, {<<"fast_pbkdf2">>,{pkg,<<"fast_pbkdf2">>,<<"1.0.3">>},2}, - {<<"fast_scram">>,{pkg,<<"fast_scram">>,<<"0.4.4">>},1}, + {<<"fast_scram">>,{pkg,<<"fast_scram">>,<<"0.5.0">>},1}, {<<"fast_tls">>,{pkg,<<"fast_tls">>,<<"1.1.16">>},1}, {<<"fusco">>,{pkg,<<"fusco">>,<<"0.1.1">>},0}, {<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.9">>},1}, @@ -26,15 +23,15 @@ {<<"meck">>,{pkg,<<"meck">>,<<"0.9.2">>},1}, {<<"p1_utils">>,{pkg,<<"p1_utils">>,<<"1.0.25">>},1}, {<<"proper">>,{pkg,<<"proper">>,<<"1.4.0">>},0}, - {<<"quickrand">>,{pkg,<<"quickrand">>,<<"2.0.5">>},2}, + {<<"quickrand">>,{pkg,<<"quickrand">>,<<"2.0.7">>},2}, {<<"rabbit_common">>,{pkg,<<"rabbit_common">>,<<"3.12.6">>},1}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1}, {<<"recon">>,{pkg,<<"recon">>,<<"2.5.3">>},2}, {<<"stringprep">>,{pkg,<<"stringprep">>,<<"1.0.27">>},1}, {<<"stun">>,{pkg,<<"stun">>,<<"1.2.6">>},1}, {<<"thoas">>,{pkg,<<"thoas">>,<<"1.0.0">>},2}, - {<<"uuid">>,{pkg,<<"uuid_erl">>,<<"2.0.5">>},1}, - {<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"6.0.1">>},1}]}. + {<<"uuid">>,{pkg,<<"uuid_erl">>,<<"2.0.7">>},1}, + {<<"worker_pool">>,{pkg,<<"worker_pool">>,<<"6.2.0">>},1}]}. [ {pkg_hash,[ {<<"amqp_client">>, <<"B0050183BB4CFBD5B3F9A3276689DFA135A196AEDC3584110F231B2CE04B0426">>}, @@ -44,10 +41,11 @@ {<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>}, {<<"credentials_obfuscation">>, <<"34E18B126B3AEFD6E8143776FBE1CECEEA6792307C99AC5EE8687911F048CFD7">>}, {<<"csv">>, <<"69E7D9B3FDC72016644368762C6A3E6CBFEB85BCCADBF1BD99AB6C827E360E04">>}, + {<<"escalus">>, <<"FBEC4F874AACCFD5B493EE9CFE39F7FE9DDADFCB5054DFD83B8965B64ED43497">>}, {<<"esip">>, <<"3B3B3AFC798BE9458517D4FD2730674322368E54C2C1211AA630327354946D1B">>}, - {<<"exml">>, <<"C64FE46373886FD62F3F753D8031034E231DC0C138F9CD3539F738EF220F0960">>}, + {<<"exml">>, <<"18F9B02107E14F6CCDEFBDB7FEB0706C56AD3AFD0DD524BDD1F0ECD98746B9BC">>}, {<<"fast_pbkdf2">>, <<"4F09D6C6C20DBEE1970E0A6AE91432E1B7731F88426C671D083BAC31FFA1FDAD">>}, - {<<"fast_scram">>, <<"299A2D430955A62A94CB43B1A727C5D21A5C4BD11AEBA476AE2F3A24CFBE89C3">>}, + {<<"fast_scram">>, <<"BD0B946911B07D36EC22AD950FF22F77F27B94E4E24452AF966597C6D8CB5E7F">>}, {<<"fast_tls">>, <<"85FA7F3112EA4FF5CCB4F3ABADC130A8C855AD74EB00869487399CB0C322D208">>}, {<<"fusco">>, <<"3DD6A90151DFEF30EA1937CC44E9A59177C0094918388D9BCAA2F2DC5E2AE4AA">>}, {<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>}, @@ -58,15 +56,15 @@ {<<"meck">>, <<"85CCBAB053F1DB86C7CA240E9FC718170EE5BDA03810A6292B5306BF31BAE5F5">>}, {<<"p1_utils">>, <<"2D39B5015A567BBD2CC7033EEB93A7C60D8C84EFE1EF69A3473FAA07FA268187">>}, {<<"proper">>, <<"89A44B8C39D28BB9B4BE8E4D715D534905B325470F2E0EC5E004D12484A79434">>}, - {<<"quickrand">>, <<"06FCAD85CB47D5C85C51D6BC9C84A082501BA098A89D64AD0A2F69599E034C04">>}, + {<<"quickrand">>, <<"D2BD76676A446E6A058D678444B7FDA1387B813710D1AF6D6E29BB92186C8820">>}, {<<"rabbit_common">>, <<"FEBD37E11483F94B614CD636C1EDBCE1099FF64866598F75D0A624D3A60437C6">>}, {<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>}, {<<"recon">>, <<"739107B9050EA683C30E96DE050BC59248FD27EC147696F79A8797FF9FA17153">>}, {<<"stringprep">>, <<"02808C7024BC6285CA6A8A67E7ADDFC16F35DDA55551A582C5181D8EA960E890">>}, {<<"stun">>, <<"5D1978D340EA20EFB28BC1E58779A3A1D64568C66168DB4D20692E76CE813D5E">>}, {<<"thoas">>, <<"567C03902920827A18A89F05B79A37B5BF93553154B883E0131801600CF02CE0">>}, - {<<"uuid">>, <<"60FAEEB7EDFD40847ED13CB0DD1044BAABE4E79A00C0CA9C4D13A073914B1016">>}, - {<<"worker_pool">>, <<"CA262C2DFB3B4AF661B206C82065D86F83922B7227508AA6E0BC34D3E5AE5135">>}]}, + {<<"uuid">>, <<"B2078D2CC814F53AFA52D36C91E08962C7E7373585C623F4C0EA6DFB04B2AF94">>}, + {<<"worker_pool">>, <<"506DE38C528A81ED2C6A80A419B83DDE6DA5E295BD320BDF4D35A69AFEB0247A">>}]}, {pkg_hash_ext,[ {<<"amqp_client">>, <<"B856F6404E7AF98C90DA870C8CE50D1380F13F2CEE02F16564B5CC5142BAE308">>}, {<<"base16">>, <<"06EA2D48343282E712160BA89F692B471DB8B36ABE8394F3445FF9032251D772">>}, @@ -75,10 +73,11 @@ {<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>}, {<<"credentials_obfuscation">>, <<"738ACE0ED5545D2710D3F7383906FC6F6B582D019036E5269C4DBD85DBCED566">>}, {<<"csv">>, <<"741D1A55AABADAA3E0FE13051050101A73E90C4570B9F9403A939D9546813521">>}, + {<<"escalus">>, <<"4E1262E6B1EEF834FE421FA1D3BBE69EF2028A8B88140DC397703B31B904C6D0">>}, {<<"esip">>, <<"02B9FC6E071415CBC62105F5115AEB68D11184BDAD3960DA7B62EA3E99E7FCCF">>}, - {<<"exml">>, <<"CB54BF62E2902B52FE9CAF7E65176E764E8A10CCC51DE2DEDC0FC5C8D9F91AC6">>}, + {<<"exml">>, <<"5F73224B784D45C743A949FC5AF4BB441B6B546B3D9883C0441D45401505ADD2">>}, {<<"fast_pbkdf2">>, <<"2900431E2E6402F23A92754448BBD949DA366BC9C984FDC791DDCFCC41042434">>}, - {<<"fast_scram">>, <<"4B30084E3BDB39158076381FC871035BEFD157D5EE614BDA5E19EA482855E5D5">>}, + {<<"fast_scram">>, <<"D45B746B8D17C0F73A94CBDB526E115A4AEDFECB4D42CA935BCB1195D783B4E1">>}, {<<"fast_tls">>, <<"AA08CCA89B4044E74F1F12E399817D8BEAEAE3EE006C98A893C0BFB1D81FBA51">>}, {<<"fusco">>, <<"6343551BD1E824F2A6CA85E1158C5B37C320FD449FBFEC7450A73F192AAF9022">>}, {<<"goldrush">>, <<"99CB4128CFFCB3227581E5D4D803D5413FA643F4EB96523F77D9E6937D994CEB">>}, @@ -89,13 +88,13 @@ {<<"meck">>, <<"81344F561357DC40A8344AFA53767C32669153355B626EA9FCBC8DA6B3045826">>}, {<<"p1_utils">>, <<"9219214428F2C6E5D3187FF8EB9A8783695C2427420BE9A259840E07ADA32847">>}, {<<"proper">>, <<"18285842185BD33EFBDA97D134A5CB5A0884384DB36119FEE0E3CFA488568CBB">>}, - {<<"quickrand">>, <<"252CF0493570EBF1A58985CB71990982CDDCD4396B6427F1E10CF58924C1C052">>}, + {<<"quickrand">>, <<"B8ACBF89A224BC217C3070CA8BEBC6EB236DBE7F9767993B274084EA044D35F0">>}, {<<"rabbit_common">>, <<"D85282C8C9BE456B42AA4B265EDE68D176CA8A28DFCF1D521BE19267167C0DC3">>}, {<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>}, {<<"recon">>, <<"6C6683F46FD4A1DFD98404B9F78DCABC7FCD8826613A89DCB984727A8C3099D7">>}, {<<"stringprep">>, <<"A5967B1144CA8002A58A03D16DD109FBD0BCDB82616CEAD2F983944314AF6A00">>}, {<<"stun">>, <<"21AED098457E5099E925129459590592E001C470CF7503E5614A7A6B688FF146">>}, {<<"thoas">>, <<"FC763185B932ECB32A554FB735EE03C3B6B1B31366077A2427D2A97F3BD26735">>}, - {<<"uuid">>, <<"E54373262CA88401689277947C54B95E9ECBC977BD5C57C9DD44AD9DA278E360">>}, - {<<"worker_pool">>, <<"772E12CCB26909EA7F804B52E86E733DF66BB8150F683B591B0A762196494C74">>}]} + {<<"uuid">>, <<"4E4C5CA3461DC47C5E157ED42AA3981A053B7A186792AF972A27B14A9489324E">>}, + {<<"worker_pool">>, <<"E1DED160797FBE656AD683109DBD741B520097DF17BDF7B51E3E4697073A6E62">>}]} ]. diff --git a/rebar.config b/rebar.config index 92d7c81c26d..ad3b589f98a 100644 --- a/rebar.config +++ b/rebar.config @@ -53,7 +53,7 @@ [ %%% Stateless parsers {base16, "2.0.1"}, - {exml, {git, "https://github.com/esl/exml.git", {branch, "max-element-size"}}}, + {exml, "3.4.0", {pkg, hexml}}, {jiffy, "1.1.1"}, {jid, "2.0.0", {pkg, mongoose_jid}}, {tomerl, "0.5.0"}, diff --git a/rebar.lock b/rebar.lock index fab1afc4bde..bf855d3b449 100644 --- a/rebar.lock +++ b/rebar.lock @@ -31,10 +31,7 @@ {<<"eredis">>,{pkg,<<"eredis">>,<<"1.7.0">>},0}, {<<"erl_csv">>,{pkg,<<"erl_csv">>,<<"0.3.1">>},0}, {<<"erlcloud">>,{pkg,<<"erlcloud">>,<<"3.6.5">>},0}, - {<<"exml">>, - {git,"https://github.com/esl/exml.git", - {ref,"b9500bd9cef5a37782734f51310f9e713097dfb9"}}, - 0}, + {<<"exml">>,{pkg,<<"hexml">>,<<"3.4.0">>},0}, {<<"exometer_core">>, {git,"https://github.com/esl/exometer_core.git", {ref,"123daa053a4abb3ff4bdbf52f08344da535294e9"}}, @@ -151,6 +148,7 @@ {<<"eredis">>, <<"7A9B2B51ECDE73AF3399B344C6C7FA5141E6C77DF5FACE86E41E8365A1E5B08F">>}, {<<"erl_csv">>, <<"5AD1BB8093D198191384F2E96EB879B08B23F14E5F6FAD8D80BDC3EB623DE8DA">>}, {<<"erlcloud">>, <<"75B93168BF6F9CD4573B261D8F83FD2C89F7809AFEAAADABFA39ECE3F75F3055">>}, + {<<"exml">>, <<"18F9B02107E14F6CCDEFBDB7FEB0706C56AD3AFD0DD524BDD1F0ECD98746B9BC">>}, {<<"fast_pbkdf2">>, <<"4F09D6C6C20DBEE1970E0A6AE91432E1B7731F88426C671D083BAC31FFA1FDAD">>}, {<<"fast_scram">>, <<"BD0B946911B07D36EC22AD950FF22F77F27B94E4E24452AF966597C6D8CB5E7F">>}, {<<"fast_tls">>, <<"85FA7F3112EA4FF5CCB4F3ABADC130A8C855AD74EB00869487399CB0C322D208">>}, @@ -214,6 +212,7 @@ {<<"eredis">>, <<"A49E7B11A2E1DF91EC3DA565DBD1A9530C95A5AC03127D3810D735F9EABF6F2E">>}, {<<"erl_csv">>, <<"21186276E59258F6F35F1CA2ECDFA995508B2E0055D502DCA1DCD09E3231F445">>}, {<<"erlcloud">>, <<"9E482E6B1C956A649AE878CBE46494BC36E6CAFA1C677B30158C0ED4BAD789E9">>}, + {<<"exml">>, <<"5F73224B784D45C743A949FC5AF4BB441B6B546B3D9883C0441D45401505ADD2">>}, {<<"fast_pbkdf2">>, <<"2900431E2E6402F23A92754448BBD949DA366BC9C984FDC791DDCFCC41042434">>}, {<<"fast_scram">>, <<"D45B746B8D17C0F73A94CBDB526E115A4AEDFECB4D42CA935BCB1195D783B4E1">>}, {<<"fast_tls">>, <<"AA08CCA89B4044E74F1F12E399817D8BEAEAE3EE006C98A893C0BFB1D81FBA51">>}, From 309fb47eb01ecd1134a74f15884848de232022c2 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Fri, 22 Dec 2023 17:30:43 +0100 Subject: [PATCH 5/5] Fix using proper jid records from mongoose_jid instead of from escalus --- big_tests/tests/anonymous_SUITE.erl | 5 +++-- big_tests/tests/bind2_SUITE.erl | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/big_tests/tests/anonymous_SUITE.erl b/big_tests/tests/anonymous_SUITE.erl index 9bb57987fa6..d3e9c852fd9 100644 --- a/big_tests/tests/anonymous_SUITE.erl +++ b/big_tests/tests/anonymous_SUITE.erl @@ -17,6 +17,7 @@ -module(anonymous_SUITE). -compile([export_all, nowarn_export_all]). +-include_lib("jid/include/jid.hrl"). -include_lib("escalus/include/escalus.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -67,7 +68,7 @@ connection_is_registered_with_sasl_anon(Config) -> escalus:story(Config, [{jon, 1}], fun(Jon) -> JID = jid:from_binary(escalus_client:short_jid(Jon)), OrigName = escalus_users:get_username(Config, jon), - ?assertNotEqual(OrigName, JID#jid.user), + ?assertNotEqual(OrigName, JID#jid.luser), F = fun() -> rpc(mim(), ejabberd_auth, does_user_exist, [JID]) end, true = F(), escalus_connection:kill(Jon), @@ -78,7 +79,7 @@ connection_is_registered_with_login(Config) -> escalus:story(Config, [{anna, 1}], fun(Anna) -> JID = jid:from_binary(escalus_client:short_jid(Anna)), OrigName = escalus_users:get_username(Config, anna), - ?assertEqual(OrigName, JID#jid.user), + ?assertEqual(OrigName, JID#jid.luser), F = fun() -> rpc(mim(), ejabberd_auth, does_user_exist, [JID]) end, true = F(), escalus_connection:kill(Anna), diff --git a/big_tests/tests/bind2_SUITE.erl b/big_tests/tests/bind2_SUITE.erl index 73d5170a887..6a42b8f33a3 100644 --- a/big_tests/tests/bind2_SUITE.erl +++ b/big_tests/tests/bind2_SUITE.erl @@ -4,6 +4,7 @@ -include_lib("stdlib/include/assert.hrl"). -include_lib("exml/include/exml.hrl"). +-include_lib("jid/include/jid.hrl"). -include_lib("escalus/include/escalus.hrl"). -include_lib("escalus/include/escalus_xmlns.hrl"). @@ -100,7 +101,7 @@ auth_and_bind_to_random_resource(Config) -> Bound = exml_query:path(Success, [{element_with_ns, <<"bound">>, ?NS_BIND_2}]), ?assertNotEqual(undefined, Bound), Identifier = exml_query:path(Success, [{element, <<"authorization-identifier">>}, cdata]), - #jid{resource = LResource} = jid:from_binary(Identifier), + #jid{lresource = LResource} = jid:from_binary(Identifier), ?assert(0 =< byte_size(LResource), LResource). auth_and_bind_do_not_expose_user_agent_id_in_client(Config) -> @@ -110,7 +111,7 @@ auth_and_bind_do_not_expose_user_agent_id_in_client(Config) -> Bound = exml_query:path(Success, [{element_with_ns, <<"bound">>, ?NS_BIND_2}]), ?assertNotEqual(undefined, Bound), Identifier = exml_query:path(Success, [{element, <<"authorization-identifier">>}, cdata]), - #jid{resource = LResource} = jid:from_binary(Identifier), + #jid{lresource = LResource} = jid:from_binary(Identifier), ?assertNotEqual(Uuid, LResource). auth_and_bind_contains_client_tag(Config) -> @@ -120,7 +121,7 @@ auth_and_bind_contains_client_tag(Config) -> Bound = exml_query:path(Success, [{element_with_ns, <<"bound">>, ?NS_BIND_2}]), ?assertNotEqual(undefined, Bound), Identifier = exml_query:path(Success, [{element, <<"authorization-identifier">>}, cdata]), - #jid{resource = LResource} = jid:from_binary(Identifier), + #jid{lresource = LResource} = jid:from_binary(Identifier), ResourceParts = binary:split(LResource, <<"/">>, [global]), ?assertMatch([Tag, _], ResourceParts). @@ -180,7 +181,7 @@ stream_resumption_failing_does_bind_and_contains_sm_status(Config) -> Resumed = exml_query:path(Success, [{element_with_ns, <<"failed">>, ?NS_STREAM_MGNT_3}]), escalus:assert(is_sm_failed, [<<"item-not-found">>], Resumed), Identifier = exml_query:path(Success, [{element, <<"authorization-identifier">>}, cdata]), - #jid{resource = LResource} = jid:from_binary(Identifier), + #jid{lresource = LResource} = jid:from_binary(Identifier), ResourceParts = binary:split(LResource, <<"/">>, [global]), ?assertMatch([Tag, _], ResourceParts). @@ -286,7 +287,7 @@ plain_auth(_Config, Client, Data, BindElems, Extra) -> escalus:send(Client, Authenticate), Answer = escalus_client:wait_for_stanza(Client), Identifier = exml_query:path(Answer, [{element, <<"authorization-identifier">>}, cdata]), - #jid{resource = LResource} = jid:from_binary(Identifier), + #jid{lresource = LResource} = jid:from_binary(Identifier), {Client, Data#{answer => Answer, client_1_jid => Identifier, bind2_resource => LResource}}. start_peer(Config, Client, Data) ->