Description

The FileMaskMultiBlockReceiver will mask targeted values within a given document using Synthetic Data Replacement (SDR). The document may contain one or more blocks (as a set of lines that make up one report) where each block contains a number of lines 1 to N, where N is the same number of lines within each report. 


In this Article


Parameters

The following parameters may be configured for the FileMaskMultiBlockReceiver. Items with an asterisk* are required. 

  • sourceFileName* - Defines the name of the file to mask. 
  • sourcePath* - Defines the base path where the source file to be masked is located. 
  • sourceSubDirectory - Defines an optional subdirectory under sourcePath where the source file is located. 
  • destPath* - Defines the base path where the clean masked file will be stored. 
  • destSubDirectory - Defines an optional subdirectory under destPath where the clean masked file will be stored. 
  • linesPerBlock* - Defines the number of lines within a block of lines before the next block of lines starts within the file. 
  • skipTopLineCount - Defines the number of lines to skip for masking from the top.
  • skipBottomLineCount - Defines the number of lines to skip for masking from the bottom. 
  • skipUnmaskedLines - Defines whether to skip the unmasked line from your destination file or not.
  • removeOnDisable - Defines whether to remove the disabled line from your destination file or not.


Receiver Attribute Property Keys

The Receiver defines four property keys that can be modified on any of its associated Domain Attributes:

  • include - Defines whether the Domain Attribute will be used for masking.
  • lineNumber - Defines the line number within a block of lines where the target is located. 
  • startPosition - Defines the column position within a given line where the target starts. 
  • length - Defines the length of the target.


Sample Story

A tester needs to mask sensitive data values within a Fixed File. The FileMaskMultiBlockReceiver can be used to mask sensitive values when record information exists on each line in a file or on multiple lines (multiblock).

Four examples will be shown below to show how to use this receiver for the following: 

  1. Single Block File Mask - Record information is on a single line in the file.
  2. Single Block with Header/Footer - Record information is on a single line in the file, and the Header/Footer will be included in the destination file.
  3. Header/Footer not in Destination File - Record information is on a single line, and Header/Footer will not be in the destination file.
  4. MultiBlockFile Mask- Record information exists on multiple lines within the file.
  5. removeOnDisable - Not all Records are masked. This example shows how to only include certain records within the destination file. 


Example 1: Single Block File Mask

For this example, the username for each record will need to be masked with synthetically generated data. The information resides on a single line within the file. 



Step 1: Add a Domain with the Attribute(s) to be Masked

For this example, a Mask Domain has been added with a username Attribute.



Note: For more information on adding Domains to a Project Verison of a given Project, click here.


Step 2: (Optional) Assign or Modify the Generator

The TreeNameGen Generator has been assigned to the username Attribute. For this example, the username will be masked with the names of trees.



Note: For more information on assigning and modifying Generators for a Domain, click here.


Step 3: Remove the id Attribute from the Domain

The id Attribute is not needed when using the FileMaskMultiBlockReceiver to mask values within a source file. Use the Trash Can icon to remove the id Attribute from the Domain.




Step 4: Change the loopCount for the Domain

The loopCount will need to match the number of records within the file. 



Note: For more information on changing the loopCount for a Domain, click here.


Step 5: Add the FileMaskMultiBlockReceiver to the Domain

The FileMaskMultiBlockReceiver will need to be assigned to the Domain.



Note: For more information on adding a Receiver to a Domain, click here


Step 6: Configure the FileMaskMultiBlockReceiver Parameters

The following Parameters have been configured in this example: 

  • sourceFileName - The name of the source file where data is being masked (e.g., Customer.txt).
  • destSubDirectory - The destination directory of the output file (e.g., Destination). Note: The original file will be overwritten if no destination subdirectory is entered. 
  • linesPerBlock - Defines the number of lines within a block. For this example, information for each record is on one line, and the value has been set to "1."


Step 7: Configure the Receiver Attributes Property Keys

The lineNumber Property Key has been set to "1" for one line per block.



The startPosition Property Key has been set to "37" and represents the starting position on the line where the username will be masked in the file.



This can be determined by placing the cursor at the starting position of the value to be masked within the file. 



The length Property Key has been set to "20" and represents the fixed length of the value to be masked.


 

Step 8: Create a Scenario for the Domain

A Scenario will need to be created for the Domain. In this example, a Quick Scenario was created. 



Note: For more information on creating a Quick Scenario, click here


Step 9: Download and Run the Scenario

Use the Cloud icon within the Project Dashboard or Domain Dashboard to download the Scenario to your local machine.



Step 10: Use the genrocket -r Command to run the Scenario


Source File

The original file is shown below: 



Destination File

The usernames have been masked with synthetically generated data in the destination file. The original value has been masked with tree names.


Example 2: Single Block File Mask with Header/Footer

For this example, the record information is still in a single line; however, the file has a header and a footer that does not have a value to mask. The username will still be masked, and the project setup is the same.


FileMaskMulitBlockReceiver Parameters

