Content filter plugin

Hi,

I have written a simple packet interceptor plugin designed to scan and reject messages with disallowed content. The disallowed content are defined using regular expressions.

I was hoping to get some feedback in order to develop the idea a bit more and maybe some people would like to give it go.

Current function is

  1. scan packet and reject if there is a content match

Future functions could be

  1. inform sender that the message was not sent as content was disallowed

  2. add a switch to allow message but mask the disallowed content i.e. change content

  3. allow rooms to have content filters , this would be useful in public room environment

How can I this plugin on the forum for download?

sounds exciting I can do some testing, though i have some problems with new plugins now. They just dont work at all. Do i need to use latest nightly build? Or 2.1.5 version will do? It’'s just a working deployment so i dont want to broke it or somethng.

Matt can give you a permission to attach files and i think he’'ll eventually do this when read this thread. But you can send him a PM to insure that he knows

Conor,

You now have permission to post attachments in the forums.

Thanks,

Matt

Thanks Matt,

Attached is deployable plugin jar which works with Jive Messenger 2.1.5 out of the box.

There is a readme.html that describes the system properties you can use to configure the plugin which can be read when the plugin jar is expanded.

Briefly:

I have tested with “plugin.contentfilter.disallowedcontent” with value “fox,dog” and it rejects messages with subject or body containing the match, although more substantial reg exprs can be used

adding the option property “plugin.contentfilter.contentmask” with value “content removed” allows messages through but replaces any disllowedcontent matches with the mask.

Looking foward to you feedback.

Conor.
contentfilter.jar (5570 Bytes)

Alright. I will try it in a day or two.

How can I notify the sender of a message that a message was rejected in my PacketInteceptor implementation?

At the moment any rejected messages are silently swallowed by JM, so the sender has no way of knowing that the message was rejected. Ideally I would like the message to appear on the chat window e.g ** Message rejected

This is my current implemenation below , I would have expected the PacketRejectedException to show something on the users chat window. Perhaps I don’'t fully understand the various parameters of this interface.

/**

  • @see org.jivesoftware.messenger.interceptor.PacketInterceptor#interceptPacket(org.xm pp.packet.Packet,

  • org.jivesoftware.messenger.Session, boolean, boolean)

*/

public void interceptPacket(Packet packet, Session session, boolean read,

boolean processed) throws PacketRejectedException

{

if (!processed && packet instanceof Message)

{

Message msg = (Message) packet;

// filter the message

boolean contentMatched = contentFilter.filter(msg);

if (contentMatched && !contentFilter.isMaskingContent())

{

throw new PacketRejectedException(“Message rejected with disallowed content”);

}

}

}

Thanks,

Conor.

So i have tested it today a little, and it works

As about message for the sender. Well, it actually shows blank broadcast message window with possible receiver’'s JID in From field and with yellow error icon. Doesnt look pretty. Maybe it could “say” something like “Your message was rejected bla bla”. Or better, i can think of this warning message by myself. Of course some warning message exactly in chat window would be perfect.

You are planing to create GUI for this plugin, arent you? Would be more convinient to customize it.

Content mask works perfectly (and this bolding of mask is a good idea). Havent tested it fully though. Interesting, is it masking only full matches of entered values? And what if restricted word is a part of other word (ex: foxy). Maybe it should mask it as ***beep***y? Or it could ignore some separators between letters, such as spaces, “_” and so on. All this could be selectable and customizable via GUI. Ok, i’‘m asking too much. Well, i’‘m not really asking. Just thinking of capabilities. I’‘m not sure if we need such plugin at our deployment, but it’'s really interesting thing though