The DBMS_REDACT package enables the redacting or masking of data returned by a query. The
DBMS_REDACT package provides a procedure to create policies, alter policies, enable policies, disable policies, and drop policies. The procedures available in the
DBMS_REDACT package are listed in the following table.
|
|
|
|
ADD_POLICY(object_schema, object_name, policy_name, policy_description, column_name, column_description, function_type, function_parameters, expression, enable, regexp_pattern, regexp_replace_string, regexp_position, regexp_occurence, regexp_match_parameter, custom_function_expression)
|
|
|
|
ALTER_POLICY(object_schema, object_name, policy_name, action, column_name, function_type, function_parameters, expression, regexp_pattern, regexp_replace_string, regexp_position, regexp_occurence, regexp_match_parameter, policy_description, column_description, custom_function_expression)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE_FULL_REDACTION_VALUES(number_val, binfloat_val, bindouble_val, char_val, varchar_val, nchar_val, nvarchar_val, datecol_val, ts_val, tswtz_val, blob_val, clob_val, nclob_val)
|
|
|
|
The DBMS_REDACT package uses the constants and redacts the column data by using any one of the data redaction types. The redaction type can be decided based on the
function_type parameter of
dbms_redact.add_policy and
dbms_redact.alter_policy procedure. The below table highlights the values for
function_type parameters of
dbms_redact.add_policy and
dbms_redact.alter_policy.
|
|
|
|
|
|
Specifies the input format. Enter V for each character from the input string to be possibly redacted. Enter F for each character from the input string that can be considered as a separator such as blank spaces or hyphens.
|
Consider 'VVVFVVFVVVV,VVV-VV-VVVV,X,1,5' for masking first 5 digits of SSN strings such as 123-45-6789, adding hyphen to format it and thereby resulting in strings such as XXX-XX-6789.
|
|
Specifies the output format. Enter V for each character from the input string to be possibly redacted. Replace each F character from the input format with a character such as a hyphen or any other separator.
|
The field value VVV-VV-VVVV can be used to redact SSN strings into XXX-XX-6789 where X comes from REDACT_PARTIAL_MASKCHAR field.
|
|
|
The value X for redacting SSN strings into XXX-XX-6789.
|
|
Specifies which V within the input format from which to start the redaction.
|
The value 1 for redacting SSN strings starting at the first V of the input format of VVVFVVFVVVV into strings such as XXX-XX-6789.
|
|
|
|
|
|
|
‘9, 1, 5’ for redacting the first five digits of the Social Security Number 123456789 into 999996789.
|
|
|
|
|
|
|
‘m’ redacts the month. To mask a specific month, specify ‘m#’ where # indicates the month specified by its number between 1 and 12.
|
|
|
‘d’ redacts the day of the month. To mask with a day of the month, append 1-31 to a lowercase d.
|
|
|
‘y’ redacts the year. To mask with a year, append 1-9999 to a lowercase y.
|
|
|
‘h’ redacts the hour. To mask with an hour, append 0-23 to a lowercase h.
|
|
|
‘m’ redacts the minute. To mask with a minute, append 0-59 to a lowercase m.
|
|
|
‘s’ redacts the second. To mask with a second, append 0-59 to a lowercase s.
|
|
|
|
|
|
|
|
|
Example: The number 123-45-6789 becomes XXX-XX-6789.
|
|
|
|
Example: The number 123-45-6789 becomes 123-45-XXXX.
|
|
|
|
Example: The number 123-45-6789 becomes XXX-XX-XXXX.
|
|
|
|
Example: The number 123456789 becomes 999996789.
|
|
|
|
Example: The number 123456789 becomes 123459999.
|
|
|
|
Example: The number 123456789 becomes 999999999.
|
|
|
|
|
|
|
|
|
|
|
|
Example: 1234 5678 9000 2358 becomes ****-****-****-2358.
|
|
|
|
Example: Redacts all date to 01-JAN-2000.
|
|
|
|
|
|
|
|
Example: The credit card number 1234 567890 34500 becomes **** ****** 34500.
|
|
|
|
Example: The credit card number 1234 567890 34500 becomes 0000 000000 34500.
|
|
|
|
Example: 123-456-789 becomes ***-***-789.
|
|
|
|
|
|
|
|
|
|
|
|
Example: The credit card number 1234-5678-9000-4671 becomes ****-****-****-4671.
|
|
|
|
Example: The credit card number 1234567890004671 becomes 0000000000004671.
|
|
|
|
Example: 123-456-7890 becomes 123-XXX-XXXX.
|
|
|
|
|
|
|
|
|
|
|
|
Example: NY 22 01 34 D becomes NY XX XX XX D.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The regexp_replace_string parameter to be used is RE_REDACT_IP_L3 that replaces the last section of an IP address with 999 and indicates it is redacted.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example: The credit card number 1234 5678 9000 2490 becomes 1234 56XX XXXX 2490.
|
|
|
|
Replaces the data with a single X character for each matching pattern as specified by setting the regexp_pattern parameter with the RE_PATTERN_ANY_DIGIT format.
Example: The credit card number 1234 5678 9000 2490 becomes XXXX XXXX XXXX XXXX.
|
|
|
|
Replaces the data with a single 1 digit for each of the data digits as specified by setting the regexp_pattern parameter with the RE_PATTERN_ANY_DIGIT format.
Example: The credit card number 1234 5678 9000 2490 becomes 1111 1111 1111 1111.
|
|
|
|
Example: The phone number 123-444-5900 becomes 123-XXX-XXXX.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example: The IP address 172.0.1.258 becomes 172.0.1.999, which is an invalid IP address.
|
|
|
|
Example: 123456789062816 becomes **********62816.
|
|
|
|
Example: 8749012678345671 becomes ************5671.
|
The following table shows the regexp_match_parameter values that you can use during
REGEXP based redaction which lets you change the default matching behavior of a function.
Note: If you create a redaction policy based on a numeric type column, then make sure that the result after redaction is a number and accordingly set the replacement string to avoid runtime errors.
Note: If you create a redaction policy based on a character type column, then make sure that a length of the result after redaction is compatible with the column type and accordingly set the replacement string to avoid runtime errors.
The add_policy procedure creates a new data redaction policy for a table.
When set to TRUE, the policy is enabled upon creation. The default is set as
TRUE. When set to
FALSE, the policy is disabled but the policy can be enabled by calling the
enable_policy procedure.
Note: For more information on
constants, function_parameters, or
regexp (regular expressions) see,
Using DBMS_REDACT Constants and Function Parameters.
The custom_function_expression is applicable only for the
CUSTOM redaction type. The
custom_function_expression is a function expression that is, schema-qualified function with a parameter such as
schema_name.function_name (argument1, …)that allows a user to use their redaction logic to redact the column data.