From fd91b9929b78b2475a1a12eac3d7751e7a70416c Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 23 Mar 2022 04:47:13 +0100 Subject: [PATCH] [MIRROR] Log filters better, including the message [MDB IGNORE] (#12233) * Log filters better (#65539) * Log filters better, including the message Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- code/__HELPERS/_logging.dm | 3 +++ code/__HELPERS/chat_filter.dm | 6 +++++- code/_globalvars/logging.dm | 3 +++ code/game/world.dm | 1 + code/modules/client/verbs/ooc.dm | 1 + code/modules/mob/dead/observer/observer_say.dm | 1 + code/modules/mob/living/living_say.dm | 3 +++ 7 files changed, 17 insertions(+), 1 deletion(-) diff --git a/code/__HELPERS/_logging.dm b/code/__HELPERS/_logging.dm index a1a5201cd71..7837391af90 100644 --- a/code/__HELPERS/_logging.dm +++ b/code/__HELPERS/_logging.dm @@ -272,6 +272,9 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global")) if (CONFIG_GET(flag/log_job_debug)) WRITE_LOG(GLOB.world_job_debug_log, "JOB: [text]") +/proc/log_filter_raw(text) + WRITE_LOG(GLOB.filter_log, "FILTER: [text]") + /* Log to both DD and the logfile. */ /proc/log_world(text) #ifdef USE_CUSTOM_ERROR_HANDLER diff --git a/code/__HELPERS/chat_filter.dm b/code/__HELPERS/chat_filter.dm index cb3346ab42c..eff2be71c96 100644 --- a/code/__HELPERS/chat_filter.dm +++ b/code/__HELPERS/chat_filter.dm @@ -59,7 +59,7 @@ return null -///Given a text, will return that word is on the soft OOC filter, with the reason. +/// Given a text, will return that word is on the soft OOC filter, with the reason. /// Returns null if the message is OK. /proc/is_soft_ooc_filtered(message) if (config.soft_ooc_filter_regex?.Find(message)) @@ -68,4 +68,8 @@ return null +/// Logs to the filter log with the given message, match, and scope +/proc/log_filter(scope, message, filter_result) + log_filter_raw("[scope] filter:\n\tMessage: [message]\n\tFilter match: [filter_result[CHAT_FILTER_INDEX_WORD]]") + #undef GET_MATCHED_GROUP diff --git a/code/_globalvars/logging.dm b/code/_globalvars/logging.dm index 038235f8cdb..fc7368b6cda 100644 --- a/code/_globalvars/logging.dm +++ b/code/_globalvars/logging.dm @@ -56,6 +56,9 @@ GLOBAL_PROTECT(tgui_log) GLOBAL_VAR(world_shuttle_log) GLOBAL_PROTECT(world_shuttle_log) +GLOBAL_VAR(filter_log) +GLOBAL_PROTECT(filter_log) + GLOBAL_VAR(perf_log) GLOBAL_PROTECT(perf_log) diff --git a/code/game/world.dm b/code/game/world.dm index c4700094ed6..29ee64a1bb3 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -154,6 +154,7 @@ GLOBAL_VAR(restart_counter) GLOB.world_paper_log = "[GLOB.log_directory]/paper.log" GLOB.tgui_log = "[GLOB.log_directory]/tgui.log" GLOB.world_shuttle_log = "[GLOB.log_directory]/shuttle.log" + GLOB.filter_log = "[GLOB.log_directory]/filters.log" GLOB.demo_log = "[GLOB.log_directory]/demo.log" diff --git a/code/modules/client/verbs/ooc.dm b/code/modules/client/verbs/ooc.dm index a92fdf7bc39..411255b40b0 100644 --- a/code/modules/client/verbs/ooc.dm +++ b/code/modules/client/verbs/ooc.dm @@ -35,6 +35,7 @@ GLOBAL_VAR_INIT(normal_ooc_colour, "#002eb8") var/list/filter_result = is_ooc_filtered(msg) if (!CAN_BYPASS_FILTER(usr) && filter_result) REPORT_CHAT_FILTER_TO_USER(usr, filter_result) + log_filter("OOC", msg, filter_result) return // Protect filter bypassers from themselves. diff --git a/code/modules/mob/dead/observer/observer_say.dm b/code/modules/mob/dead/observer/observer_say.dm index 7f484db735b..44801a10999 100644 --- a/code/modules/mob/dead/observer/observer_say.dm +++ b/code/modules/mob/dead/observer/observer_say.dm @@ -15,6 +15,7 @@ var/list/filter_result = CAN_BYPASS_FILTER(src) ? null : is_ooc_filtered(message) if (filter_result) REPORT_CHAT_FILTER_TO_USER(usr, filter_result) + log_filter("OOC", message, filter_result) return var/list/soft_filter_result = CAN_BYPASS_FILTER(src) ? null : is_soft_ooc_filtered(message) diff --git a/code/modules/mob/living/living_say.dm b/code/modules/mob/living/living_say.dm index 457a30350d6..5ec91e53064 100644 --- a/code/modules/mob/living/living_say.dm +++ b/code/modules/mob/living/living_say.dm @@ -116,16 +116,19 @@ GLOBAL_LIST_INIT(message_modes_stat_limits, list( to_chat(src, span_warning("That message contained a word prohibited in IC chat! Consider reviewing the server rules.")) to_chat(src, span_warning("\"[message]\"")) REPORT_CHAT_FILTER_TO_USER(src, filter_result) + log_filter("IC", message, filter_result) SSblackbox.record_feedback("tally", "ic_blocked_words", 1, lowertext(config.ic_filter_regex.match)) return if(soft_filter_result && !filterproof) if(tgui_alert(usr,"Your message contains \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\". \"[soft_filter_result[CHAT_FILTER_INDEX_REASON]]\", Are you sure you want to say it?", "Soft Blocked Word", list("Yes", "No")) != "Yes") SSblackbox.record_feedback("tally", "soft_ic_blocked_words", 1, lowertext(config.soft_ic_filter_regex.match)) + log_filter("Soft IC", message, filter_result) return message_admins("[ADMIN_LOOKUPFLW(usr)] has passed the soft filter for \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\" they may be using a disallowed term. Message: \"[message]\"") log_admin_private("[key_name(usr)] has passed the soft filter for \"[soft_filter_result[CHAT_FILTER_INDEX_WORD]]\" they may be using a disallowed term. Message: \"[message]\"") SSblackbox.record_feedback("tally", "passed_soft_ic_blocked_words", 1, lowertext(config.soft_ic_filter_regex.match)) + log_filter("Soft IC (Passed)", message, filter_result) var/list/message_mods = list() var/original_message = message