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

OF-2189 blocklist fixes #1795

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

guusdk
Copy link
Member

@guusdk guusdk commented Jan 16, 2021

No description provided.

@akrherz
Copy link
Member

akrherz commented Apr 9, 2021

@guusdk , this PR is marked as draft state, is that still the case?

@guusdk
Copy link
Member Author

guusdk commented Apr 9, 2021

I don't recall adding a draft state to this :-/

Did I do that because the person reporting the issue reported a bunch of related issues in https://igniterealtime.atlassian.net/browse/OF-2189 ?

@mightymop
Copy link
Contributor

mightymop commented Apr 22, 2021

I don't recall adding a draft state to this :-/

Did I do that because the person reporting the issue reported a bunch of related issues in https://igniterealtime.atlassian.net/browse/OF-2189 ?

As i have written to the atlassian ticket theese things are still open:

  1. "from" attribute in message tag:
    • in one case it is missing
    • in another case it is equal with the "to" attribute
  2. error message: insert <blocked xmlns='urn:xmpp:blocking:errors'/>
    tag from xep-191, if possible
  3. MAM Plugin should not save/load messages from blocked users

things that have been fixed:

  • do not save/load offline messages if sender is blocked
  • do not send carbon copy if sender is blocked

@mightymop
Copy link
Contributor

mightymop commented Nov 16, 2021

When both PRs are merged the Issue should be fixed then...
BUT

I have cherry picked this PR and get this Exception:

2021.11.16 21:59:09 ERROR [Server SR - 1446833763]: org.jivesoftware.openfire.spi.RoutingTableImpl - Primary packet routing failed
java.lang.ClassCastException: class org.xmpp.packet.PacketExtension cannot be cast to class org.jivesoftware.openfire.carbons.Received (org.xmpp.packet.PacketExtension and org.jivesoftware.openfire.carbons.Received are in unnamed module of loader org.jivesoftware.openfire.starter.JiveClassLoader @75d2da2d)
        at org.jivesoftware.openfire.session.LocalClientSession.canProcess(LocalClientSession.java:988) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.session.LocalSession.process(LocalSession.java:405) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.spi.RoutingTableImpl.ccMessage(RoutingTableImpl.java:396) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.spi.RoutingTableImpl.routeToLocalDomain(RoutingTableImpl.java:344) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.spi.RoutingTableImpl.routePacket(RoutingTableImpl.java:262) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.MessageRouter.route(MessageRouter.java:134) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:79) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.SocketReader.processMessage(SocketReader.java:320) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.ServerSocketReader.access$001(ServerSocketReader.java:54) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.ServerSocketReader.processMessage(ServerSocketReader.java:115) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.SocketReader.process(SocketReader.java:175) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.BlockingReadingMode.readStream(BlockingReadingMode.java:188) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.BlockingReadingMode.run(BlockingReadingMode.java:81) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.SocketReader.run(SocketReader.java:150) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at java.lang.Thread.run(Thread.java:829) [?:?]

i could fix it with:

PacketExtension extension = packet.getExtension(Received.NAME, Received.NAMESPACE);
if (extension!=null)
{
    final Element received = extension.getElement().getName().equalsIgnoreCase("received")? extension.getElement() : null; 
    if (received != null) {
        final Element forwardedStanza = received.element("forwarded");
        if (forwardedStanza!=null)
        {
            Element elMessage = forwardedStanza.element("message");
            Element elIq = forwardedStanza.element("iq");
            Element elPres = forwardedStanza.element("presence");
            if (elMessage!=null)
            {
                Message message = new Message(elMessage, true);
                if (!canProcess(message)) {
                    return false;
                }
            }
            else
                if (elIq!=null)
                {
                    IQ iq = new IQ(elIq, true);
                    if (!canProcess(iq)) {
                        return false;
                    }
                }
                else
                    if (elPres !=null)
                    {
                        Presence p = new Presence(elPres, true);
                        if (!canProcess(p)) {
                            return false;
                        }
                    }
        }
    }
}

and

java.lang.NullPointerException: null
        at org.jivesoftware.openfire.OfflineMessageStore.addMessage(OfflineMessageStore.java:197) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.OfflineMessageStrategy.store(OfflineMessageStrategy.java:191) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.OfflineMessageStrategy.storeOffline(OfflineMessageStrategy.java:144) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.MessageRouter.routingFailed(MessageRouter.java:268) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.MessageRouter.route(MessageRouter.java:137) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.spi.PacketRouterImpl.route(PacketRouterImpl.java:79) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.StanzaHandler.processMessage(StanzaHandler.java:422) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.ClientStanzaHandler.processMessage(ClientStanzaHandler.java:109) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:246) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.net.StanzaHandler.process(StanzaHandler.java:209) ~[xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.jivesoftware.openfire.nio.ConnectionHandler.messageReceived(ConnectionHandler.java:183) [xmppserver-4.6.5-SNAPSHOT.jar:4.6.5-SNAPSHOT]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:1015) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1128) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:122) [mina-core-2.1.3.jar:?]
        at org.jivesoftware.openfire.plugin.RawPrintFilter.messageReceived(RawPrintFilter.java:111) [xmldebugger-1.7.5.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1128) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:122) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1128) [mina-core-2.1.3.jar:?]
        at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:413) [mina-core-2.1.3.jar:?]
        at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:257) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1128) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:106) [mina-core-2.1.3.jar:?]
        at org.apache.mina.core.session.IoEvent.run(IoEvent.java:89) [mina-core-2.1.3.jar:?]
        at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:766) [mina-core-2.1.3.jar:?]
        at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:758) [mina-core-2.1.3.jar:?]
        at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:697) [mina-core-2.1.3.jar:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]

... which i fixed by adding a null check for defaultPrivacyList...

final PrivacyList defaultPrivacyList = PrivacyListManager.getInstance().getDefaultPrivacyList(username);
if (defaultPrivacyList!=null&&defaultPrivacyList.shouldBlockPacket(message)) {
    Log.trace( "Not storing message, as it is rejected by the default privacy list of the recipient ({}).", recipient );
...

@mightymop
Copy link
Contributor

mightymop commented Dec 20, 2021

ping @guusdk

any news on this?

@Fishbowler
Copy link
Member

I assume the MUC Real-Time Block List Plugin, whilst being adjacent, doesn't make this work irrelevant?

Messages that arrive for offline users should not be stored in their offline message store, if the message would have been blocked if the intended recipient would have been online.
This prevents stanzas to bypass a privacy list or blocklist, when they're included in a carbon copy.
@guusdk
Copy link
Member Author

guusdk commented Jun 27, 2023

I assume the MUC Real-Time Block List Plugin, whilst being adjacent, doesn't make this work irrelevant?

I don't think that the two overlap, no.

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.

4 participants