Skip to content

Commit fcc391a

Browse files
update data masking tuts (#512)
1 parent e2e5c57 commit fcc391a

24 files changed

+53
-36
lines changed

content/docs/tutorials/data-masking.md

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
title: How to Configure Dynamic Data Masking
33
author: Ningjing
4-
updated_at: 2024/10/08 20:00
5-
feature_image: /content/docs/tutorials/step-by-step-guide-to-data-masking/data-mask-banner.webp
4+
updated_at: 2025/02/05 18:00
65
tags: Tutorial
76
integrations: General
87
level: Intermediate
@@ -21,7 +20,7 @@ from being exposed to unauthorized users.
2120
<HintBlock type="info">
2221

2322
This tutorial covers configuration via UI console. You can also codify the masking policies, check
24-
out [this sample](https://github.com/bytebase/database-security-github-actions-example).
23+
out [this sample](https://github.com/bytebase/database-security-github-actions-example/tree/main/masking).
2524

2625
</HintBlock>
2726

@@ -44,69 +43,87 @@ out [this sample](https://github.com/bytebase/database-security-github-actions-e
4443

4544
Enter **SQL Editor** on top right. Without any worksheet open (no tab page open on top), click **Connect to a database** or **Select a database to start**.
4645

47-
![sql-editor-entry](/content/docs/tutorials/step-by-step-guide-to-data-masking/sql-editor-entry.webp)
46+
![sql-editor-entry](/content/docs/tutorials/data-masking/sql-editor-entry.webp)
4847

4948
Choose database `hr_prod` under `Prod Sample Instance` within the Connection detail page. Run `SELECT * FROM employee;`, you'll see the following result without any masking.
5049

51-
![prod-without-masking](/content/docs/tutorials/step-by-step-guide-to-data-masking/prod-without-masking.webp)
50+
![prod-without-masking](/content/docs/tutorials/data-masking/prod-without-masking.webp)
5251

53-
Run the same query against database `hr_test`, the result is the same.
52+
### Semantic Types
53+
54+
Semantic type is a way to classify data into different categories. You may apply them to columns to apply the same masking rule.
55+
56+
1. Enter **Data Access > Semantic Types**, click **Add**.
57+
1. Fill in the name, description and specify the **Masking Algorithm**. Click the check mark.
58+
59+
![bb-semantic-type](/content/docs/tutorials/data-masking/bb-semantic-type.webp)
60+
61+
There are two ways to apply the semantic type and its masking algorithm:
62+
63+
1. Apply to a column directly.
64+
2. Apply according to a global masking rule.
65+
66+
### Column Masking Rule
67+
68+
As a project owner, you may want to apply the semantic type to a column, usually it's a column that you want to mask on production environment.
69+
70+
1. Go into the project `Sample Project`, and click database `hr_prod`.
71+
72+
1. Go into the `employee` table, and set the `birth_date` column to apply the `birth_date` semantic type.
73+
74+
![bb-column-semantic-type](/content/docs/tutorials/data-masking/bb-column-semantic-type.webp)
75+
76+
1. Go back to SQL Editor, run `SELECT * FROM employee;` within `hr_prod`. You'll see the `birth_date` is masked based on the masking algorithm.
77+
78+
![bb-sql-editor-column-masking](/content/docs/tutorials/data-masking/bb-sql-editor-column-masking.webp)
5479

5580
### Global Masking Rule
5681

57-
You may want to batch apply masking settings. Use [Global Masking Rule](/docs/security/data-masking/global-masking-rule/) to achieve this.
82+
As a DBA, you may want to batch apply masking settings. Use [Global Masking Rule](/docs/security/data-masking/global-masking-rule/) to achieve this.
5883

59-
Here for example, we'll mask all the `birth_date` columns in all tables.
84+
1. Enter **Data Access > Semantic Types**, click **Use Predefined Type**.
85+
1. Add the predefined type `Default`.
86+
1. Enter **Data Access > Global Masking Rule**, click **Add**.
87+
1. Here define a global masking rule to mask all the `birth_date` columns in all tables on production environment with semantic type `Default`, and click **Confirm**.
6088

61-
1. Within Workspace, enter **Security & Policy** > **Data Masking** on the left. Click **Add** on top right of `Global Masking Rule` page.
89+
![bb-global-masking-rule](/content/docs/tutorials/data-masking/bb-global-masking-rule.webp)
6290

63-
2. Name the rule as `birth_date should be masked`, select `Column name`, `==`. Fill `birth_date` in the input box, and **Confirm**.
64-
![global-birth-date](/content/docs/tutorials/step-by-step-guide-to-data-masking/global-birth-date.webp)
91+
1. Go back to SQL Editor, run `SELECT * FROM employee;` within `hr_prod`. You'll see the `birth_date` is masked.
6592

66-
3. Go back to SQL Editor. Run `SELECT * FROM employee;` within `hr_prod` again. You'll see the `birth_date` is masked. Result within `hr_test` is the same.
67-
![query-prod-masked](/content/docs/tutorials/step-by-step-guide-to-data-masking/query-prod-masked.webp)
93+
![bb-sql-editor-column-masking](/content/docs/tutorials/data-masking/bb-sql-editor-column-masking.webp)
6894

69-
For a more organized and hierarchical global masking management, check [Data Classification](/docs/security/data-masking/data-classification/).
95+
1. You may also notice that the global masking rule take precedence over the column masking rule.
7096

7197
### Export data with masked columns
7298

7399
Exported data is masked in the same way as query results.
74100

75101
1. Stay on the SQL Editor after querying, and click **Export**.
76-
![prod-export](/content/docs/tutorials/step-by-step-guide-to-data-masking/prod-export.webp)
77-
78-
2. Fill in the export rows number, choose the format and click **Confirm**. The file will start downloading.
79102

80-
3. Open the downloaded file, you'll see the `birth_date` is masked.
81-
![exported-data](/content/docs/tutorials/step-by-step-guide-to-data-masking/exported-data.webp)
82-
83-
### Column Masking Rule
103+
![bb-sql-editor-export](/content/docs/tutorials/data-masking/bb-sql-editor-export.webp)
84104

85-
If you want to mask a specific column in a specific table, you can use **Column Masking Rule**.
105+
1. Fill in the export rows number, choose the format and click **Confirm**. The file will start downloading.
86106

87-
1. Enter **Database** > **Databases** within `Sample Project`. Choose table `salary` of database `hr_prod`.
107+
1. Open the downloaded file, you'll see the `birth_date` is masked.
88108

89-
2. Click the pencil icon by `Masking level` of row `amount`, choose `Full` for Masking level in Setting detail page.
90-
![prod-salary-amount](/content/docs/tutorials/step-by-step-guide-to-data-masking/prod-salary-amount.webp)
109+
![exported-data](/content/docs/tutorials/data-masking/exported-data.webp)
91110

92-
3. Go back to SQL Editor. Run `SELECT * FROM salary;` within `hr_prod`. You'll see `amount` been masked.
93-
![query-prod-salary-amount-masked](/content/docs/tutorials/step-by-step-guide-to-data-masking/query-prod-salary-amount-masked.webp)
111+
### Masking Exemptions
94112

95-
Switch to database `hr_test` to run the same command, `amount` will appear not masked.
113+
You can reveal masked data to a specific user by granting masking exemption.
96114

97-
![query-prod-salary-amount-masked](/content/docs/tutorials/step-by-step-guide-to-data-masking/query-prod-salary-amount-masked.webp)
115+
1. Go into the project `Sample Project`, and click **Manage > Masking Exemptions**.
116+
1. Grant exemption to the user and click **Confirm**.
98117

99-
### Grant unmasked access to a user
118+
![bb-masking-exemption](/content/docs/tutorials/data-masking/bb-masking-exemption.webp)
100119

101-
You can reveal masked data to a specific user by granting unmasked access.
120+
1. Go back to SQL Editor, run `SELECT * FROM employee;` within database `hr_prod`. You'll see the `birth_date` is unmasked.
102121

103-
1. Locate the column and click the pencil icon by `Masking level` of row `amount`, **Grant Access**. Select the user and **Confirm**.
104-
![grant-access](/content/docs/tutorials/step-by-step-guide-to-data-masking/grant-access.webp)
122+
![bb-sql-editor-exemption](/content/docs/tutorials/data-masking/bb-sql-editor-exemption.webp)
105123

106-
![grant-access-detail](/content/docs/tutorials/step-by-step-guide-to-data-masking/grant-access-detail.webp)
124+
1. If you export the data, the `birth_date` is also unmasked.
107125

108-
1. Login as the granted user. Run `SELECT * FROM salary;` within database `hr_prod` in SQL Editor. `amount` data is shown as unmasked.
109-
![dba-query-salary](/content/docs/tutorials/step-by-step-guide-to-data-masking/dba-query-salary.webp)
126+
![exported-data-exemption](/content/docs/tutorials/data-masking/exported-data-exemption.webp)
110127

111128
## Related content
112129

55.4 KB
Loading
8.03 KB
Loading
57.6 KB
Loading
18.2 KB
Loading
100 KB
Loading
117 KB
Loading
50.6 KB
Loading
93.4 KB
Loading
75.6 KB
Loading

0 commit comments

Comments
 (0)