diff --git a/luoo_comment/pom.xml b/luoo_comment/pom.xml index 7fdf314..ecfd55c 100644 --- a/luoo_comment/pom.xml +++ b/luoo_comment/pom.xml @@ -128,7 +128,10 @@ http://116.62.145.60:2375 + + + \ No newline at end of file diff --git a/luoo_comment/src/main/java/com/luoo/comment/config/SpringSensitiveWordConfig.java b/luoo_comment/src/main/java/com/luoo/comment/config/SpringSensitiveWordConfig.java index ef7cd29..1932282 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/config/SpringSensitiveWordConfig.java +++ b/luoo_comment/src/main/java/com/luoo/comment/config/SpringSensitiveWordConfig.java @@ -2,8 +2,8 @@ package com.luoo.comment.config; import com.github.houbb.sensitive.word.bs.SensitiveWordBs; import com.github.houbb.sensitive.word.support.allow.WordAllows; import com.github.houbb.sensitive.word.support.deny.WordDenys; -import com.luoo.comment.sensitiveWord.MyDdWordAllow; -import com.luoo.comment.sensitiveWord.MyDdWordDeny; +import com.luoo.comment.sensitiveword.MyDdWordAllow; +import com.luoo.comment.sensitiveword.MyDdWordDeny; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordAllow.java b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordAllow.java new file mode 100644 index 0000000..135f170 --- /dev/null +++ b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordAllow.java @@ -0,0 +1,21 @@ +package com.luoo.comment.sensitiveword; + +import com.github.houbb.sensitive.word.api.IWordAllow; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component +public class MyDdWordAllow implements IWordAllow { + + @Override + public List allow() { + List list = new ArrayList<>(); + list.add("五星红旗"); + list.add("天安门"); + + return list; + } + +} diff --git a/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordDeny.java b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordDeny.java new file mode 100644 index 0000000..82b28b1 --- /dev/null +++ b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/MyDdWordDeny.java @@ -0,0 +1,25 @@ +package com.luoo.comment.sensitiveword; + +import com.github.houbb.sensitive.word.api.IWordDeny; +import constants.SensitiveWords; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component +public class MyDdWordDeny implements IWordDeny { + String DENY_WORDS= SensitiveWords.DENY_WORDS; + @Override + public List deny() { + List list = new ArrayList<>(); +// list.add("落网"); + + String[] s = DENY_WORDS.split("\n"); + for(String denyWord:s) { + list.add(denyWord); + } + + return list; + } +} \ No newline at end of file diff --git a/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/SensitiveWordService.java b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/SensitiveWordService.java new file mode 100644 index 0000000..c75aca4 --- /dev/null +++ b/luoo_comment/src/main/java/com/luoo/comment/sensitiveword/SensitiveWordService.java @@ -0,0 +1,23 @@ +package com.luoo.comment.sensitiveword; + +import com.github.houbb.sensitive.word.bs.SensitiveWordBs; +import org.springframework.beans.factory.annotation.Autowired; + +public class SensitiveWordService { + + @Autowired + private SensitiveWordBs sensitiveWordBs; + + /** + * 更新词库 + *

+ * 每次数据库的信息发生变化之后,首先调用更新数据库敏感词库的方法。 + * 如果需要生效,则调用这个方法。 + *

