Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ 功能建议 ] 查询表权限检验和动态脱敏功能改造 #145

Closed
hhyo opened this issue Apr 23, 2019 · 5 comments
Closed

[ 功能建议 ] 查询表权限检验和动态脱敏功能改造 #145

hhyo opened this issue Apr 23, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@hhyo
Copy link
Owner

hhyo commented Apr 23, 2019

目前遇到的问题/使用障碍

表权限

关于表权限检验,目前是利用inception的语法树打印获取SQL包含的表信息,再按照用户拥有的权限列表进行判断,不支持子查询的解析

查询脱敏

包括MySQL和MsSQL的实现,相关配置项:QUERY_CHECK说明

MySQL查询脱敏需要先解析语句,获取select信息,提取脱敏字段,再针对脱敏字段去正则匹配脱敏规则,进行字符替换

MsSQL的实现则相对简单,不需要解析语句,直接对所有查询结果数据进行匹配替换

解析语句比较精准,没有误伤,但是语法解析相对困难,会存在比较多的限制

希望如何解决/实现它

其他信息

语法解析相关开源库

  • 小米SOAR:go实现,结合了vitess的语法解析库和TIDB语法解析库,仅支持mysql
  • Inception:c实现,包含语法树打印功能,仅支持mysql
  • Druid:java实现,SQL Parser模块,支持数据库多
  • sqlparser:python实现,需要自己遍历tokens
  • moz-sql-parser:python实现,直接输出语法树
@hhyo hhyo added this to ALL in 需求汇总 via automation Apr 23, 2019
@hhyo hhyo added the enhancement New feature or request label Apr 23, 2019
@hhyo
Copy link
Owner Author

hhyo commented Aug 24, 2019

这里分别列出不支持表权限校验和脱敏的场景,欢迎补充

表权限校验失效

  • 嵌套子查询

脱敏失效

@xxlrr
Copy link
Contributor

xxlrr commented Aug 30, 2019

表权限校验失效

  • group by子句包含别名

作者您好,在我们的使用中出现了表权限校验失效的问题
触发SQL:
select DATE_FORMAT(logtime,"%Y-%m-%d") 'logdate', sum(other) '' FROM table
where logtime>='2019-08-22'
GROUP BY logdate;
报错信息:
Inception Error: Column 'logdate' not existed.
失效原因:
group by子句中出现别名,Inception在语法解析部分误解析为列名。
版本信息:
Archery1.6.4、Inception2.1.50

@hhyo
Copy link
Owner Author

hhyo commented Nov 17, 2019

先处理表权限检验的问题,表权限使用sqlparser解析检验,相比inception支持更多语法

@hhyo
Copy link
Owner Author

hhyo commented Dec 7, 2019

MySQL查询权限已使用goInception解析,兼容更多检验场景

@hhyo
Copy link
Owner Author

hhyo commented Jul 4, 2020

卒,无进一步改造计划

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
需求汇总
  
Done
Development

No branches or pull requests

2 participants