Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBZ-29 Changed MySQL connector to be able to hide, truncate, and mask specific columns #38

Merged
merged 1 commit into from May 12, 2016

Conversation

rhauch
Copy link
Member

@rhauch rhauch commented May 11, 2016

Changes the MySQL connector to use regular expressions in the database and table blacklist/whitelists, and adds support for excluding, truncating, and masking certain columns.

Using regular expression patterns

Changed the MySQL connector to use comma-separated lists of regular expressions for the database and table whitelist/blacklists. Literals are still accepted and will match fully-qualified table names, although the . character used as a delimiter is also a special character in regular expressions and therefore may need to be escaped (e.g., preceded by a double backslash (\\) or surrounded by square brackets) to more carefully match fully-qualified table names.

Excluding columns

Added several new configuration properties for the MySQL connector that instruct it to hide, truncate, and/or mask certain columns. The properties' values are all lists of regular expressions or literal fully-qualified column names. For example, the following configuration property:

column.blacklist=server.users.picture,server.users.other

will cause the connector to leave out of change event messages for the server.users table those fields that correspond to the picture and others columns.

Excluding columns in change events can help prevent dissemination of sensitive information.

Masking columns

An alternative to excluding/blacklisting columns is masking them. The following configuration property:

column.mask.with.10.chars=server\\.users\\.(\\w*email)

will cause the connector to mask in the change event messages for the server.users table all values for columns whose name ends in email. The values will be replaced in this case with a constant string of 10 asterisk (*) characters, even when the email value is null. Although this example used a mask of 10 characters, any positive length can be specified; separate properties should be used when different mask lengths are required.

Masking columns in change events can help prevent dissemination of sensitive information.

Truncating columns

It is also possible to truncate string values of specific columns to reduce the potential size of change events. The following configuration property:

column.truncate.to.120.chars=server[.]users[.](description|biography)

is an example that shows how to configure the connector to truncate to at most 120 characters the values of the description and biography columns in the change event messages for the server.users table. Although this example used a limit of 120 characters, any positive length can be specified; separate properties should be used when different lengths are required. Note how the . delimiter in the fully-qualified names is escaped since that same character is a special character in regular expressions; this escaping of the . characters may not be required in all cases, but it is recommended.

… specific columns

Changed the MySQL connector to use comma-separated lists of regular expressions for the database
and table whitelist/blacklists. Literals are still accepted and will match fully-qualified table names,
although the '.' character used as a delimiter is also a special character in regular expressions and
therefore may need to be escaped with a double backslash ('\\') to more carefully match fully-qualified
table names.

Added several new configuration properties for the MySQL connector that instruct it to hide,
truncate, and/or mask certain columns. The properties' values are all lists of regular expressions
or literal fully-qualified column names. For example, the following configuration property:

    column.blacklist=server.users.picture,server.users.other

will cause the connector to leave out of change event messages for the `server.users` table those
fields that correspond to the `picture` and `others` columns. This capability can be used to
This capability can be used to prevent dissemination of sensitive information in the change event
stream.

An alternative to blacklisting is masking. The following configuration property:

    column.mask.with.10.chars=server\\.users\\.(\\w*email)

will cause the connector to mask in the change event messages for the `server.users` table
all values for columns whose name ends in `email`. The values will be replaced in this case with
a constant string of 10 asterisk ('*') characters, even when the email value is null.
This capability can also be used to prevent dissemination of sensitive information in the change event
stream.

Another option is to truncate string values for specific columns. The following configuration
property:

    column.truncate.to.120.chars=server[.]users[.](description|biography)

will cause the connector to truncate to at most 120 characters the values of the `description` and
`biography` columns in the change event messages for the `server.users` table. Although this example
used a limit of 120 characters, any positive length can be specified; separate properties should
be used when different lengths are required. Note how the '.' delimiter in the fully-qualified names
is escaped since that same character is a special character in regular expressions. This capability
can be used to reduce the size of change event messages.
@rhauch rhauch merged commit 18995ab into debezium:master May 12, 2016
@rhauch rhauch deleted the dbz-29 branch May 13, 2016 17:06
xinbinhuang pushed a commit to xinbinhuang/debezium that referenced this pull request Feb 4, 2023
bdbene pushed a commit to bdbene/debezium that referenced this pull request Jun 23, 2023
bdbene pushed a commit to bdbene/debezium that referenced this pull request Jun 23, 2023
@xinbinhuang xinbinhuang mentioned this pull request Jun 27, 2023
methodmissing pushed a commit to methodmissing/debezium that referenced this pull request Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant