Masking conditioned by data from related entities

Configuring masking conditioned by data from related entities involves retrieving relevant data from the related entity, defining the relationship between the table being masked and the related entity, and the conditions for masking.

Retrieving relevant data from the related entity and defining the relationship between the table being masked and the related entity is done within the Handling strategy within the table masking activity.

Masking conditions are defined by conditional masking.

The related table does not need to be imported into the Portal using the "Create data source / create environment" functionality and into Designer using the "Import Portal Data" functionality. The same connection string is used for the table being masked and for the related table.

Example

First names and last names in the Customer table should be masked according to the cities stored in the Address table. IT only affects customers from that city

Customers that are from a city Blackstone should be masked only.

Preconditions:

  • BizDataX Package (Visual Studio project) is created
  • Ekobit.BizDataX.Databases.MSSQL NuGet package is installed
  • table Customer is imported on Portal and in Designer. Import of the Address table is optional
  • BizDataX Package (Visual Studio project) is built

Steps

  1. From the Solution Explorer open the Package.xaml file.
  2. Delete the HelloWorldScope step created by default.
  3. Drag the Step activity from the Toolbox into the opened Package.xaml file.
  4. Drag the Customer_Activity into the Step activity. A Masking engine with a Customer masking iterator and a Handler strategy is created.
  5. Modify Handler property. Default value is: Datasources.Demo_data_source.dbo.Customer.Handle.WithBulk().
    Modified value should be: Datasources.Demo_data_source.dbo.Customer.Handle.WithReader().Join("Select City,CustomerID from dbo.Address","{table}.CustomerID={related}.CustomerID").WithBulk()
    where:
    Select City,CustomerID from dbo.Address is select statement used to retreive related data, and
    {table}.CustomerID={related}.CustomerID is join criteria.
    If needed, this handler expression can be extended for other purposes. More details can be found at Fluent Handler API page.
  6. Drag the Condition activity from the Toolbox into the Customer masking iterator.
  7. Drag the Condition branch activity from the Toolbox into the Condition into the Branch(es).
  8. Write Condition property. Condition should be: X=>X.RelatedSingle().AsStringOrDefault("City")=="Blackstone" which means that only customers from a city Blackstone should be affected by masking. More details about conditional masking can be found at Condition page.
  9. Drag the Masking block from the Toolbox into the Condition branch.
  10. Drag the Pick first name from list from the Toolbox into the Masking block.
  11. Drag the Pick last name from list from the Toolbox into the Masking block.
  12. Start the data masking by selecting Debug -> Start Without Debugging (or CTRL+F5).
  13. Check the results in the database.

Complete example workflow
Figure 1: Complete example workflow