首页 > 数据库 >Mysql:canal-deployer:如何阻断canal-client对deployer上的filter过滤条件订阅修改:https://github.com/alibaba/canal/blob

Mysql:canal-deployer:如何阻断canal-client对deployer上的filter过滤条件订阅修改:https://github.com/alibaba/canal/blob

时间:2024-04-24 11:44:23浏览次数:14  
标签:canal filter java destination clientId return protocol public

 

也算是安全管理上的一个控制点:

本来,允许客户端去根据自己的实际需求去服务端订阅自己关心的数据流,是很好的。

but,但是,服务端的黑白名单过滤,尤其是白名单的filter条件会被客户端的最新订阅的过滤条件给覆盖!!!

这算是bug吗? 上游服务端怎么显得那么没地位呢!!!???

 

#==========================================================================================

另外,还有一个问题:canal的服务端depoyer 和客户端client(使用客户端库自己开发的、或者是adapter匹配的等等)

通常会由同一个安全域内的组织去部署,如此,除了业务层面的便利,数据安全上确漏洞百出!

 

#==========================================================================================

 基于以上原因: 分开安全域去部署服务端deployer和客户端client;并且阻断客户端的订阅中的过滤条件覆盖功能,以加固deployer的数据安全性。 经过代码分析,我们只要简单的修改: ./protocol/src/main/java/com/alibaba/otter/canal/protocol/ClientIdentity.java 屏蔽其中的filter参数设置。以1.1.7源代码为例,如下:  
  1 package com.alibaba.otter.canal.protocol;
  2 
  3 import java.io.Serializable;
  4 
  5 import org.apache.commons.lang.StringUtils;
  6 import org.apache.commons.lang.builder.ToStringBuilder;
  7 
  8 import com.alibaba.otter.canal.common.utils.CanalToStringStyle;
  9 
 10 /**
 11  * @author zebin.xuzb @ 2012-6-20
 12  * @version 1.0.0
 13  */
 14 public class ClientIdentity implements Serializable {
 15 
 16     private static final long serialVersionUID = -8262100681930834834L;
 17     private String            destination;
 18     private short             clientId;
 19     private String            filter;
 20 
 21     public ClientIdentity(){
 22 
 23     }
 24 
 25     public ClientIdentity(String destination, short clientId){
 26         this.clientId = clientId;
 27         this.destination = destination;
 28     }
 29 
 30     public ClientIdentity(String destination, short clientId, String filter){
 31         this.clientId = clientId;
 32         this.destination = destination;
 33         this.filter = "";
 34     }
 35 
 36     public Boolean hasFilter() {
 37         if (filter == null) {
 38             return false;
 39         }
 40         return StringUtils.isNotBlank(filter);
 41     }
 42 
 43     // ======== setter =========
 44 
 45     public String getDestination() {
 46         return destination;
 47     }
 48 
 49     public short getClientId() {
 50         return clientId;
 51     }
 52 
 53     public void setClientId(short clientId) {
 54         this.clientId = clientId;
 55     }
 56 
 57     public void setDestination(String destination) {
 58         this.destination = destination;
 59     }
 60 
 61     public String getFilter() {
 62         return filter;
 63     }
 64 
 65     public void setFilter(String filter) {
 66         this.filter = "";
 67     }
 68 
 69     public String toString() {
 70         return ToStringBuilder.reflectionToString(this, CanalToStringStyle.DEFAULT_STYLE);
 71     }
 72 
 73     public int hashCode() {
 74         final int prime = 31;
 75         int result = 1;
 76         result = prime * result + clientId;
 77         result = prime * result + ((destination == null) ? 0 : destination.hashCode());
 78         return result;
 79     }
 80 
 81     public boolean equals(Object obj) {
 82         if (this == obj) {
 83             return true;
 84         }
 85         if (obj == null) {
 86             return false;
 87         }
 88         if (!(obj instanceof ClientIdentity)) {
 89             return false;
 90         }
 91         ClientIdentity other = (ClientIdentity) obj;
 92         if (clientId != other.clientId) {
 93             return false;
 94         }
 95         if (destination == null) {
 96             if (other.destination != null) {
 97                 return false;
 98             }
 99         } else if (!destination.equals(other.destination)) {
100             return false;
101         }
102         return true;
103     }
104 
105 }

 

