FIRE-11815: Send newline flood antispam message only on initial block and only if source is not muted
parent
597eb2265d
commit
43b1e2f3e5
|
|
@ -88,6 +88,19 @@ U32 NACLAntiSpamQueue::getAmount()
|
|||
return mQueueAmount;
|
||||
}
|
||||
|
||||
NACLAntiSpamQueueEntry* NACLAntiSpamQueue::getEntry(const LLUUID& source)
|
||||
{
|
||||
spam_queue_entry_map_t::iterator found = mEntries.find(source);
|
||||
if (found != mEntries.end())
|
||||
{
|
||||
return found->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void NACLAntiSpamQueue::clearEntries()
|
||||
{
|
||||
for (spam_queue_entry_map_t::iterator it = mEntries.begin(); it != mEntries.end(); ++it)
|
||||
|
|
@ -388,6 +401,40 @@ bool NACLAntiSpamRegistry::checkQueue(EAntispamQueue queue, const LLUUID& source
|
|||
return false;
|
||||
}
|
||||
|
||||
bool NACLAntiSpamRegistry::isBlockedOnQueue(EAntispamQueue queue, const LLUUID& source)
|
||||
{
|
||||
// skip all checks if we're we've been administratively turned off
|
||||
static LLCachedControl<bool> useAntiSpam(gSavedSettings, "UseAntiSpam");
|
||||
if (!useAntiSpam)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mGlobalQueue)
|
||||
{
|
||||
spam_queue_entry_map_t::iterator found = mGlobalEntries.find(source);
|
||||
if (found != mGlobalEntries.end())
|
||||
{
|
||||
return (found->second->getBlocked());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (queue >= ANTISPAM_QUEUE_MAX || mQueues[queue] == NULL)
|
||||
{
|
||||
LL_ERRS("AntiSpam") << "CODE BUG: Attempting to use a antispam queue that was not created or was outside of the reasonable range of queues. Queue: " << getQueueName(queue) << llendl;
|
||||
return false;
|
||||
}
|
||||
|
||||
NACLAntiSpamQueueEntry* entry = mQueues[queue]->getEntry(source);
|
||||
return (entry && entry->getBlocked());
|
||||
}
|
||||
}
|
||||
|
||||
// Global queue
|
||||
void NACLAntiSpamRegistry::setGlobalQueue(bool value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ protected:
|
|||
|
||||
void blockEntry(const LLUUID& source);
|
||||
S32 checkEntry(const LLUUID& source, U32 multiplier);
|
||||
NACLAntiSpamQueueEntry* getEntry(const LLUUID& source);
|
||||
|
||||
void clearEntries();
|
||||
void purgeEntries();
|
||||
|
|
@ -87,6 +88,7 @@ public:
|
|||
|
||||
void blockOnQueue(EAntispamQueue queue, const LLUUID& source);
|
||||
bool checkQueue(EAntispamQueue queue, const LLUUID& source, U32 multiplier = 1, bool silent = false);
|
||||
bool isBlockedOnQueue(EAntispamQueue queue, const LLUUID& source);
|
||||
|
||||
void clearRegisteredQueue(EAntispamQueue queue);
|
||||
void purgeRegisteredQueue(EAntispamQueue queue);
|
||||
|
|
|
|||
|
|
@ -2646,47 +2646,13 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
|
|||
//msg->getData("MessageBlock", "Count", &count);
|
||||
msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, name);
|
||||
msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, message);
|
||||
|
||||
// NaCl - Newline flood protection
|
||||
static LLCachedControl<bool> useAntiSpam(gSavedSettings, "UseAntiSpam");
|
||||
if (useAntiSpam)
|
||||
{
|
||||
bool doCheck = true;
|
||||
if (from_id.isNull() || gAgentID == from_id)
|
||||
{
|
||||
doCheck = false;
|
||||
}
|
||||
if (doCheck)
|
||||
{
|
||||
LLViewerObject* obj = gObjectList.findObject(from_id);
|
||||
if (obj && obj->permYouOwner())
|
||||
{
|
||||
doCheck = false;
|
||||
}
|
||||
}
|
||||
if (doCheck)
|
||||
{
|
||||
static LLCachedControl<U32> _NACL_AntiSpamNewlines(gSavedSettings, "_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES);
|
||||
if ((std::abs(std::distance(iter, boost::sregex_iterator())) > _NACL_AntiSpamNewlines))
|
||||
{
|
||||
NACLAntiSpamRegistry::instance().blockOnQueue(ANTISPAM_QUEUE_IM, from_id);
|
||||
LLSD args;
|
||||
llinfos << "[antispam] blocked owner due to too many newlines: " << from_id << llendl;
|
||||
args["MESSAGE"] = llformat("AntiSpam: Blocked %s for sending message with %ud lines.", from_id.asString().c_str(), (U32)_NACL_AntiSpamNewlines);
|
||||
LLNotificationsUtil::add("SystemMessageTip", args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
msg->getU32Fast(_PREHASH_MessageBlock, _PREHASH_ParentEstateID, parent_estate_id);
|
||||
msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_RegionID, region_id);
|
||||
msg->getVector3Fast(_PREHASH_MessageBlock, _PREHASH_Position, position);
|
||||
msg->getBinaryDataFast( _PREHASH_MessageBlock, _PREHASH_BinaryBucket, binary_bucket, 0, 0, MTUBYTES);
|
||||
binary_bucket_size = msg->getSizeFast(_PREHASH_MessageBlock, _PREHASH_BinaryBucket);
|
||||
EInstantMessage dialog = (EInstantMessage)d;
|
||||
|
||||
// NaCl - Antispam Registry
|
||||
if (dialog != IM_TYPING_START && dialog != IM_TYPING_STOP)
|
||||
{
|
||||
|
|
@ -2729,6 +2695,52 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
|
|||
BOOL is_afk = gAgent.getAFK();
|
||||
// </FS:PP>
|
||||
|
||||
// NaCl - Newline flood protection
|
||||
static LLCachedControl<bool> useAntiSpam(gSavedSettings, "UseAntiSpam");
|
||||
if (useAntiSpam)
|
||||
{
|
||||
bool doCheck = true;
|
||||
if (from_id.isNull() || gAgentID == from_id)
|
||||
{
|
||||
doCheck = false;
|
||||
}
|
||||
if (doCheck)
|
||||
{
|
||||
LLViewerObject* obj = gObjectList.findObject(from_id);
|
||||
if (obj && obj->permYouOwner())
|
||||
{
|
||||
doCheck = false;
|
||||
}
|
||||
}
|
||||
if (doCheck)
|
||||
{
|
||||
if (!NACLAntiSpamRegistry::instance().isBlockedOnQueue(ANTISPAM_QUEUE_IM, from_id))
|
||||
{
|
||||
static LLCachedControl<U32> _NACL_AntiSpamNewlines(gSavedSettings, "_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES);
|
||||
if ((std::abs(std::distance(iter, boost::sregex_iterator())) > _NACL_AntiSpamNewlines))
|
||||
{
|
||||
NACLAntiSpamRegistry::instance().blockOnQueue(ANTISPAM_QUEUE_IM, from_id);
|
||||
if (!is_muted)
|
||||
{
|
||||
LLSD args;
|
||||
LL_INFOS("AntiSpam") << "[antispam] blocked owner due to too many newlines: " << from_id << LL_ENDL;
|
||||
args["SOURCE"] = from_id.asString();
|
||||
args["COUNT"] = llformat("%u", _NACL_AntiSpamNewlines());
|
||||
LLNotificationsUtil::add("AntiSpamImNewLineFloodBlocked", args);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
|
||||
chat.mMuted = is_muted;
|
||||
chat.mFromID = from_id;
|
||||
chat.mFromName = name;
|
||||
|
|
@ -4346,14 +4358,25 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
|
|||
}
|
||||
if (doCheck)
|
||||
{
|
||||
static LLCachedControl<U32> _NACL_AntiSpamNewlines(gSavedSettings, "_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES);
|
||||
if (std::abs(std::distance(iter, boost::sregex_iterator())) > _NACL_AntiSpamNewlines)
|
||||
if (!NACLAntiSpamRegistry::instance().isBlockedOnQueue(ANTISPAM_QUEUE_CHAT, owner_id))
|
||||
{
|
||||
static LLCachedControl<U32> _NACL_AntiSpamNewlines(gSavedSettings, "_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES);
|
||||
if (std::abs(std::distance(iter, boost::sregex_iterator())) > _NACL_AntiSpamNewlines)
|
||||
{
|
||||
NACLAntiSpamRegistry::instance().blockOnQueue(ANTISPAM_QUEUE_CHAT, owner_id);
|
||||
if (!is_muted)
|
||||
{
|
||||
LLSD args;
|
||||
args["SOURCE"] = owner_id.asString();
|
||||
args["COUNT"] = llformat("%u", _NACL_AntiSpamNewlines());
|
||||
LLNotificationsUtil::add("AntiSpamChatNewLineFloodBlocked", args);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NACLAntiSpamRegistry::instance().blockOnQueue(ANTISPAM_QUEUE_CHAT, owner_id);
|
||||
LLSD args;
|
||||
args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString();
|
||||
LLNotificationsUtil::add("SystemMessageTip", args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11557,6 +11557,22 @@ Export failed unexpectedly. Please see the log for details.
|
|||
AntiSpam: Blocked [SOURCE] for spamming a [QUEUE] ([COUNT]) times in [PERIOD] seconds.
|
||||
</notification>
|
||||
|
||||
<notification
|
||||
icon="notifytip.tga"
|
||||
name="AntiSpamImNewLineFloodBlocked"
|
||||
log_to_chat="false"
|
||||
type="notifytip">
|
||||
AntiSpam: Blocked [SOURCE] for sending an instant message with more than [COUNT] lines.
|
||||
</notification>
|
||||
|
||||
<notification
|
||||
icon="notifytip.tga"
|
||||
name="AntiSpamChatNewLineFloodBlocked"
|
||||
log_to_chat="false"
|
||||
type="notifytip">
|
||||
AntiSpam: Blocked [SOURCE] for sending a chat message with more than [COUNT] lines.
|
||||
</notification>
|
||||
|
||||
<notification
|
||||
icon="alertmodal.tga"
|
||||
name="MeshMaxConcurrentReqTooHigh"
|
||||
|
|
|
|||
Loading…
Reference in New Issue