To skip a header or footer within the file during masking, FileMaskMultiBlockReceiver Parameters will need to be modified:

  • skipTopLine - Enter a value for the number of lines from the top of the file to skip (not mask).
  • skipBottomLine - Enter a value for the number of lines from the bottom of the file to skip (not mask).


Source File

The source file contains a header and footer:


Destination File

The username is still masked with synthetically generated data in the output file, but the header and footer were skipped.


Example 3: Header/Footer not in Destination File

For this example, the header/footer in the source file will not be included in the destination file. Record information is still in a single line. The username will still be masked, and the project setup is the same. 


If the Header/Footer should not be in the destination file, then the skipUnmaskedLines Parameter will also need to be set to "true" within the Receiver Parameters.



The destination file will appear as shown below: 



Example 4: MultiBlock File Mask

Record information may exist in multiple lines of a fixed file (multiblock). This example shows how to set up a Project to mask values when record information is on multiple lines, and more than one set of values will need to be masked. 


The source file will appear as shown below. Items in green will need to be masked for each record in the file. 



Step 1: Change the loopCount for the Domain

This source file only has ten records. The loopCount will need to be changed to "10."



Step 2: Add Attributes for each Masked Value

An Attribute will need to be added for each set of values to be masked in the file. For this example, an additional Attribute titled "accountNumber" will be added and is used to mask the customer's account number in the destination file. 



Step 3: Assign a Generator or Modify the Assigned Generators Parameters

A Generator will automatically be assigned to the new Attribute. It may need to be replaced with another Generator, or its Parameters may need to be modified. 


For this example, a new Generator will be assigned: RandomStringGen Generator. This Generator will create a random string of ten letters and numbers.


FileMaskMultiBlockReceiver Parameters

For this example, the linesPerBlock Parameter will need to be set to "2" within the FileMaskMultiBlockReciever. This is because each record's information is in two lines within the file. 



Receiver Attribute Property Keys

The lineNumber Attribute's Property Keys will need to be configured within the FileMaskMultiBlockReceiver. For this example, the following values have been entered (see screenshot): 



Source File


Destination File

The data values highlighted in green have been masked for each record in the file: 



Example 5: removeOnDisable

It is possible to only mask records with certain values rather than all records within the source file. The removeOnDisable Parameter defines whether to remove the disabled line from your destination file or not. This parameter determines if disabled lines (unmasked) lines are included or not included within the destination file. 


Note: This example builds on the Project Setup outline in Example 1.


For example, in the file below, only records that do not have a middle initial of 'A' will be included in the destination file. The username will be masked for each of the included records. 



Step 1: Add an Attribute for the Evaluation Logic

An Attribute will need to be added and set up to contain the logic for determining what records will be included in the destination file. 


The value of this particular Attribute will be used to decide whether each record will go into the destination file or not. For this example, it has been named middleInitialLogic.



Step 2: Replace the Assigned Generator with ListFixedFileGen Generator and Configure Parameters

The default assigned generator will need to be replaced with the ListFixedFileGen Generator. These Parameters will need to be altered as well for this example: 

  • filePath - The path where the source file resides (e.g., #{resource.output.directory})
  • fileName - Enter the name of the source file (e.g., Customer.txt).
  • startPosition - Enter the start position of the value to be evaluated within the source file. For this example, it is the middle initial, which starts at position 50 in the source file.
  • setLoop - Set to "true."


Next, link a SwitchGen Generator to the Attribute and configure its Parameters.


The Parameter values changed for this example include the following: 

  • switch - References the value generated by gen1 (ListFixedFileGen).   
  • default - true  
  • caseList - A
  • actionList - false



Step 4: Reference the Attribute within the Enable/Disable Receiver for the Scenario

Within a Scenario, users can turn on and off the Receiver. The Receiver must reference an Attribute to do so. Any Attribute can be referenced that is generating a 'true' or 'false' value. 


Select the Scenario within the Project or Domain Dashboard



Within the Scenario Dashboard, click on the Receiver Name located in the Scenario Domain Receivers Pane.



Then double click to add a reference. 



Click on the Plus (+) for an Attribute. Then click Save to save the change.



For this example, the middleInitialLogic Attribute will be referenced. If 'true,' the record will be included in the destination file. If 'false,' it will not be included.  



Step 5: Enter Values for middleInitialLogic Attribute Property Keys

Since a new Attribute has been added, changes will need to be made to the Attribute's Property Keys for the Receiver. The following Property Key values have been changed:

  • include - false
  • lineNumber - 1
  • startPosition - 0
  • length - 0



Step 6:  Set skipTopLineCount and skipBottomLineCount to Zero

Within the FileMaskMultiBlockReciever's Parameters, the following two Parameters will need to be set to "0."



Step 7: Enable the removeOnDisable Parameter for the FixedFileMultiBlockReceiver.

When this Parameter is enabled, disabled rows should be removed and not be included in the destination file.



Source File


Destination File