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

PG脱敏-查询语句中带有别名脱敏处理 #973

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

learn0208
Copy link
Contributor

@learn0208 learn0208 commented Nov 20, 2020

修复了PG查询语句中带有别名字段时不能脱敏的处理逻辑。
目前使用没啥问题。
此脱敏方法一样适合于oracle

@codecov
Copy link

codecov bot commented Nov 20, 2020

Codecov Report

Merging #973 (ad07ecd) into master (015d278) will decrease coverage by 0.00%.
The diff coverage is 73.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #973      +/-   ##
==========================================
- Coverage   77.98%   77.98%   -0.01%     
==========================================
  Files          76       76              
  Lines       11890    11904      +14     
==========================================
+ Hits         9273     9283      +10     
- Misses       2617     2621       +4     
Impacted Files Coverage Δ
sql/utils/data_masking.py 92.72% <73.33%> (-1.45%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 015d278...ad07ecd. Read the comment docs.

@LeoQuote
Copy link
Collaborator

也是辛苦了, 我之前的 brute mask 就是因为不想去处理sql里的别名这些东西, 做的全字段脱敏

Copy link
Collaborator

@LeoQuote LeoQuote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@learn0208
Copy link
Contributor Author

learn0208 commented Nov 20, 2020

这边需求,没辙啊,只能硬着头皮来。
看你代码,脱敏对mysql这里有个简单的优化。先判断是否存在实例的脱敏规则,不然这个消耗有点大。
我这边是这么干的。前面加了个简单判断

def data_masking(instance, db_name, sql, sql_result):
    """脱敏数据"""
    try:
        # 如果实例没有配置脱敏规则, 跳过脱敏环节
        masking_columns = DataMaskingColumns.objects.filter(instance=instance, active=True)
        if not masking_columns:
            return sql_result

@LeoQuote LeoQuote added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Nov 20, 2020
@LeoQuote LeoQuote merged commit e4c026d into hhyo:master Nov 20, 2020
@LeoQuote
Copy link
Collaborator

关于这些你的想法, 下次可以直接提pr, 非常感谢贡献

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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants