If a user has the permissions to query specific sensitive data in a MaxCompute project but you do not want the user to view complete sensitive data, you can enable the dynamic data masking feature of MaxCompute. This way, MaxCompute can dynamically mask sensitive data in the query results. This topic describes how to enable the dynamic data masking feature of MaxCompute and provides an example.
Background information
The dynamic data masking feature of MaxCompute depends on Data Security Guard of DataWorks. You must activate Data Security Guard of DataWorks before you can enable the dynamic data masking feature for a MaxCompute project.
After you enable the dynamic data masking feature for a MaxCompute project, you can configure data masking rules for the project based on the data identification rules that are preconfigured in DataWorks. After you configure data masking rules, sensitive data in the query results is masked based on the rules when you query data in MaxCompute. The dynamic data masking feature can effectively protect sensitive information, such as mobile phone numbers, ID card numbers, bank card numbers, license plate numbers, and IP addresses. After the dynamic data masking feature is enabled, only sensitive data in the query results is masked and the data that is stored in the underlying storage is not affected.
We recommend that you use the data identification rules that are preconfigured in DataWorks. For more information about how to customize data identification rules, see Manage sensitive field types.
Limits
The dynamic data masking feature can be configured only for a MaxCompute project that resides in the China (Shanghai) region.
Procedure
To use the dynamic data masking feature in a MaxCompute project, perform the following steps:
Step 1: Activate Data Security Guard of DataWorks
Step 2: Enable the dynamic data masking feature for the MaxCompute project
Step 3: Use the dynamic data masking feature
- If you want to enable the dynamic data masking feature at the session level, you can
add the following masking settings before the SQL statement and commit them together
with the SQL statement. Sensitive data in the result of the SQL statement is masked.
set odps.output.field.formatter=aegis:masking_v1; set odps.isolation.session.enable=true;
- If you want to enable the dynamic data masking feature at the project level, you can
execute the following statement to configure the masking parameters for your project.
After the configuration is complete, sensitive data in the result of all the SQL statements
in the project is masked.
setproject odps.output.field.formatter=aegis:masking_v1;
Example
After the dynamic data masking feature is enabled for a MaxCompute project, sensitive data in the query results can be masked when you query data in MaxCompute. For example, an IP address masking rule is configured for Project A. The iptest table of Project A contains the following data:
+--------+-------------+
| name | ip |
+--------+-------------+
| a | 192.0.2.10 |
| b | 198.51.2.0 |
+--------+-------------+
set odps.output.field.formatter=aegis:masking_v1;
set odps.isolation.session.enable=true;
select * from iptest;
The following result is returned: +--------+----------------+
| name | ip |
+--------+----------------+
| a | 192.0.***.* |
| b | 198.51.***.* |
+--------+----------------+