Private Information Masking

Updated at:

The private information masking operator uses regular expressions to identify and replace private information. For example, it replaces an email address with [EMAIL], a mobile phone number with [MOBILEPHONE], a landline number with [TELEPHONE], and an ID card number with [IDNUM]. This topic describes how to configure the private information masking operator.

Prerequisites

  • To use the workflow feature, you must first purchase the unstructured data feature for your instance.

  • You have created a workflow. For detailed steps, see Create and manage a workflow.

Permissions

Project administrators, developers, analysts, and custom project roles with the Dataset-Use permission can use all datasets in a Basic project as the operator's input and output.

Supported file formats

The private information masking operator supports the following file formats: txt, md, csv, json, xml, and html.

Procedure

  1. In the top navigation bar of the Dataphin homepage, choose R&D > Data Development.

  2. In the top navigation bar of the Develop page, select a Project.

  3. In the left-side navigation pane, choose Data Processing > Workflow. In the Workflow list, click the target workflow to open its canvas. From the Operator Library, drag the Private Information Masking operator to the canvas. In the Private Information Masking panel on the right, configure the parameters.

    Parameter

    Description

    Step name

    The name of the operator. You can enter any combination of characters. The name can be up to 256 characters long.

    Input settings

    Dataset

    Select the dataset that you want to process. You can select a mixed dataset or a table dataset. After you select a dataset, you must also select a Version. By default, the earliest version is selected.

    If this operator is downstream from another, this dataset is typically the output of the upstream operator.

    Input field

    Select a field from the metadata table of the input dataset. The system determines how to process the field's content based on its type:

    • If the field is a URL type, the system automatically fetches the resource at the URL and parses its structured or semi-structured content. The supported file formats include .txt, .md, .csv, .json, .xml, and .html.

    • If the field is not a URL type, the system treats the field value as plain text.

    Filter condition (Optional)

    Use SQL syntax. Enter only the filter condition after the WHERE clause. You can use global system variables, such as the business date ${bizdate}.

    Operator settings

    Desensitization content selection

    Select the types of private information to mask. For more information about the regular expressions that the system uses to identify this content, see Appendix: Regular expressions for identifying and masking content.

    Output settings

    Dataset

    You can select Source dataset or Other datasets. If the source dataset's metadata table lacks a primary key, Other datasets is selected by default.

    • If you select Other datasets, you must specify a Dataset and its Version as the output dataset based on the input field type. By default, the earliest version of the dataset is selected. You can also select another version of the source dataset.

      • If the input field is a URL type field (which generates a file after processing), you can only select a mixed dataset as the output dataset.

      • If the input field is not a URL type field (which does not generate a file after processing), you can select a mixed dataset or a table dataset as the output dataset.

    • If you select Source dataset, the operator writes the generated metadata to the source dataset's metadata table.

    File output path

    The path where the output file is saved. This parameter is available only when the input field is a URL type.

    Load policy

    If the metadata table of the selected output dataset contains a primary key, update on primary key conflict is selected by default. If no primary key exists, append data is selected by default.

    • Append data: Appends new data to the destination table. A primary key or constraint conflict will cause an error.

    • Update on primary key conflict: If a primary key or constraint conflict occurs, the system replaces the existing row with the new data.

    • Overwrite: Deletes all data from the destination table before writing the new data.

    Note

    When the output dataset is set to Source Dataset, the load policy only supports Update on Primary Key Conflict.

    Field mapping

    If the input field for the private information masking operator is a URL field, the operator outputs a fixed field named markdown_url, which is the storage URL of the output file. If the input field is not a URL field, the operator outputs a fixed field named processed_text that contains the masked text.

    By default, the operator maps its output fields to fields with the same names in the output dataset. You can also manually select destination fields for custom mapping. In addition, you can map passthrough fields from the source dataset to the destination dataset. You can manage field mappings in the following ways:

    • Add output field: Click to add a new, empty field mapping row. This feature is available only when you select Other datasets as the output dataset.

    • Batch mapping: Click to perform batch manual mapping, map by name, or map by row. This feature is available only when you select Other datasets as the output dataset.

    • Delete mapping: Click the Delete icon to delete the corresponding field mapping. The mapping for the operator's fixed output fields cannot be deleted.

  4. After you configure the parameters, click Save in the top menu bar of the canvas.

    You can then add more operators to build your workflow.

Appendix: Masking regular expressions

Content to mask

Regular expression

Masked content

Mobile phone number

(?<!\d)(1[3-9]\d{9})(?!\d)

[MOBILEPHONE]

Email

(?<![A-Za-z0-9._%+-])([A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+)(?![A-Za-z0-9._%+-])

[EMAIL]

Landline number

(?<!\d)((?:\(\s*0\d{2,3}\s*\)|0\d{2,3})[-\s]?\d{7,8})(?!\d)

[TELEPHONE]

ID card

(?<!\d)([1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}[0-9Xx])(?!\d)

[IDNUM]

ID card number (Taiwan, China)

(?<![A-Za-z0-9])([A-Z][12]\d{8})(?![A-Za-z0-9])

[IDNUM]

ID card number (Hong Kong, China)

(?<![A-Za-z0-9])([A-Z]{1,2}\d{6}\(?[0-9A]\)?)(?![A-Za-z0-9])

[IDNUM]

ID card number (Macao, China)

(?<![A-Za-z0-9])([157]\d{6}\(?[0-9A-Z]\)?)(?![A-Za-z0-9])

[IDNUM]

IPv4 address

(?<!\d)((?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.(?:25[0-5]|2[0-4]\d|[01]?\d\d?))(?!\d)

[IPV4]

IPv6 address

(?<![0-9A-Fa-f:])((?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,5}(?::[0-9A-Fa-f]{1,4}){1,2}|(?:[0-9A-Fa-f]{1,4}:){1,4}(?::[0-9A-Fa-f]{1,4}){1,3}|(?:[0-9A-Fa-f]{1,4}:){1,3}(?::[0-9A-Fa-f]{1,4}){1,4}|(?:[0-9A-Fa-f]{1,4}:){1,2}(?::[0-9A-Fa-f]{1,4}){1,5}|[0-9A-Fa-f]{1,4}:(?::[0-9A-Fa-f]{1,4}){1,6}|:(?::[0-9A-Fa-f]{1,4}){1,7}|::)(?![0-9A-Fa-f:])

[IPV6]

Credit card number

(?<!\d)(4\d{12}(?:\d{3})?(?:\d{3})?|5[1-5]\d{14}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|6(?:011|5\d{2})\d{12}|35\d{14}|62\d{14,17})(?!\d)

[CREDITCARD]

Bank card number

(?<!\d)([1-9]\d{14,18})(?!\d)

[BANKCARD]

Passport

(?<![A-Za-z0-9])([EeGg]\d{8}|[Dd]\d{8}|[Pp]\d{7}|[Ss]\d{7,8}|[HhMm]\d{8,10}|[TtLl]\d{8}|1[45]\d{7})(?![0-9A-Za-z])

[PASSPORT]

Social security card

(?<![A-Za-z0-9])([A-Z]\d{7}-?[0-9X])(?![A-Za-z0-9])

[SOCIALID]