+ * 说明:重新初始化不影响旧的方法使用。初始化完成后,会以新的为准。 + */ + public void refresh() { + // 每次数据库的信息发生变化之后,首先调用更新数据库敏感词库的方法,然后调用这个方法。 + sensitiveWordBs.init(); + } +} \ No newline at end of file diff --git a/luoo_common/src/main/java/constants/SensitiveWords.java b/luoo_common/src/main/java/constants/SensitiveWords.java new file mode 100644 index 0000000..6b78365 --- /dev/null +++ b/luoo_common/src/main/java/constants/SensitiveWords.java @@ -0,0 +1,304 @@ +package constants; + +public class SensitiveWords { + + public static String DENY_WORDS="爱液\n" + + "暴奸\n" + + "屄\n" + + "被操\n" + + "被插\n" + + "操逼\n" + + "操烂\n" + + "肏你\n" + + "肏死\n" + + "操我\n" + + "插比\n" + + "插b\n" + + "插逼\n" + + "潮吹\n" + + "潮喷\n" + + "吃精\n" + + "抽插\n" + + "荡妇\n" + + "荡女\n" + + "多人轮\n" + + "肥逼\n" + + "粉穴\n" + + "肛交\n" + + "肛门\n" + + "龟头\n" + + "国产av\n" + + "黑逼\n" + + "换妻俱乐部\n" + + "鸡巴\n" + + "妓女\n" + + "开苞\n" + + "口爆\n" + + "口交\n" + + "口射\n" + + "浪逼\n" + + "浪妇\n" + + "露b\n" + + "乱交\n" + + "乱伦\n" + + "轮暴\n" + + "轮操\n" + + "轮奸\n" + + "裸陪\n" + + "美逼\n" + + "美穴\n" + + "美幼\n" + + "迷奸\n" + + "密穴\n" + + "蜜穴\n" + + "蜜液\n" + + "男奴\n" + + "内射\n" + + "嫩逼\n" + + "嫩女\n" + + "嫩穴\n" + + "捏弄\n" + + "喷精\n" + + "屁眼\n" + + "强奸处女\n" + + "拳交\n" + + "群交\n" + + "人兽\n" + + "日逼\n" + + "日烂\n" + + "肉棒\n" + + "肉逼\n" + + "肉唇\n" + + "肉洞\n" + + "肉缝\n" + + "肉穴\n" + + "乳交\n" + + "骚逼\n" + + "骚比\n" + + "骚女\n" + + "骚水\n" + + "骚穴\n" + + "兽交\n" + + "舔阴\n" + + "小穴\n" + + "小xue\n" + + "穴口\n" + + "穴图\n" + + "颜射\n" + + "幼交\n" + + "幼女\n" + + "玉穴\n" + + "操你妈\n" + + "擦你妈\n" + + "操你娘\n" + + "日你妈\n" + + "干你妈\n" + + "干你娘\n" + + "妈逼\n" + + "乱伦\n" + + "妹按摩\n" + + "妹上门\n" + + "迷幻药\n" + + "迷幻藥\n" + + "迷昏口\n" + + "迷昏药\n" + + "迷昏藥\n" + + "迷魂药\n" + + "迷魂藥\n" + + "迷奸粉\n" + + "迷奸药\n" + + "迷情粉\n" + + "迷情水\n" + + "迷情药\n" + + "谜奸药\n" + + "骚妇\n" + + "骚货\n" + + "骚女\n" + + "色情服务\n" + + "色情图片\n" + + "色情小说\n" + + "色情影片\n" + + "色情表演\n" + + "色情电影\n" + + "色情服务\n" + + "色情片\n" + + "色视频\n" + + "色小说\n" + + "性服务\n" + + "性交\n" + + "性交视频\n" + + "性交图片\n" + + "性奴\n" + + "性奴集中营\n" + + "性虐\n" + + "淫水\n" + + "淫穴\n" + + "morphine\n" + + "摇头丸\n" + + "迷药\n" + + "乖乖粉\n" + + "narcotic\n" + + "麻醉药\n" + + "安眠酮\n" + + "代药物毒品类:血浆\n" + + "普萘洛尔\n" + + "呋塞米\n" + + "西布曲明\n" + + "testosterone\n" + + "胰岛素样生长因子\n" + + "促红细胞生成素\n" + + "地西泮\n" + + "尼可刹米\n" + + "甲睾酮\n" + + "adrenaline\n" + + "erythropoietin\n" + + "地奈德\n" + + "莫达非尼\n" + + "氯噻嗪\n" + + "苯巴比妥\n" + + "促性腺激素\n" + + "泼尼松\n" + + "麻黄草\n" + + "雄烯二醇\n" + + "地塞米松\n" + + "tamoxifen\n" + + "strychnine\n" + + "androst\n" + + "新型毒品\n" + + "杜冷丁\n" + + "mdma\n" + + "海洛因\n" + + "海luo因\n" + + "heroin\n" + + "diamorphine\n" + + "diacetylmorphine\n" + + "cocain\n" + + "三唑仑\n" + + "美沙酮\n" + + "麻古\n" + + "k粉\n" + + "凯他敏\n" + + "ketamine\n" + + "冰毒\n" + + "苯丙胺\n" + + "cannabis\n" + + "大麻\n" + + "爱他死\n" + + "氯胺酮\n" + + "benzodiazepines\n" + + "甲基安非他明\n" + + "安非他命\n" + + "吗啡\n" + + "morphine\n" + + "摇头丸\n" + + "迷药\n" + + "乖乖粉\n" + + "narcotic\n" + + "麻醉药\n" + + "专业代理\n" + + "信用卡提现\n" + + "无抵押贷款\n" + + "广告代理\n" + + "代开发票\n" + + "销售热线\n" + + "免费订购热线\n" + + "婴儿汤\n" + + "中国复兴党\n" + + "阿波罗网\n" + + "六合彩\n" + + "大麻树脂\n" + + "大麻油\n" + + "dpp大法\n" + + "fa lun\n" + + "falu\n" + + "发抡\n" + + "发抡功\n" + + "下法轮\n" + + "发轮\n" + + "发伦\n" + + "发伦功\n" + + "发仑\n" + + "发沦\n" + + "发纶\n" + + "发论\n" + + "发论功\n" + + "发论公\n" + + "发正念\n" + + "法 轮 功\n" + + "法*功\n" + + "法.轮.功\n" + + "法L功\n" + + "法lun功\n" + + "法轮\n" + + "法轮大法\n" + + "法轮佛法\n" + + "法轮功\n" + + "法十轮十功\n" + + "珐.輪功\n" + + "falun\n" + + "Falundafa\n" + + "fa轮\n" + + "梦网洪志\n" + + "达赖喇嘛\n" + + "哒赖\n" + + "李洪志\n" + + "志洪李\n" + + "质押贷款\n" + + "小额贷款\n" + + "64事件\n" + + "天安门事件\n" + + "代开发票\n" + + "代理发票\n" + + "代理票据\n" + + "代追债\n" + + "短信广告\n" + + "短信群发\n" + + "短信群发器\n" + + "VPN\n" + + "为党不为国\n" + + "西藏,独立\n" + + "西藏独立\n" + + "西藏国家民主党\n" + + "西藏人民大起义\n" + + "藏独\n" + + "疆独\n" + + "香港彩\n" + + "香港独立\n" + + "香港马会\n" + + "香港一类\n" + + "香港总彩\n" + + "小姐按摩\n" + + "小姐上门\n" + + "新疆暴乱\n" + + "新疆独立\n" + + "信用卡套现\n" + + "性息网\n" + + "一党独裁\n" + + "一党私利\n" + + "一党执政\n" + + "一党专政\n" + + "幼齿\n" + + "幼幼\n" + + "真钱,百家乐\n" + + "真钱斗地\n" + + "真钱投注\n" + + "真善忍\n" + + "证到付款\n" + + "证件公司\n" + + "证件集团\n" + + "证生成器\n" + + "证书办\n" + + "支那\n" + + "支那猪\n" + + "植物冰\n" + + "自杀手册\n" + + "自杀指南\n" + + "自由西藏\n" + + "自由西藏学生运动\n" + + "自由新疆\n" + + "自由新疆学生运动\n" + + "博彩\n" + + "藏独立\n" + + "中共独裁\n" + + "中共邪教\n"; +} diff --git a/luoo_user/pom.xml b/luoo_user/pom.xml index 538981b..08991bd 100644 --- a/luoo_user/pom.xml +++ b/luoo_user/pom.xml @@ -105,6 +105,11 @@ ip2region 2.7.0 + + com.github.houbb + sensitive-word + 0.2.0 + app diff --git a/luoo_user/src/main/java/com/luoo/user/config/SpringSensitiveWordConfig.java b/luoo_user/src/main/java/com/luoo/user/config/SpringSensitiveWordConfig.java new file mode 100644 index 0000000..5260ecf --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/config/SpringSensitiveWordConfig.java @@ -0,0 +1,37 @@ +package com.luoo.user.config; +import com.github.houbb.sensitive.word.bs.SensitiveWordBs; +import com.github.houbb.sensitive.word.support.allow.WordAllows; +import com.github.houbb.sensitive.word.support.deny.WordDenys; +import com.luoo.user.sensitiveword.MyDdWordAllow; +import com.luoo.user.sensitiveword.MyDdWordDeny; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +public class SpringSensitiveWordConfig { + + + @Autowired + private MyDdWordAllow myDdWordAllow; + + @Autowired + private MyDdWordDeny myDdWordDeny; + /** + * 初始化引导类 + * @return 初始化引导类 + * @since 1.0.0 + */ + @Bean + public SensitiveWordBs sensitiveWordBs() { + SensitiveWordBs init = SensitiveWordBs.newInstance() + .wordAllow(WordAllows.chains(WordAllows.system(), myDdWordAllow)) + .wordDeny(WordDenys.chains( myDdWordDeny)) + .ignoreRepeat(false) + // 各种其他配置 + .init(); + + return init; + } +} \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/sensitiveword/MyDdWordAllow.java b/luoo_user/src/main/java/com/luoo/user/sensitiveword/MyDdWordAllow.java new file mode 100644 index 0000000..edaff5f --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/sensitiveword/MyDdWordAllow.java @@ -0,0 +1,21 @@ +package com.luoo.user.sensitiveword; + +import com.github.houbb.sensitive.word.api.IWordAllow; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component +public class MyDdWordAllow implements IWordAllow { + + @Override + public List allow() { + List list = new ArrayList<>(); + list.add("五星红旗"); + list.add("天安门"); + + return list; + } + +} diff --git a/luoo_user/src/main/java/com/luoo/user/sensitiveword/MyDdWordDeny.java b/luoo_user/src/main/java/com/luoo/user/sensitiveword/MyDdWordDeny.java new file mode 100644 index 0000000..78b4482 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/sensitiveword/MyDdWordDeny.java @@ -0,0 +1,25 @@ +package com.luoo.user.sensitiveword; + +import com.github.houbb.sensitive.word.api.IWordDeny; +import constants.SensitiveWords; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Component +public class MyDdWordDeny implements IWordDeny { + String DENY_WORDS= SensitiveWords.DENY_WORDS; + @Override + public List deny() { + List list = new ArrayList<>(); +// list.add("落网"); + + String[] s = DENY_WORDS.split("\n"); + for(String denyWord:s) { + list.add(denyWord); + } + + return list; + } +} \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/sensitiveword/SensitiveWordService.java b/luoo_user/src/main/java/com/luoo/user/sensitiveword/SensitiveWordService.java new file mode 100644 index 0000000..6030f51 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/sensitiveword/SensitiveWordService.java @@ -0,0 +1,23 @@ +package com.luoo.user.sensitiveword; + +import com.github.houbb.sensitive.word.bs.SensitiveWordBs; +import org.springframework.beans.factory.annotation.Autowired; + +public class SensitiveWordService { + + @Autowired + private SensitiveWordBs sensitiveWordBs; + + /** + * 更新词库 + *

+ * 每次数据库的信息发生变化之后,首先调用更新数据库敏感词库的方法。 + * 如果需要生效,则调用这个方法。 + *

+ * 说明:重新初始化不影响旧的方法使用。初始化完成后,会以新的为准。 + */ + public void refresh() { + // 每次数据库的信息发生变化之后,首先调用更新数据库敏感词库的方法,然后调用这个方法。 + sensitiveWordBs.init(); + } +} \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/util/MySensitiveWordReplaceUtils.java b/luoo_user/src/main/java/com/luoo/user/util/MySensitiveWordReplaceUtils.java new file mode 100644 index 0000000..39bab66 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/util/MySensitiveWordReplaceUtils.java @@ -0,0 +1,29 @@ +package com.luoo.user.util; + +import com.github.houbb.heaven.util.lang.CharUtil; +import com.github.houbb.sensitive.word.api.ISensitiveWordReplace; +import com.github.houbb.sensitive.word.api.ISensitiveWordReplaceContext; +import org.springframework.stereotype.Component; + +@Component +public class MySensitiveWordReplaceUtils implements ISensitiveWordReplace { + + @Override + public String replace(ISensitiveWordReplaceContext context) { + String sensitiveWord = context.sensitiveWord(); + + // 自定义不同的敏感词替换策略,可以从数据库等地方读取 + if("五星红旗".equals(sensitiveWord)) { + return "国家旗帜"; + } + if("毛主席".equals(sensitiveWord)) { + return "教员"; + } + + // 其他默认使用 * 代替 + int wordLength = context.wordLength(); + return CharUtil.repeat('*', wordLength); + } + +} +