Skip to content

Commit a5b8e7a

Browse files
authored
docs: add data masking 3 (#481)
* docs: optimize part 1&2 * update * docs: add masking-3
1 parent fd2d4de commit a5b8e7a

File tree

3 files changed

+101
-10
lines changed

3 files changed

+101
-10
lines changed

content/docs/tutorials/github-action-data-masking-part1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ By using GitHub Actions with Bytebase API, you can implement policy-as-code to a
2020
This is Part 1 of our tutorial series on implementing automated database masking using GitHub Actions:
2121

2222
- Part 1: Column masking and masking exception with GitHub Actions (this one)
23-
- Part 2: Masking Algorithm with GitHub Actions
24-
- Part 3: Data Classification and Global Masking with GitHub Actions
23+
- Part 2: [Masking Algorithm with GitHub Actions](/docs/tutorials/github-action-data-masking-part2)
24+
- Part 3: [Data Classification and Global Masking with GitHub Actions](/docs/tutorials/github-action-data-masking-part3)
2525

2626
## Overview
2727

@@ -102,7 +102,7 @@ In the GitHub workflow, find the step `Apply column masking`, which will apply t
102102
--data @"$CHANGED_FILE")
103103
```
104104

105-
By changing the files `masking/databases/**/**/column-masking.json`, create a PR and then merge, the change will be applied to the database.
105+
By changing file `masking/databases/**/**/column-masking.json`, create a PR and then merge, the change will be applied to the database.
106106

107107
Log in Bytebase console, at the workspace level, click **Data Access > Data Masking**. Click **Explicit Masked Columns**, you can see the column masking is applied to the database.
108108

@@ -121,7 +121,7 @@ In the GitHub workflow, find the step `Apply masking exception`, which will appl
121121
--data @"$CHANGED_FILE")
122122
```
123123

124-
By changing the files `masking/projects/**/masking-exception.json`, create a PR and then merge, the change will be applied to the database.
124+
By changing file `masking/projects/**/masking-exception.json`, create a PR and then merge, the change will be applied to the database.
125125

126126
Log in Bytebase console, go to the project `Sample Project`, click **Database > Masking Access**, you can see the masking exception is applied to the database.
127127

content/docs/tutorials/github-action-data-masking-part2.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ In the [previous tutorial](/docs/tutorials/github-action-data-masking-part1), yo
1818
This is Part 2 of our tutorial series on implementing automated database masking using GitHub Actions:
1919

2020
- Part 1: [Column masking and masking exception with GitHub Actions](/docs/tutorials/github-action-data-masking-part1)
21-
- Part 2: Masking Algorithm with GitHub Actions (this one)
22-
- Part 3: Data Classification and Global Masking with GitHub Actions
21+
- Part 2: Masking Algorithm with GitHub Actions(this one)
22+
- Part 3: [Data Classification and Global Masking with GitHub Actions](/docs/tutorials/github-action-data-masking-part3)
2323

2424
## Overview
2525

