by eVolpe Consulting Group

Is data privacy your priority? Get a data-breach proof CRM system! Data Anonymizer is a tool designed to quickly encode data on your CRM instance, while preserving their diversity and relations between records. It allows you to quickly prepare a realistic instance for tests and demonstrations without the risk of leaking someone’s personal information.

Includes a 30 day guarantee
Try it Now

Anonymizer field classes

Introduction

Anonymizer uses several classes to modify module fields. In modules.php config file, each field has assigned a class that will be used. This section will describe their effects.

All classes in package are located in include/DataAnonymizer/FieldAnonymizers.

BaseAnonymizer

interface BaseAnonymizer {

   public function anonymize($field_value);
}

Each class designed to anonymize fields has to implement the BaseAnonymizer interface, consisting of one public function – anonymize($field_value). This function accepts field's current value as $field_value variable, and returns its anonymized value. Additional parameters to classes are passed to their constructors in form of $params array.

List of classes

EmptyAnonymizer

  • Parameters: none

Using this class will completely clear the field.

LoremIpsumAnonymizer

  • Parameters: lorem

This class will overwrite text field with text passed to its constructor in $params[‘lorem’] parameter. It should be used for long text fields like Descriptions – to overwrite short fields, use ShortTextAnonymizer instead.

NIPAnonymizer

  • Parameters: nip

Overwrites field value by text provided with parameter nip.

NameAnonymizer

  • Parameters: list

This is an abstract class, designed to overwrite names and addresses with values from Suite demo data dictionaries. To do so, it uses a helper class called SugarDictionaryFetcher (/custom/include/DataAnonymizer/SugarDictionaryFetcher.php) to grab a random line from target dictionary (which can be passed in $params['list'], or hardcoded in a child class). Anonymizer comes with following classes extending NameAnonymizer:

List of inheriting classes:

  • AccountNameAnonymizer (company_name_array)
  • CityAddressAnonymizer (city_array)
  • CountryAddressAnonymizer (custom list country_array)
  • FirstNameAnonymizer (first_name_array)
  • LastNameAnonymizer (last_name_array)
  • StateAddressAnonymizer (custom list state_array)
  • StreetAddressAnonymizer (street_address_array)

PhoneNoAnonymizer

  • Parameters: offset

This class is designed to overwrite phone numbers by stripping special symbols (e.g. +) and adding offset value passed in $params['offset'] variable to each digit (and performing modulo 10 on each digit to prevent adding extra digits).

ShortTextAnonymizer

  • Parameters: none

This class gets a part of text from short_texts.txt in configuration directory and uses it to overwrite values of text fields. By default, this class takes no more than 100 characters from text, so it should be used for short, generic text fields – for Descriptions and other large fields, use LoremIpsumAnonymizer instead.

ValueAnonymizer

  • Parameters: field_value

This class multiplies numeric values by value passed in $params['multiplier'], which by default will be a randomly generated number in (0.03, 3.3) range.

ZipCodeAnonymizer

  • Parameters: none

It returns random polish zip code (example: 12.345).

Low priority anonymizers

These classes use record’s name as a parameter and as such, they should be used only for low-priority fields. Otherwise, there’s a possibility that the original name of the record will remain in the record after anonymization.

EmailAnonymizer

  • Parameters: name, email_suffix

anonymizer suitecrm record after.png

The class overrides e-mail addresses in record according to formula:

<name.of.record><index><suffix>
  • name.of.record - record name passed by parameter name. All white signs are replaced by dot.
  • index - number of e-mail address in current record (started from 1 and next address increments it).
  • suffix - end of e-mail address (with @) provided with configuration by parameter email_suffix (default: '@evolpe.com').

anonymizer suitecrm list preview.png

WebsiteAnonymizer

  • Parameters: name

takes name of record as $params['name'], replaces all whitespaces with dashes, and returns website address created with www..pl pattern.

Creating custom anonymizer classes

In addition to existing classes, Anonymizer allows to create new field anonymizers according to user’s needs. These new classes should be placed in /custom/include/DataAnonymizer/FieldAnonymizers directory.

Each new Anonymizer must implement the BaseAnonymizer interface or extend an already-existing anonymizer. It must implement or override anonymize($field_value) function and return new field value. If additional parameters are necessary, they have to be added to prepareParams function in RowAnonymizer class, and passed as a part of $params array to the class’ constructor.

Once the class is complete, simply go to modules.php file of your configuration and put your class’ name in class_name parameter of field definition.

Saving Comment Saving Comment...