附件:源代码   class文件

 

 

 

   

标签:canal,filter,java,destination,clientId,return,protocol,public
From: https://www.cnblogs.com/jinzhenshui/p/18154720

相关文章

  • java线程池
    java线程池 一、线程池的7个核心参数 1.corePoolSize 核心线程数 corePoolSize是线程池中保持活动状态的最小线程数。即使线程是空闲的,它们也会一直保持在池中。当有新任务提交时,线程池会优先创建核心线程来处理任务。 2.maximumPoolSize 最大线程数 maximu......
  • 「Java开发指南」如何利用MyEclipse启用Spring DSL?(二)
    本教程将引导您通过启用SpringDSL和使用ServiceSpringDSL抽象来引导Spring和Spring代码生成项目,本教程中学习的技能也可以很容易地应用于其他抽象。在本教程中,您将学习如何:为SpringDSL初始化一个项目创建一个模型包创建一个服务和操作实现一个服务方法启用JAX-WS和DWR......
  • Java 断言 Assert 使用教程与最佳实践
    本文收录于Github.com/niumoo/JavaNotes,Java系列文档,数据结构与算法!本文收录于网站:https://www.wdbyte.com/,我的公众号:程序猿阿朗作为一个Java开发者,如果要问你Java中有哪些关键字,你可能会随口说出一串,如果问你Java有哪些最不常使用的关键字,或许你还能说出几个。但是......
  • 挑战前端基础120题--JavaScript 中如何实现链式调用的函数?
    一.何为链式调用?链式调用是一种简化过程的编码方式,使代码看起来更加简洁~它允许你通过在方法调用之间返回对象本身,从而连续地调用多个方法;比较常见的链式调用:jQuery,Promise等,通过多次书写.或()操作来调用。二.实现的原理?每次执行完成后返回自己/新的自己,这样可以确保后续的......
  • JavaImprove--Lesson10--IO流-字符流,缓冲流,转换流,打印流,数据流
    一.IO流-字符流上期在字节流的学习中,了解到字节流写字符操作表现很不好,随时面临乱码的情况,一下写完全部数据的,内存可能不足,所以对于文本操作还需要专业的操作 而字符流就非常适合操作文本字符FileWirte文件字符输入流作用:以内存为基准,可以把文件的数据以字符的形式输入到......
  • Java SE 笔记搬运
    本科过过两遍JavaSE,但是由于考研等不可抗力因素很久未接触代码,因工作需求这里将四年前的Java笔记重新整理搬运,方便Java学习。——————————————————————————————————————————————————————————————继承/*私有化的......
  • 详细分析Java中的@JsonFormat注解和@DateTimeFormat注解
    @DateTimeFormat(pattern="yyyy-MM-ddHH:mm:ss")@JsonFormat(pattern="yyyy-MM-ddHH:mm:ss",timezone="GMT+8")privateDatecreated_on;在前后端数据交互的过程中,Data类型的数据经常会出现类型映射转换的错误,为了达到业务的目标时间格式,通常会使用@JsonFormat和@DateTi......
  • Java并发工具类之LongAdder原理总结
    出处: Java并发工具类之LongAdder原理总结LongAdder实现原理图                                高并发下N多线程同时去操作一个变量会造成大量线程CAS失败,然后处于自旋状态,导致严重浪费CPU资源,降低了并发......
  • MyBatis所有的jdbcType类型对应的javaType类型
    来源:https://www.jb51.net/program/287517rew.htmMyBatis处理MySQL字段类型date与datetime1)DATETIME显示格式:yyyy-MM-ddHH:mm:ss时间范围:['1000-01-0100:00:00'到'9999-12-3123:59:59']2)DATE显示格式:yyyy-MM-dd时间范围:['1000-01-01'到'9999-12-31'......
  • cmd命令行运行Java文件产生乱码问题的解决方式
    1.第一种方式(改变记事本的编码集为ANSI)另存为ANSI 这样就OK啦2.第二种方式 改变cmd编码集 javac-encodingutf8 源文件名.java ......