Closed github-actions[bot] closed 3 years ago
Improve this check
https://github.com/OpticFusion1/MCAntiMalware/blob/be3e0c94425d79225d811c33cdf806625f45a7d1/MCAntiMalware-Core/src/main/java/optic_fusion1/antimalware/servers/transformers/ChatEventTransformer.java#L18
package optic_fusion1.antimalware.servers.transformers; import java.lang.reflect.InvocationTargetException; import optic_fusion1.antimalware.AntiMalware; import static optic_fusion1.antimalware.AntiMalware.LOGGER; import optic_fusion1.antimalware.check.CacheContainer; import optic_fusion1.antimalware.exceptions.FormattedSecurityException; import optic_fusion1.antimalware.servers.runtimeprotect.callerinfo.CallerInfo; import optic_fusion1.antimalware.servers.runtimeprotect.callerinfo.RuntimeUtils; import static optic_fusion1.antimalware.utils.I18n.tl; public abstract class ChatEventTransformer { static void handle(Object object) { try { String message = (String) object.getClass().getMethod("getMessage").invoke(object); String player = getPlayerName(object); // TODO: Improve this check CacheContainer cache = AntiMalware.getInstance().getCache(); if (cache.containsBlacklistedCommand(message) || cache.containsBlacklistedString(message) || cache.containsBlacklistedString(message.split(" ")[0]) || cache.containsBlacklistedCommand(message.split(" ")[0])) { CallerInfo callerInfo = RuntimeUtils.getCallerInfo(); if (callerInfo != null) { throw new FormattedSecurityException(tl("transformer_blacklisted_word", callerInfo.getPlugin().getJar(), player, message)); } throw new FormattedSecurityException(tl("transformer_blacklisted_word_no_file", getPlayerName(object), message)); } LOGGER.info(player + " said " + message + " (Cancelled Event)"); } catch (IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) { e.printStackTrace(); } } private static String getPlayerName(Object object) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { Object player = object.getClass().getMethod("getPlayer").invoke(object); return (String) player.getClass().getMethod("getDisplayName").invoke(player); } }
8b831e2bd134920577dd601b871587385fa6818f
Closed in e6f0849bc799dfeff816fea1c304739273f1a983
Improve this check
https://github.com/OpticFusion1/MCAntiMalware/blob/be3e0c94425d79225d811c33cdf806625f45a7d1/MCAntiMalware-Core/src/main/java/optic_fusion1/antimalware/servers/transformers/ChatEventTransformer.java#L18
8b831e2bd134920577dd601b871587385fa6818f