MP 的攻击 SQL 阻断解析器(V3.4.0)

2021/10/18 19:10:20

本文主要是介绍MP 的攻击 SQL 阻断解析器(V3.4.0),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、何为SQL阻断器

官网给出的一句话

阻止恶意的全表更新删除

官网地址
已经总结的很到位了

二、具体是如何实现的

也很简单,通过MP(Mybatis-Plus)的拦截器来实现,官方更新的很勤快

image

可以看到 10-8的官方示例代码 而今天仅仅过了10天就

image

不过插件主题也是10-8更新的还标了必看,不知道图什么

插件主体

三、编码

官方更新了新的使用方式
image

并且也强调了已有的插件以及使用方式
image

那就 复制站贴吧

/**
     * 新的分页插件,一缓和二缓遵循mybatis的规则,
     * 需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        List<InnerInterceptor> interceptors = new ArrayList<>();
		//如果想用其他的插件 添加到集合中就行
        interceptors.add(new BlockAttackInnerInterceptor());
        interceptor.setInterceptors(interceptors);
        return interceptor;
    }

效果其实挺一般,它也只是看看你做更新和删除时有没有Where条件,感觉 其实 用处不大,但总比没有强
image

不过照这个更新速度 指不定哪天又更加智能了



这篇关于MP 的攻击 SQL 阻断解析器(V3.4.0)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程