The DBMS_REDACT
package provides an interface to Oracle Data Redaction, which enables you to mask (redact) data that is returned from queries issued by low-privileged users or an application.
See Also:
Oracle Database Advanced Security Guide regarding using Data Redaction to protect sensitive data
This chapter contains the following topics:
Overview
Security Model
Constants
Operating Procedures
Data Redaction provides a way to define masking policies for an application. Oracle Data Redaction provides functionality to mask (redact) data that is returned from user SELECT
queries. The masking takes place in real time. The Data Redaction policy applies to the querying user, depending on this user's SYS_CONTEXT
values. This redaction process does not require that the queried data be static or unchanging, or for the entire data set to be redacted at one time in an off-line manner. Oracle Database redacts only the data for the rows specified by the user's query, not the data for the entire column. The redaction takes place immediately before the data is returned to the querying user or application.
If the querying user has the EXEMPT REDACTION POLICY
system privilege, redaction will not be performed. If the user does not have the EXEMPT REDACTION POLICY
system privilege, the policy expression will be evaluated in the current user's environment. If the policy expression evaluates to TRUE
, then redaction will be performed, otherwise no redaction will be performed.
You need the EXECUTE
privilege on the DBMS_REDACT
package in order to execute its subprograms. Procedures in the interface are executed with privileges of the current user.
The DBMS_REDACT
package uses the constants shown in the following tables:
Table 121-1 Values for function_type Parameter of DBMS_REDACT.ADD_POLICY
Constant | Value | Type | Description |
---|---|---|---|
|
|
|
No redaction |
|
|
|
Redact to fixed values |
|
2 |
|
Partial redaction, redact a portion of the column data |
|
4 |
|
Random redaction, each query results in a different random value |
|
|
|
Regular expression based redaction |
Table 121-2 Values for action Parameter of DBMS_REDACT.ALTER_POLICY
Constant | Value | Type | Description |
---|---|---|---|
|
|
|
Add a column to the redaction policy |
|
|
|
Drop a column from the redaction policy |
|
|
|
Modify the expression of a redaction policy (the expression evaluates to a |
|
|
|
Modify a column in the redaction policy to change the redaction |
|
|
|
Set a description for the redaction policy |
|
|
|
Set a description for the redaction performed on the column |
The following table presents the relationship between the type of redaction function and its parameters, based on the datatype of the column being redacted. Examples of the various format strings are provided, showing how to perform some commonplace redaction for a string datatype (in this case, a Social Security Number (SSN)), a DATE
datatype, and various examples of redaction for the number datatype.
Table 121-3 Data Redaction Function Types
function_type | function_parameters | Examples |
---|---|---|
|
||
|
||
|
A comma-separated list, containing the following five fields (with no spaces after the commas delimiting the fields):
See Table 121-4, "Format Descriptors with Component Field Names and Delimiters". |
|
|
The |
|
|
The REDACT_PARTIAL_OUTPUT_FORMATfield value |
|
|
The value |
|
|
The value |
|
|
The value |
|
The |
||
|
A comma-separated list, containing the following three fields (with no spaces after the commas delimiting the fields):
See Table 121-4, "Format Descriptors with Component Field Names and Delimiters". |
|
|
||
|
A list, containing the following five fields (concatenated so that there is no space between the fields):
See Table 121-4, "Format Descriptors with Component Field Names and Delimiters". |
|
|
||
|
Table 121-4 Format Descriptors with Component Field Names and Delimiters
Datatype | Format Descriptor for Partial redaction |
---|---|
Character |
|
Number |
|
Datetime |
|
Table 121-5 DBMS_REDACT Package Subprograms
Subprogram | Description |
---|---|
Defines a Data Redaction policy for a table or view |
|
Alters a Data Redaction policy for a table or view |
|
Disables a Data Redaction policy |
|
Drops a Data Redaction policy |
|
Enables a Data Redaction policy |
|
Modifies the default displayed values for a Data Redaction policy for full redaction |
This procedure defines a Data Redaction policy for a table or view.
DBMS_REDACT.ADD_POLICY ( object_schema IN VARCHAR2 := NULL, object_name IN VARCHAR2, policy_name IN VARCHAR2, column_name IN VARCHAR2 := NULL, function_type IN BINARY_INTEGER := DBMS_REDACT.FULL, function_parameters IN VARCHAR2 := NULL, expression IN VARCHAR2, enable IN BOOLEAN := TRUE, regexp_pattern IN VARCHAR2 := NULL, regexp_replace_string IN VARCHAR2 := NULL, regexp_position IN BINARY_INTEGER := 1, regexp_occurrence IN BINARY_INTEGER := 0, regexp_match_parameter IN VARCHAR2 := NULL, policy_description IN VARCHAR2 := NULL, column_description IN VARCHAR2 := NULL);
Table 121-6 ADD_POLICY Procedure Parameters
Parameter | Description |
---|---|
|
Schema owning the table, current user if |
|
Name of table or view to which to add a Data Redaction policy |
|
Name of policy |
|
[Optional] Name of one column to which the redaction policy applies. If you must redact more than one column, use the ALTER_POLICY Procedure to add the additional columns. |
|
Type of redaction function to use. Possible values are: - - - - - If the See Table 121-1, "Values for function_type Parameter of DBMS_REDACT.ADD_POLICY" for an overview of the meanings of these values, and for some examples of their use. |
|
Parameters to the redaction function. The possible values depend on the value of the If the - - - Masking parameters for partial character masking. For character datatypes, a comma-separated list containing these fields:
For number datatypes, a comma-separated list containing these fields:
|
For datetime datatypes, the format is a packed string (no spaces or commas) containing the following sequence of fields. Please note that each field can consist of one or more characters, and the field length depends on whether masking is required. The one-character fields are used to specify that no redaction of that component of the datetime value is to take place. The longer fields indicate a specific time or date to use as the redacted value of that component of the datetime value.
An example is For partial character and number-masking shortcuts, see Oracle Database Advanced Security Guide. |
|
|
Boolean expression for the table or view, using either the |
|
Boolean value that determines whether the Data Redaction policy is enabled on creation. The default value is |
|
Regular expression pattern up to 512 bytes. Use only if the See Oracle Database SQL Language Reference for more information and examples on using regular expression patterns. |
|
Replacement string (up to 4000 characters in length) with up to 500 back-references to subexpressions in the form Use only if the |
|
Integer counting from 1, specifies the position where the search must begin. Use only if the |
|
Use only if the |
|
Changes the default matching behavior, possible values are a combination of 'i', 'c', 'n', 'm', 'x' Use only if the See Oracle Database SQL Language Reference for more information and examples on using regular expression match parameters. |
|
Description of redaction policy |
|
Description of the column being redacted |
ORA-28060
- A Data Redaction policy already exists on this column.
ORA-28061
- This object cannot have a Data Redaction policy defined on it.
ORA-28062
- The policy expression is too long.
ORA-28063
- The policy expression is empty.
ORA-28064
- The type of redaction function is not valid.
ORA-28066
- Invalid column column
ORA-28069
- A Data Redaction policy already exists on this object.
ORA-28073
- The column column_name
has an unsupported datatype.
ORA-28074
- The field
field_name
of the masking parameters is not valid
The field can be any of the following:
REDACT_PARTIAL_INPUT_FORMAT
REDACT_PARTIAL_OUTPUT_FORMAT
REDACT_PARTIAL_MASKCHAR
REDACT_PARTIAL_MASKFROM
REDACT_PARTIAL_MASKTO
REDACT_PARTIAL_DATE_MONTH
REDACT_PARTIAL_DATE_DAY
REDACT_PARTIAL_DATE_YEAR
REDACT_PARTIAL_DATE_HOUR
REDACT_PARTIAL_DATE_MINUTE
REDACT_PARTIAL_DATE_SECOND
See Table 121-3 and Table 121-4 for examples of the field contents and field ordering.
ORA-28075
- The policy expression has unsupported functions
ORA-28076
- An attribute was not specified for SYS_SESSION_ROLES
ORA-28077
- The attribute specified (attribute
) exceeds the maximum length
ORA-28078
- A regular expression parameter is missing or invalid
ORA-28082
- The parameter parameter is invalid (where the possible values are function_parameters
, column_description
, policy_name
and policy_description
)
ORA-28085
- The input and output lengths of the redaction do not match.
See Operating Procedures for more information regarding function types and function parameters with related examples.
Partial redaction policy:
BEGIN DBMS_REDACT.ADD_POLICY( object_schema => 'hr', object_name => 'employees', column_name => 'employee_id', policy_name => 'mask_emp_id_nums', function_type => DBMS_REDACT.PARTIAL, function_parameters => '7,1,5', expression => '1=1'); END;
Full redaction policy:
BEGIN DBMS_REDACT.ADD_POLICY( object_schema => 'hr', object_name => 'employees', column_name => 'employee_id', policy_name => 'mask_emp_ids', function_type => DBMS_REDACT.FULL, expression => 'SYS_CONTEXT(''SYS_SESSION_ROLES'',''CLERK'') = ''FALSE'''); END;
This procedure alters an existing Data Redaction policy for a table or view in one or more of the following ways:
By changing the policy expression
By changing the type of redaction for a specified column
By changing the parameters to the redaction function for a specified column
By adding a column to the redaction policy (the redaction type and any parameters must be specified).
By removing a column from the redaction policy
DBMS_REDACT.ALTER_POLICY ( object_schema IN VARCHAR2 := NULL, object_name IN VARCHAR2, policy_name IN VARCHAR2, action IN BINARY_INTEGER := DBMS_REDACT.ADD_COLUMN, column_name IN VARCHAR2 := NULL, function_type IN BINARY_INTEGER := DBMS_REDACT.FULL, function_parameters IN VARCHAR2 := NULL, expression IN VARCHAR2, regexp_pattern IN VARCHAR2 := NULL, regexp_replace_string IN VARCHAR2 := NULL, regexp_position IN BINARY_INTEGER := 1, regexp_occurrence IN BINARY_INTEGER := 0, regexp_match_parameter IN VARCHAR2 := NULL, policy_description IN VARCHAR2 := NULL, column_description IN VARCHAR2 := NULL);
Table 121-7 ALTER_POLICY Procedure Parameters
Parameter | Description |
---|---|
|
Schema owning the table, current user if |
|
Name of table or view to which to alter a Data Redaction policy |
|
Name of policy limited to 30 bytes |
|
Action to take. For more information see Table 121-2, "Values for action Parameter of DBMS_REDACT.ALTER_POLICY". |
|
[Optional] Name of one column to which the redaction policy applies. |
|
Type of redaction function to use. Possible values are: - - - - - If the See Table 121-1, "Values for function_type Parameter of DBMS_REDACT.ADD_POLICY" for an overview of the meanings of these values, and for some examples of their use. |
|
Parameters to the redaction function. The possible values depend on the value of the If the - If the - If the - If the
For number datatypes, a comma-separated list containing these fields:
|
For datetime datatypes, the format is a packed string (no spaces or commas) containing the following sequence of fields. Please note that each field can consist of one or more characters, and the field length depends on whether masking is required. The one-character fields are used to specify that no redaction of that component of the datetime value is to take place. The longer fields indicate a specific time or date to use as the redacted value of that component of the datetime value.
An example is For partial character and number-masking shortcuts, see Oracle Database Advanced Security Guide. |
|
|
Boolean expression for the table or view, using either the |
|
Regular expression pattern up to 512 bytes. Use only if the See Oracle Database SQL Language Reference for more information and examples on using regular expression patterns |
|
Replacement string (up to 4000 characters in length) with up to 500 back-references to subexpressions in the form Use only if the |
|
Integer counting from 1, specifies the position where the search must begin. Use only if the |
|
Use only if the |
|
Changes the default matching behavior, possible values are a combination of 'i', 'c', 'n', 'm', 'x' Use only if the See Oracle Database SQL Language Reference for more information and examples on using regular expression match parameters. |
|
Description of redaction policy |
|
Description of the column being redacted |
ORA-28062
- The policy expression is too long.
ORA-28063
- The policy expression is empty.
ORA-28064
- The type of redaction function is not valid.
ORA-28066
- Invalid column column
ORA-28067
- Missing or invalid column name
ORA-28068 -
The object object
does not have a Data Redaction policy.
ORA-28070
- The column column
does not have a Data Redaction policy.
ORA-28071
- The action is not valid.
ORA-28072
- The specified policy name is incorrect.
ORA-28073
- The column column_name
has an unsupported datatype.
ORA-28074
- The field field_name
of the masking parameters is not valid
The field can be any of the following:
REDACT_PARTIAL_INPUT_FORMAT
REDACT_PARTIAL_OUTPUT_FORMAT
REDACT_PARTIAL_MASKCHAR
REDACT_PARTIAL_MASKFROM
REDACT_PARTIAL_MASKTO
REDACT_PARTIAL_DATE_MONTH
REDACT_PARTIAL_DATE_DAY
REDACT_PARTIAL_DATE_YEAR
REDACT_PARTIAL_DATE_HOUR
REDACT_PARTIAL_DATE_MINUTE
REDACT_PARTIAL_DATE_SECOND
See Table 121-3 and Table 121-4 for examples of the field contents and field ordering.
ORA-28075
- The policy expression has unsupported functions.
ORA-28076
- An attribute was not specified for SYS_SESSION_ROLES.
ORA-28077
- The attribute specified (attribute
) exceeds the maximum length.
ORA-28078
- A regular expression parameter is missing or invalid.
ORA-28082
- The parameter parameter is invalid (where the possible values are function_parameters
, column_description,
policy_name
and policy_description
)
ORA-28085
- The input and output lengths of the redaction do not match.
See Operating Procedures for more information regarding Function Types and Function Parameters with related examples.
This procedure disables a Data Redaction policy.
DBMS_REDACT.DISABLE_POLICY ( object_schema IN VARCHAR2 := NULL, object_name IN VARCHAR2, policy_name IN VARCHAR2);
ORA-28068
- The object object
does not have a Data Redaction policy.
ORA-28072
- The specified policy name is incorrect.
ORA-28080
- The policy was already disabled.
This procedure drops a Data Redaction policy by removing a masking policy from the table or view.
DBMS_REDACT.DROP_POLICY ( object_schema IN VARCHAR2 := NULL, object_name IN VARCHAR2, policy_name IN VARCHAR2);
ORA-28068
- The object object
does not have a Data Redaction policy.
ORA-28072
- The specified policy name is incorrect.
This procedure re-enables a Data Redaction policy.
DBMS_REDACT.ENABLE_POLICY ( object_schema IN VARCHAR2 := NULL, object_name IN VARCHAR2, policy_name IN VARCHAR2);
ORA-28068
- The object object
does not have a Data Redaction policy.
ORA-28071
- The action is not valid.
ORA-28072
- The specified policy name is incorrect.
ORA-28079
- The policy was already enabled.
This procedure modifies the default displayed values for a Data Redaction policy for full redaction.
DBMS_REDACT.UPDATE_FULL_REDACTION_VALUES ( number_val IN NUMBER := NULL, binfloat_val IN BINARY_FLOAT := NULL, bindouble_val IN BINARY_DOUBLE := NULL, char_val IN CHAR := NULL, varchar_val IN VARCHAR2 := NULL, nchar_val IN NCHAR := NULL, nvarchar_val IN NVARCHAR2 := NULL, date_val IN DATE := NULL, ts_val IN TIMESTAMP := NULL, tswtz_val IN TIMESTAMP WITH TIME ZONE := NULL, blob_val IN BLOB := NULL, clob_val IN CLOB := NULL, nclob_val IN NCLOB NULL);
Table 121-11 UPDATE_FULL_REDACTION_VALUES Procedure Parameters
Parameter | Description |
---|---|
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |
|
Modifies the default value for columns of the |