Skip to content

Commit

Permalink
增加脱敏规则判断
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Jul 30, 2018
1 parent 356989a commit 5c682e9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sql/data_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def analy_query_tree(self, query_tree, cluster_name):
hit_columns = [] # 命中列
table_hit_columns = [] # 涉及表命中的列

# 判断是否存在不支持脱敏的语法
for select_item in select_list:
if select_item['type'] not in ('FIELD_ITEM', 'aggregate'):
raise Exception('不支持该查询语句脱敏!')

# 获取select信息的规则,仅处理type为FIELD_ITEM和aggregate类型的select信息,如[*],[*,column_a],[column_a,*],[column_a,a.*,column_b],[a.*,column_a,b.*],
select_index = [
select_item['field'] if select_item['type'] == 'FIELD_ITEM' else select_item['aggregate']['field'] for
Expand Down Expand Up @@ -215,8 +220,6 @@ def analy_query_tree(self, query_tree, cluster_name):
item['index'] = index
if item['field'] != '*':
columns.append(item)
else:
raise Exception('不支持select信息包含函数的查询脱敏!')

# 格式化命中的列信息
for column in columns:
Expand Down

0 comments on commit 5c682e9

Please sign in to comment.