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

253 阅读1分钟

一、何为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());
        //自动分页插件
        interceptors.add(new PaginationInnerInterceptor());
        interceptor.setInterceptors(interceptors);
        return interceptor;
    }

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

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