Logo
ALTER MASK RULE

描述 #

ALTER MASK RULE 语法用于修改数据脱敏规则.

语法定义 #

alterMaskRule ::=
    'ALTER' 'MASK' 'RULE' maskRuleDefinition (',' maskRuleDefinition)*

maskRuleDefinition ::=
    ruleName '(' 'COLUMNS' '(' columnDefinition (',' columnDefinition)* ')' ')'

columnDefinition ::=
    '(' 'NAME' '=' columnName ',' algorithmDefinition ')' | '(' 'NAME' '=' columnName ',' algorithmGroupsDefinition ')'

algorithmGroupsDefinition ::=
    'ALGORITHM_GROUPS' '(' algorithmGroupDefinition (',' algorithmGroupDefinition)* ')'

algorithmGroupDefinition ::=
    '(' maskAlgorithm ',' matchingAlgorithm ')'

maskAlgorithm ::=
    'MASK_ALGORITHM' '(' algorithmDefinition ')'

matchingAlgorithm ::=
    'MATCHING_ALGORITHM' '(' algorithmDefinition ')'

algorithmDefinition ::=
    'TYPE' '(' 'NAME' '=' algorithmTypeName (',' propertiesDefinition)? ')'

maskAlgorithmType ::=
  literal

ruleName ::=
  identifier

columnName ::=
  identifier

propertiesDefinition ::=
    'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'

key ::=
  string

value ::=
  literal

补充说明 #

示例 #

修改数据脱敏规则 #

ALTER MASK RULE t_mask (
COLUMNS(
(NAME=phone_number,TYPE(NAME='MASK_FROM_X_TO_Y', PROPERTIES("from-x"=1, "to-y"=2, "replace-char"="*"))),
(NAME=address,TYPE(NAME='MD5'))
));

修改数据脱敏规则及绑定用户 #

ALTER MASK RULE t_mask (
COLUMNS(
(NAME=phone_number,ALGORITHM_GROUPS(
(MASK_ALGORITHM(TYPE(NAME='MASK_FROM_X_TO_Y',PROPERTIES('from-x'=1, 'to-y'=2, 'replace-char'='*'))),
MATCHING_ALGORITHM(TYPE(NAME='SphereEx:MASK_USERNAME', PROPERTIES('user-lists'='sharding'))))))));

保留字 #

ALTERMASKRULECOLUMNSNAMETYPEMATCHING_ALGORITHMMASK_ALGORITHMALGORITHM_GROUPS