Skip to content

vmunisamy/mask-sobject

 
 

Repository files navigation

Mask SObject Framework

This framework allow users to configure some data masking operations on Sandbox environments.

Disclaimer

Mask SObject Framework is not an official Salesforce product, it has not been officially tested or documented by Salesforce.

How Do You Configure SObjects And Fields to Mask ?

The configuration is based on two objects:

  • MaskSObject__c : object to mask with options such as the order sequence and the where clause
  • MaskSObjectField___c : field to mask and the option of masking (erase, randomize ...)

SObjedt config

To assign required pset run following command:

sfdx force:apex:execute -f scripts/assignPset.apex

If you want to insert demo data, please run following command:

sfdx force:apex:execute -f scripts/importDemo.apex

How To Run Data Masking ?

  • With execute anonymous and the following code
    • To run anonymisation on all objects
MaskSObjectUtils.executeBatch('%');
  • To run on a particular SObject
MaskSObjectUtils.executeBatch('Contact');
  • When creating / refreshing a sandbox:

Configure post copy class

WARNING: if you choose this option, you need a Partial Copy Sandbox or a Full Copy Sandbox and data configuration on Production.

Actions

  • Randomize:

    • Generate a X char String based on Crypto.generateAesKey(128); method where X is the number of characters of the input to anonymize.

      'SALESFORCE.COM FRANCE' => 'iih5e2UT0qGZ8fJaNCbTT'

  • Random Luhn number

    • Generate a number considered as valid by Luhn algorithm Luhn algorithm, the number of characters to generate is calculated from the original input field value.
  • Obfuscate:

    • Replace and lowercase following chars (customizable in settings) {'a', 'e', 'i', 'o', '1', '2', '5', '6'}; by 'x'

      'SALESFORCE.COM FRANCE' => 'sxlxsfxrcx.cxm frxncx'

  • Erase:

    • 'SALESFORCE.COM FRANCE' => ''

  • Replace:

    • Actions Types:
      • Hardcoded: You must insert an hardocoded value in Value__c field to replace the current field value with hardcoded one.
      • Dictionary:
        • You can choose different dictionary fields to replace the current value Firstname, Lastname, Fullname, Email, Company Name, Street.
        • A random line from MaskSObjectDictionary.json file will be selected to fill the field.

      Dictionary Firstname : 'Thomas' => 'Corie', Dictionary Fullname : 'John Doe' => 'Corie Joberne' ...

Data Dictionary

The data dictionary is stored in MaskSObjectDictionary.json StaticResource. You can edit this file and replace the current values with yours if you need more common names for a particular country for example.

Website used to generate the data https://www.mockaroo.com/

Fields specificity

  • Standard Email
  • Standard Phone
    • We mask only the part after the two first char

      '0612345678' => '0600340078'

Configure Settings

You can customize some options by editing MaskSObjectSettings__mdt Default Custom Metadata

  • Allow execution on prod : enable this option to be able to run the batch on PROD (otherwise soql query returns no rows)
  • Configure the number of digits to preserve in standard Phone fields.

Customize options

Deploy to Salesforce

Checkout the repo and deploy it with sfdx:

sfdx force:source:deploy -p force-app

Use GitHub Salesforce Deploy Tool:

Deploy to Salesforce

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Apex 99.2%
  • JavaScript 0.8%