資料遮罩函數 (Data Masking Functions)
Info
This feature is only available after version 2.8.0
Canner Enterprise 目前提供內建的資料遮罩 (Data Masking) 函數,讓使用者在進行資料分析時,可以直接使用這些內建函數進行個人資料上的遮蔽,達成保護敏感資料的目的。
目前支援可以遮蔽的個人資料種類包含:
- 地址
- 電話號碼
- 姓名
- 生日
- 身分證字號
- 信箱
資料遮罩函數
在 Canner Enterprise 中,你可以透過 redact
將原始的資料進行替換,例如將手機號碼替換成 *
符號。目前支援以下幾種類型的替換方式
1. redact(string, pattern, replacement)
輸入的值符合正規表達式或是內建遮罩模式,該值將會被進行替換。
regular expression
demo=> select redact('johndoe@example.com','^(.*)@(.*)$', '*****@***.com');
redact
---------------
*****@***.com
(1 row)
built-in pattern
參考文件下方查看所有內建遮罩模式
demo=> select redact('johndoe@example.com','EMAIL_NAME', '*****');
redact
-------------------
*****@example.com
(1 row)
2. redact(string, struct)
可以定義一個 JSON object,並將 pattern 作為 key,取代的值作為 value,此時輸入的值會若符合該模式則會被進行替換。
demo=> select redact('johndoe@example.com','{"EMAIL_NAME":"*****","EMAIL_DOMAIN_LAST_3_PRESERVED":"yyds."}');
redact
----------------
*****@yyds.com
(1 row)
內建遮罩模式(Built-in pattern)
Category | Pattern Name | Input | Output | Replacement |
---|---|---|---|---|
Address | TAIWAN_ADDRESS_WITH_CITY_AND_DISTRICT_AND_STREET_KEPT | 台北市中正區忠孝東路一段1號 | 台北市中正區忠孝東路一段* | * |
Address | TAIWAN_ADDRESS_WITH_CITY_AND_DISTRICT_KEPT | 台北市中正區忠孝東路一段1號 | 台北市中正區* | * |
Address | TAIWAN_ADDRESS_WITH_CITY_KEPT | 台北市中正區忠孝東路一段1號 | 台北市* | * |
Address | ADDRESS_WITH_COUNTRY_ZIPCODE_STATE_KEPT | 725 5th Ave, New York, NY 10022, United States | * , * , NY 10022, United States | * |
Address | ADDRESS_WITH_COUNTRY_KEPT | 725 5th Ave, New York, NY 10022, United States | * , * , * * , United States | * |
Phone Number | TAIWAN_PHONE_NUMBER | 0912345678 | 09* | * |
Phone Number | PHONE_NUMBER_WITH_LAST_3_KEPT | 886912345678 | * 678 | * |
Phone Number | PHONE_NUMBER_WITH_LAST_4_KEPT | 02 2321 4311 | * 4311 | * |
Phone Number | PHONE_NUMBER_WITH_COUNTRY_CODE_KEPT | +886912345678 | +886* | * |
Name | CHINESE_NAME_SECOND_CHAR | 王大錘 | 王* 錘 | * |
Name | CHINESE_NAME_LAST_PRESERVED | 王大錘 | * 錘 | * |
Name | CHINESE_NAME_FIRST_PRESERVED | 王大錘 | 王* | * |
Name | LAST_NAME_PRESERVED | John Doe | * Doe | * |
Name | FIRST_NAME_PRESERVED | John Doe | John * | * |
Date of Birth | DATE_OF_BIRTH_WITH_MONTH_AND_DAY_KEPT_ROC_ERA | 84/04/01 | * /04/01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_AND_DAY_KEPT_ROC_ERA | 84/04/01 | 84/* /01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_AND_MONTH_KEPT_ROC_ERA | 84/04/01 | 84/04/* | * |
Date of Birth | DATE_OF_BIRTH_WITH_DAY_KEPT_ROC_ERA | 84/04/01 | * /* /01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_MONTH_KEPT_ROC_ERA | 84/04/01 | * /04/* | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_KEPT_ROC_ERA | 84/04/01 | 84/* /* | * |
Date of Birth | DATE_OF_BIRTH_WITH_MONTH_AND_DAY_KEPT_ISO_8601 | 1970-01-01 | * -01-01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_AND_DAY_KEPT_ISO_8601 | 1970-01-01 | 1970-* -01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_AND_MONTH_KEPT_ISO_8601 | 1970-01-01 | 1970-01-* | * |
Date of Birth | DATE_OF_BIRTH_WITH_DAY_KEPT_ISO_8601 | 1970-01-01 | * -* -01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_MONTH_KEPT_ISO_8601 | 1970-01-01 | * -01-* | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_KEPT_ISO_8601 | 1970-01-01 | 1970-* -* | * |
Date of Birth | DATE_OF_BIRTH_WITH_MONTH_AND_DAY_KEPT | 1970/01/01 | * /01/01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_AND_DAY_KEPT | 1970/01/01 | 1970/* /01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_AND_MONTH_KEPT | 1970/01/01 | 1970/01/* | * |
Date of Birth | DATE_OF_BIRTH_WITH_MONTH_KEPT | 1970/01/01 | * /01/* | * |
Date of Birth | DATE_OF_BIRTH_WITH_DAY_KEPT | 1970/01/01 | * /* /01 | * |
Date of Birth | DATE_OF_BIRTH_WITH_YEAR_KEPT | 1970/01/01 | 1970/* /* | * |
Identification Number | TAIWAN_ID_NUMBER_KEEP_LETTER_AND_LAST_4_PRESERVED | F123456789 | F* 6789 | * |
Identification Number | TAIWAN_ID_NUMBER_LETTER_PRESERVED | F123456789 | F* | * |
Email | EMAIL_DOMAIN_LAST_3_PRESERVED | johndoe@example.com | johndoe@* com | * |
Email | EMAIL_DOMAIN_LAST_1_PRESERVED | johndoe@example.com | johndoe@* m | * |
Email | EMAIL_DOMAIN_FIRST_3_PRESERVED | johndoe@example.com | johndoe@exa* | * |
Email | EMAIL_DOMAIN_FIRST_1_PRESERVED | johndoe@example.com | johndoe@e* | * |
Email | EMAIL_DOMAIN | johndoe@example.com | johndoe@* | * |
Email | EMAIL_NAME_LAST_3_PRESERVED | johndoe@example.com | * doe@example.com | * |
Email | EMAIL_NAME_LAST_1_PRESERVED | johndoe@example.com | * e@example.com | * |
Email | EMAIL_NAME | johndoe@example.com | * @example.com | * |
Email | EMAIL_NAME_FIRST_1_PRESERVED | johndoe@example.com | j* @example.com | * |
Email | EMAIL_NAME_FIRST_3_PRESERVED | johndoe@example.com | joh* @example.com | * |