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

Treat privacy IQs send to users as regular stanzas #4361

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

jacekwegr
Copy link
Collaborator

@jacekwegr jacekwegr commented Aug 20, 2024

This PR changes how privacy and blocking IQs sent to other users are handled. They are now treated like regular stanzas. The logic in mod_privacy and mod_blocking has been modified to support this change.

@mongoose-im

This comment was marked as outdated.

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.94%. Comparing base (87ce067) to head (5d2244a).
Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4361      +/-   ##
==========================================
- Coverage   84.96%   84.94%   -0.02%     
==========================================
  Files         552      552              
  Lines       33697    33703       +6     
==========================================
  Hits        28630    28630              
- Misses       5067     5073       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jacekwegr jacekwegr force-pushed the handle-privacy-iq-to-user branch from 3610a38 to 09ba2fc Compare August 22, 2024 06:43
@mongoose-im
Copy link
Collaborator

mongoose-im commented Aug 22, 2024

elasticsearch_and_cassandra_27 / elasticsearch_and_cassandra_mnesia / 09ba2fc
Reports root/ big
OK: 439 / Failed: 0 / User-skipped: 47 / Auto-skipped: 0


small_tests_27 / small_tests / 09ba2fc
Reports root / small


small_tests_26 / small_tests / 09ba2fc
Reports root / small


small_tests_27_arm64 / small_tests / 09ba2fc
Reports root / small


ldap_mnesia_26 / ldap_mnesia / 09ba2fc
Reports root/ big
OK: 2340 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


ldap_mnesia_27 / ldap_mnesia / 09ba2fc
Reports root/ big
OK: 2340 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


dynamic_domains_mysql_redis_27 / mysql_redis / 09ba2fc
Reports root/ big
OK: 4590 / Failed: 0 / User-skipped: 145 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 09ba2fc
Reports root/ big
OK: 4623 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


internal_mnesia_27 / internal_mnesia / 09ba2fc
Reports root/ big
OK: 2480 / Failed: 0 / User-skipped: 765 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_27 / pgsql_mnesia / 09ba2fc
Reports root/ big
OK: 4623 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


pgsql_cets_27 / pgsql_cets / 09ba2fc
Reports root/ big
OK: 4534 / Failed: 0 / User-skipped: 179 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_27 / odbc_mssql_mnesia / 09ba2fc
Reports root/ big
OK: 4620 / Failed: 0 / User-skipped: 115 / Auto-skipped: 0


mysql_redis_27 / mysql_redis / 09ba2fc
Reports root/ big
OK: 4993 / Failed: 0 / User-skipped: 140 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 09ba2fc
Reports root/ big
OK: 5014 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


pgsql_mnesia_27 / pgsql_mnesia / 09ba2fc
Reports root/ big
OK: 5014 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


mssql_mnesia_27 / odbc_mssql_mnesia / 09ba2fc
Reports root/ big
OK: 5010 / Failed: 1 / User-skipped: 122 / Auto-skipped: 0

service_domain_db_SUITE:db:rest_without_auth:rest_without_auth_parallel:rest_delete_domain_cleans_data_from_mam
{error,
  {{badrpc,timeout},
   [{distributed_helper,rpc,
      [#{node => mongooseim@localhost},service_domain_db,sync_local,[]],
      [{file,
         "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
       {line,140}]},
    {service_domain_db_SUITE,sync_local,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1212}]},
    {service_domain_db_SUITE,sync,0,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1191}]},
    {service_domain_db_SUITE,
      '-rest_delete_domain_cleans_data_from_mam/1-fun-0-',5,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,963}]},
    {escalus_story,story,4,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,72}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1794}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1303}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1235}]}]}}

Report log


mssql_mnesia_27 / odbc_mssql_mnesia / 09ba2fc
Reports root/ big
OK: 5011 / Failed: 0 / User-skipped: 122 / Auto-skipped: 0

@jacekwegr jacekwegr marked this pull request as ready for review August 22, 2024 07:41
Copy link
Contributor

@gustawlippa gustawlippa left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, they do fix the problem of MIM "impersonating" somebody.