@@ -36,16 +36,20 @@ The complete code for this tutorial is available at: [database-security-github-a
3636

3737
</HintBlock>
3838

39-
This tutorial skips the setup part, if you haven't set up the Bytebase and GitHub Action, please refer to the [previous tutorial](/docs/tutorials/github-action-data-masking-part1).
39+
This tutorial skips the setup part, if you haven't set up the Bytebase and GitHub Action, please follow **Setup Instructions** section in the [previous tutorial](/docs/tutorials/github-action-data-masking-part1).
4040

4141
## Masking Algorithm
4242

4343
You may customize your own [data masking algorithm](/docs/security/data-masking/masking-algorithm/) with the help of a predefined masking type, such as Full mask, Range mask, MD5 mask and Inner/Outer mask.
4444

45-
In Bytebase console, go to **Data Access > Data Masking**, click **Masking Algorithm** and click **Add**. You can create a new masking algorithm with a name and description, and later it can be used in the definition of semantic types.
45+
### In Bytebase console
46+
47+
Go to **Data Access > Data Masking**, click **Masking Algorithm** and click **Add**. You can create a new masking algorithm with a name and description, and later it can be used in the definition of semantic types.
4648

4749
![bb-masking-algorithm](/content/docs/tutorials/github-action-data-masking-part2/bb-masking-algorithm.webp)
4850

51+
### In GitHub Workflow
52+
4953
In the GitHub workflow `bb-masking-2.yml`, find the step `Apply masking algorithm`, which will apply the masking algorithm to the database via API. All the masking algorithms should be defined in one file in the root directory of `masking/masking-algorithm.json`. The code it calls Bytebase API is as follows:
5054

5155
```bash
@@ -55,15 +59,21 @@ response=$(curl -s -w "\n%{http_code}" --request PATCH "${BYTEBASE_API_URL}/sett
5559
--data @"$CHANGED_FILE")
5660
```
5761

62+
By changing file `masking/masking-algorithm.json`, you can apply the masking algorithm to the database. Go to Bytebase console, click **Data Access > Data Masking**, go to **Masking Algorithm** page, you can see the masking algorithm is applied to the database.
63+
5864
## Semantic Type
5965

6066
You may define [semantic types](/docs/security/data-masking/semantic-types/) and apply them to columns of different tables. Columns with the same semantic type will be masked with the same masking algorithm. For example, you may define a semantic type `mobile` and apply it to all the columns of phone number. Then you can define a masking algorithm `range 4-10` for the partial level masking for semantic type `mobile`.
6167

62-
In Bytebase console, go to **Data Access > Data Masking**, click **Semantic Types** and click **Add**. You can create a new semantic type with a name and description, and select the masking algorithm.
68+
### In Bytebase Console
69+
70+
Go to **Data Access > Data Masking**, click **Semantic Types** and click **Add**. You can create a new semantic type with a name and description, and select the masking algorithm.
6371

6472
![bb-semantic-types](/content/docs/tutorials/github-action-data-masking-part2/bb-semantic-types.webp)
6573

66-
In the GitHub workflow, find the step `Apply semantic type`, which will apply the semantic type to the database via API. All the masking algorithms should be defined in one file in the root directory as `masking/semantic-type.json`. The code it calls Bytebase API is as follows:
74+
### In GitHub Workflow
75+
76+
Find the step `Apply semantic type`, which will apply the semantic type to the database via API. All the masking algorithms should be defined in one file in the root directory as `masking/semantic-type.json`. The code it calls Bytebase API is as follows:
6777

6878
```bash
6979
response=$(curl -s -w "\n%{http_code}" --request PATCH "${BYTEBASE_API_URL}/settings/bb.workspace.semantic-types?allow_missing=true" \
@@ -72,6 +82,8 @@ response=$(curl -s -w "\n%{http_code}" --request PATCH "${BYTEBASE_API_URL}/sett
7282
--data @"$CHANGED_FILE")
7383
```
7484

85+
By changing file `masking/semantic-type.json`, you can apply the semantic type to the database. Go to Bytebase console, click **Data Access > Data Masking**, go to **Semantic Types** page, you can see the semantic type is applied to the database.
86+
7587
## Next Steps
7688

7789
Now you have successfully applied data masking algorithm and semantic type using GitHub Actions and Bytebase API. In the next part of this tutorial, you'll learn how to use data classification and global masking with GitHub Actions. Stay tuned!
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: 'Applying Data Masking with GitHub Actions - Part 3'
3+
author: Dec
4+
updated_at: 2024/12/04 18:00
5+
tags: Tutorial
6+
integrations: General, API
7+
level: Advanced
8+
estimated_time: '30 mins'
9+
description: 'Learn how to use data classification and global masking policy using GitHub Actions and Bytebase API'
10+
---
11+
12+
<IncludeBlock url="/docs/share/tutorials/api-preface"></IncludeBlock>
13+
14+
In the [previous tutorial](/docs/tutorials/github-action-data-masking-part2), you learned how to customize both the masking algorithm and semantic types. In this tutorial, we will explore how to use data classification and global masking policy.
15+
16+
---
17+
18+
This is Part 3 of our tutorial series on implementing automated database masking using GitHub Actions:
19+
20+
- Part 1: [Column masking and masking exception with GitHub Actions](/docs/tutorials/github-action-data-masking-part1)
21+
- Part 2: [Masking Algorithm with GitHub Actions](/docs/tutorials/github-action-data-masking-part2)
22+
- Part 3: Data Classification and Global Masking with GitHub Actions(this one)
23+
24+
## Overview
25+
26+
In this tutorial, you'll learn how to automate data classification and global masking policy using GitHub Actions and the Bytebase API. This integration allows you to:
27+
28+
- Manage data classification and global masking policy as code
29+
- Automatically apply masking policies when PRs are merged
30+
31+
<HintBlock type="info">
32+
33+
The complete code for this tutorial is available at: [database-security-github-actions-example](https://github.com/bytebase/database-security-github-actions-example)
34+
35+
</HintBlock>
36+
37+
This tutorial skips the setup part, if you haven't set up the Bytebase and GitHub Action, please follow **Setup Instructions** section in the [previous tutorial](/docs/tutorials/github-action-data-masking-part1).
38+
39+
## Data Classification
40+
41+
### In Bytebase Console
42+
43+
Follow [Data Classification](/docs/security/data-classification/).
44+
45+
### In GitHub Workflow
46+
47+
Find the step `Apply classification`, which will apply the classification to the database via API. All the classifications should be defined in one file in the root directory as `masking/classification.json`. The code it calls Bytebase API is as follows:
48+
49+
```bash
50+
response=$(curl -s -w "\n%{http_code}" --request PATCH "${BYTEBASE_API_URL}/settings/bb.workspace.classification" \
51+
--header "Authorization: Bearer ${BYTEBASE_TOKEN}" \
52+
--header "Content-Type: application/json" \
53+
--data @"$CHANGED_FILE")
54+
```
55+
56+
By changing file `masking/classification.json`, creating a PR and merging, you can apply the classification to the database. Go to Bytebase console, click **Data Access > Data Classification**, go to **Classification** page, you can see the classification is applied to the database.
57+
58+
## Global Masking Rule
59+
60+
### In Bytebase Console
61+
62+
Follow [Global Masking Rule](/docs/security/data-masking/global-masking-rule/).
63+
64+
### In GitHub Workflow
65+
66+
Find the step `Apply global masking rule`, which will apply the global masking rule to the database via API. All the global masking rules should be defined in one file in the root directory as `masking/global-masking-rule.json`. The code it calls Bytebase API is as follows:
67+
68+
```bash
69+
response=$(curl -s -w "\n%{http_code}" --request PATCH "${BYTEBASE_API_URL}/settings/bb.workspace.global_masking_rule?allow_missing=true&update_mask=payload" \
70+
--header "Authorization: Bearer ${BYTEBASE_TOKEN}" \
71+
--header "Content-Type: application/json" \
72+
--data @"$CHANGED_FILE")
73+
```
74+
75+
By changing file `masking/global-masking-rule.json`, creating a PR and merge, you can apply the global masking rule to the database. Go to Bytebase console, click **Data Access > Data Masking**, go to **Global Masking Rule** page, you can see the global masking rule is applied to the database.
76+
77+
## Summary
78+
79+
Through out this tutorial series, you have learned how to automate database masking policies, customize both the masking algorithm and semantic types, and use data classification and global masking policy using GitHub Actions and Bytebase API.

0 commit comments

Comments
 (0)