Create and manage dynamic desensitization rules
Dynamic desensitization alters the data displayed in query results without changing the underlying data. Desensitization rules are used to manage the scope of data to be desensitized and the specific desensitization methods. This topic describes how to create and manage dynamic desensitization rules.
Limits
-
You can desensitize fields in both Dataphin tables and data source tables.
-
For SAP HANA data sources, dynamic desensitization is not supported for ad-hoc queries and data previews.
-
Desensitization rules are not applied when reading data from a data source table using a data integration task.
-
Desensitization wraps the field in a function, such as
MASK(col). This may invalidate indexes and reduce query performance. Therefore, avoid enabling mask on query on frequently filtered or joined fields.
Permissions
-
Security administrators and global custom roles with permissions to manage desensitization rules and data classifications can create and manage dynamic desensitization rules.
-
A first-level directory administrator can configure desensitization rules for the data classifications that they manage.
-
The owner of a desensitization rule can manage it, but their actions are restricted by their data classification management permissions.
Desensitization rules
-
Dynamic desensitization rules are commonly used for querying sensitive production data. They protect sensitive private data by transforming or encrypting data objects that meet specified conditions.
-
If a field in a table within the specified business category or project is tagged with the selected data classification, the system desensitizes the data according to the configured desensitization method and algorithm when writing to development tables or performing data queries.
Create a dynamic desensitization rule
-
In the top navigation bar of the Dataphin homepage, choose Governance > Data Security.
-
In the left-side navigation pane, choose Sensitive Data Protection > Desensitization Rules. On the Desensitization Rules page, click the Dynamic Desensitization Rules tab, and then click + New Dynamic Desensitization Rule.
-
In the New Dynamic Desensitization Rule dialog box, configure the parameters.
Parameter
Description
Rule name
Enter a name for the dynamic desensitization rule. Example: ID card desensitization.
Rule description
Enter a custom description for the rule, up to 200 characters. Example: Used for reading production data in the development environment.
Data classification
Select a data classification that you have permission to manage. For example: /Personal Information/Basic Personal Information/ID Card.
Data source
Select the data sources to which the desensitization rule applies. You can select both compute source table and data source table.
-
compute source table: Scope the data to be desensitized by business category and project.
-
data source table: Scope the data to be desensitized by data source range. Only MySQL, Oracle, and SAP HANA types are supported.
Business category
This parameter is required when you select compute source table as the data source. You can scope the data by business category. You can select All or Enumeration.
Project
This parameter is required when you select compute source table as the data source. You can scope the data by project. You can select All or Enumeration.
Data source scope
This parameter is required when you select data source table as the data source. Desensitization is supported only for MySQL, Oracle, and SAP HANA data sources with configured metadata collection tasks. You can select All Data Sources or Specified Data Sources.
-
All Data Sources: Applies the desensitization rule to all data source tables, including existing and future ones. The system automatically applies the rule to any field that matches the specified data classification.
-
Specified Data Sources: Applies the desensitization rule to data source tables within specific schemas, including existing and future ones. Click Add Data Source to configure data source instances and schema ranges one by one.
Application scenario
Select the scenarios where dynamic desensitization applies. Supported scenarios are Write to Development Table, Data Query, and Data Service API.
-
Write to Development Table: Desensitizes query results containing sensitive data from a source table before writing them to a development table. This prevents sensitive data from leaking from the production environment. In special cases, when a user account writes to a Basic table, this is also considered writing to a development table.
-
Data Query: For queries that are not part of scheduled production tasks, such as one-time task runs, ad-hoc queries, and analytical queries, the system desensitizes the query results before displaying them. This protects sensitive data without affecting the normal operation of production tasks.
-
Data Service API: This option is available if you have purchased the Data Service feature and the data source is a data source table. When selected, the system rewrites fields that match the desensitization rule in the query results returned by a Data Service API according to the corresponding desensitization algorithm.
Note-
For robust data protection, enable both the Write to Development Table and Data Query application scenarios.
-
If you need to use original data values for join analysis on development data, use a desensitization whitelist for precise control. This allows plaintext data to be written to tables only in specified scenarios. You should also configure the desensitization method as mask on display.
Desensitization method
You can select mask on query or mask on display.
-
mask on query: Desensitizes data as soon as it is queried. The desensitized results are used throughout SQL processing, which provides stronger data protection.
-
mask on display: Desensitizes data just before display. SQL processing uses the original data, which supports simple WHERE or JOIN conditions and is more user-friendly. Note that if you process a sensitive field with a user-defined function (UDF), such as for string truncation, the system triggers a desensitization fallback and replaces the generated field with asterisks (***).
Desensitization algorithm
Algorithms marked with
are advanced algorithms. You can use them only after the security function is installed in the project where the data resides. Otherwise, the system downgrades the desensitization to the default method (MD5). Desensitization algorithms include masking, hashing, encryption, and Others.NoteIf the compute engine is Doris, you must use Apache Doris v2.1.x or later to use the Birthday, Mobile Phone, Mobile Phone (Hide Length), Fixed-line Phone, Fixed-line Phone (Hide Length), SHA256, SHA384, and SHA512 desensitization algorithms.
If you select an advanced algorithm but the data source does not support function installation, the system downgrades the desensitization algorithm to the default method (MD5).
-
hashing
The following algorithms require a desensitization key: Hashing-Salted SHA256, Hashing-Salted SHA384, Hashing-Salted MD5, and Hashing-Salted SHA512.
Desensitization key: A required parameter for salted hash desensitization algorithms. There are no strict format requirements.
-
masking
-
Masking-Keyword Replacement
You must configure a regular expression and a replacement string.
-
Masking-Custom Mask, Masking-Custom Mask (Custom Replacement)
You must configure a set of masking parameters: start position, end position, and replacement content. You can add or remove pairs of these parameters.
-
-
encryption: Encryption desensitization algorithms are supported when the compute engine is MaxCompute.
If you select Native FPE format-preserving encryption, you must configure the encryption alphabet and tweak. If you select FPE format-preserving encryption, you must configure the encryption range. For more configuration details, see Configure the encryption transformation component.
-
Encryption alphabet: The set of characters used for encryption. You can use a System-built-in set (including Digits, Uppercase letters, Lowercase letters, Digits + Uppercase letters, Digits + Lowercase letters, Digits + Letters, and Special characters) or a Custom set.
-
Tweak: A tweak allows the same plaintext to produce different ciphertexts with the same key in different contexts, which can enhance the uniqueness and security of the ciphertext. Any character is supported.
-
Encryption range: Encrypts a specified range of characters or all characters. The encryption and decryption ranges must be consistent; otherwise, the decrypted result may not match the original data.
-
Exception handling: If an issue occurs, such as the plaintext not meeting algorithm requirements, a key mismatch, or an encoding inconsistency, the system processes the plaintext data according to the selected policy. You can choose to return null, return plaintext, or throw exception.
You do not need to configure an encryption key. The system uses its own key for encryption. This prevents the desensitized data from being decrypted and exposing sensitive data.
-
You can test the effect of an algorithm in Security Algorithms. For more information, see Test a security algorithm.
For detailed descriptions of security algorithms, see Security algorithm overview and Security algorithm examples.
For a list of desensitization algorithms supported by different compute engines, see Supported desensitization methods by engine.
Status
Select Enabled or Disabled to set the status of the rule.
-
-
Click OK to create the dynamic desensitization rule.
Default desensitization policy
-
The default desensitization policy is a fallback sensitive data protection strategy. It provides unified security protection for sensitive data that does not match a specific desensitization rule.
-
Only security administrators can configure the default desensitization policy.
-
On the Desensitization Rules page, click the Dynamic Desensitization Rules tab, and then click Default Desensitization Policy.
-
In the Default Desensitization Policy dialog box, configure the parameters.
Parameter
Description
Data sensitivity level
The levels, from lowest to highest, are: Public (L1) and above, Internal (L2) and above, Confidential (L3) and above, and Top Secret (L4) and above. To create a new data sensitivity level, see Create a data sensitivity level.
Data source
Select the data source to which the default policy applies. You can select compute source table or data source table. The default is compute source table.
Desensitization method
You can select mask on query or mask on display.
-
mask on query: Desensitizes data when it is queried. The desensitized results are used throughout SQL processing, which provides stronger data protection.
-
mask on display: Desensitizes data just before display. SQL processing uses the original data, which supports simple WHERE or JOIN conditions and is more user-friendly. Note that if you process a sensitive field with a user-defined function (UDF), such as for string truncation, the system triggers a desensitization fallback and replaces the generated field with asterisks (***).
Desensitization algorithm
You can select one of four desensitization algorithms: Return Null, Return MD5 Hash, Return Masked Value (fixed-length ***), or No Desensitization.
-
-
Click OK to create the default desensitization policy.
View dynamic desensitization rules
You can view the details of dynamic desensitization rules and perform actions such as editing, transferring, or deleting them.

|
Area |
Description |
|
① Introduction |
Displays an introduction to dynamic desensitization rules, desensitization whitelists, and static desensitization rules. |
|
② Filter and search area |
You can perform a fuzzy search by rule name or data classification, or filter precisely by Desensitization Type or Application Scenario. |
|
③ Dynamic desensitization rule list |
Displays the name, data classification, desensitization algorithm, application scenarios, owner, update time, and status for each rule. In the Actions column, you can Edit, Transfer, Delete, View Desensitization Algorithm, or View Desensitization Whitelist for a rule.
|