As a note, I think that the issue and test is a bit weird, as it happens when a user sends a blocking/privacy IQ to another user, which is not really something they should do according to the XEPs. It's unclear what would the other client do, probably drop the stanza, or return an error.
However, according to https://www.rfc-editor.org/rfc/rfc6120.html#section-10.5.4, the tested behaviour of MIM passing the stanza to the recipient is indeed correct, when the stanza is sent to a full JID - it is in the test. Maybe a note in the testcase pointing out that this is an edge case, that shouldn't really happen could be useful? Especially since, if I'm not mistaken, if Alice didn't sent to Bob's full JID, MIM should handle the IQ directly, so there is some nuance there (see the third dot of https://www.rfc-editor.org/rfc/rfc6120.html#section-10.5.3.2). But I'm fine with merging this as it is now as well, let me know if you'd like to add a note to the testcases or not.

@jacekwegr
Copy link
Collaborator Author

@gustawlippa

Thanks for the feedback! I agree this is an unusual case, and adding a note to the test about it being an edge case makes sense. I'll add that note to make it clear why this scenario is being tested.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Aug 22, 2024

elasticsearch_and_cassandra_27 / elasticsearch_and_cassandra_mnesia / 5d2244a
Reports root/ big
OK: 439 / Failed: 0 / User-skipped: 47 / Auto-skipped: 0


small_tests_27 / small_tests / 5d2244a
Reports root / small


small_tests_26 / small_tests / 5d2244a
Reports root / small


small_tests_27_arm64 / small_tests / 5d2244a
Reports root / small


ldap_mnesia_26 / ldap_mnesia / 5d2244a
Reports root/ big
OK: 2340 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


ldap_mnesia_27 / ldap_mnesia / 5d2244a
Reports root/ big
OK: 2340 / Failed: 0 / User-skipped: 905 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 5d2244a
Reports root/ big
OK: 4623 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


dynamic_domains_mysql_redis_27 / mysql_redis / 5d2244a
Reports root/ big
OK: 4590 / Failed: 0 / User-skipped: 145 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_27 / pgsql_mnesia / 5d2244a
Reports root/ big
OK: 4623 / Failed: 0 / User-skipped: 112 / Auto-skipped: 0


pgsql_cets_27 / pgsql_cets / 5d2244a
Reports root/ big
OK: 4534 / Failed: 0 / User-skipped: 179 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_27 / odbc_mssql_mnesia / 5d2244a
Reports root/ big
OK: 4620 / Failed: 0 / User-skipped: 115 / Auto-skipped: 0


internal_mnesia_27 / internal_mnesia / 5d2244a
Reports root/ big
OK: 2463 / Failed: 0 / User-skipped: 765 / Auto-skipped: 17

service_mongoose_system_metrics_SUITE:all_clustered_mongooses_report_the_same_client_id
{skip,
  {failed,
    {service_mongoose_system_metrics_SUITE,init_per_testcase,
      {{badrpc,timeout},
       [{distributed_helper,rpc,
          [#{timeout => 30000,node => mongooseim2@localhost},
           mongoose_cluster,join,
           [mongooseim@localhost]],
          [{file,
             "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
           {line,140}]},
        {distributed_helper,add_node_to_mnesia_cluster,2,
          [{file,
             "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
           {line,44}]},
        {distributed_helper,add_node_to_cluster,2,
          [{file,
             "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
           {line,36}]},
        {service_mongoose_system_metrics_SUITE,init_per_testcase,2,
          [{file,
             "/home/circleci/project/big_tests/tests/service_mongoose_system_metrics_SUITE.erl"},
           {line,113}]},
        {test_server,do_init_per_testcase,2,
          [{file,"test_server.erl"},{line,1564}]},
        {test_server,run_test_case_eval1,6,
          [{file,"test_server.erl"},{line,1265}]},
        {test_server,run_test_case_eval,9,
          [{file,"test_server.erl"},{line,1235}]}]}}}}

Report log

service_domain_db_SUITE:no_db:init_per_group
{'EXIT',
  {{badrpc,
     {'EXIT',
       {noproc,
         {gen_server,call,
           [mongoose_domain_sup,
            {terminate_child,mongoose_domain_core},
            infinity]}}}},
   [{distributed_helper,rpc,
      [#{node => mongooseim2@localhost},
       mongoose_domain_sup,restart_core,
       [[[],
       [<<"mim2only">>,<<"type1">>,<<"type2">>,<<"dummy auth">>,
        <<"dbgroup">>,<<"dbgroup2">>,<<"cfggroup">>]]]],
      [{file,
         "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
       {line,140}]},
    {domain_helper,restart_domain_core,3,
      [{file,"/home/circleci/project/big_tests/tests/domain_helper.erl"},
       {line,33}]},
    {service_domain_db_SUITE,setup_service,2,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,317}]},
    {service_domain_db_SUITE,init_per_group,2,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,240}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1794}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1391}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1235}]}]}}

Report log

service_domain_db_SUITE:end_per_suite
{error,
  {{badrpc,
     {'EXIT',
       {noproc,
         {gen_server,call,
           [mongoose_domain_sup,
            {terminate_child,mongoose_domain_core},
            infinity]}}}},
   [{distributed_helper,rpc,
      [#{node => mongooseim2@localhost},
       mongoose_domain_sup,restart_core,
       [[]]],
      [{file,
         "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
       {line,140}]},
    {domain_helper,restart_domain_core,1,
      [{file,"/home/circleci/project/big_tests/tests/domain_helper.erl"},
       {line,30}]},
    {service_domain_db_SUITE,'-end_per_suite/1-lc$^0/1-0-',1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,212}]},
    {service_domain_db_SUITE,end_per_suite,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,212}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1794}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1391}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1235}]}]}}

Report log

dynamic_domains_SUITE:init_per_suite
{'EXIT',
  {{badrpc,timeout},
   [{distributed_helper,rpc,
      [#{timeout => 30000,node => mongooseim2@localhost},
       mongoose_cluster,join,
       [mongooseim@localhost]],
      [{file,
         "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
       {line,140}]},
    {distributed_helper,add_node_to_mnesia_cluster,2,
      [{file,
         "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
       {line,44}]},
    {distributed_helper,add_node_to_cluster,2,
      [{file,
         "/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
       {line,36}]},
    {dynamic_domains_SUITE,cluster_nodes,2,
      [{file,
         "/home/circleci/project/big_tests/tests/dynamic_domains_SUITE.erl"},
       {line,210}]},
    {dynamic_domains_SUITE,init_per_suite,1,
      [{file,
         "/home/circleci/project/big_tests/tests/dynamic_domains_SUITE.erl"},
       {line,32}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1794}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1391}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1235}]}]}}

Report log

local_iq_SUITE:init_per_suite
{'EXIT',{{badrpc,timeout},
     [{distributed_helper,rpc,
                [#{timeout => 30000,
                 node => mongooseim2@localhost},
                 mongoose_cluster,join,
                 [mongooseim@localhost]],
                [{file,"/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
                 {line,140}]},
      {distributed_helper,add_node_to_mnesia_cluster,2,
                [{file,"/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
                 {line,44}]},
      {distributed_helper,add_node_to_cluster,2,
                [{file,"/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
                 {line,36}]},
      {local_iq_SUITE,init_per_suite,1,
              [{file,"/home/circleci/project/big_tests/tests/local_iq_SUITE.erl"},
               {line,29}]},
      {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1794}]},
      {test_server,run_test_case_eval1,6,
             [{file,"test_server.erl"},{line,1391}]},
      {test_server,run_test_case_eval,9,
             [{file,"test_server.erl"},{line,1235}]}]}}

Report log


pgsql_mnesia_27 / pgsql_mnesia / 5d2244a
Reports root/ big
OK: 5014 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


mysql_redis_27 / mysql_redis / 5d2244a
Reports root/ big
OK: 4993 / Failed: 0 / User-skipped: 140 / Auto-skipped: 0


pgsql_mnesia_26 / pgsql_mnesia / 5d2244a
Reports root/ big
OK: 5014 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


mssql_mnesia_27 / odbc_mssql_mnesia / 5d2244a
Reports root/ big
OK: 5011 / Failed: 0 / User-skipped: 122 / Auto-skipped: 0


internal_mnesia_27 / internal_mnesia / 5d2244a
Reports root/ big
OK: 2480 / Failed: 0 / User-skipped: 765 / Auto-skipped: 0

@gustawlippa gustawlippa merged commit 47731ed into master Aug 22, 2024
4 checks passed
@gustawlippa gustawlippa deleted the handle-privacy-iq-to-user branch August 22, 2024 13:57
@jacekwegr jacekwegr added this to the 6.3.0 milestone Oct 3, 2024
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.

3 participants