Skip to content

Running an Algorithm Using the SDK Tools

It will often be more convenient to use the SDK utilities to test an algorithm since this avoids the need to install or update your plugin, create masking inventory, and execute jobs on the Delphix Masking Engine. This can be done interactively using maskApp, or entirely from the command line using maskScript.

Using maskApp to Test an Algorithm

The maskApp application is interactive and may be launched with no parameters from the shell:

$ maskApp

After a moment, the application will print a banner and prompt for input. Currently, the only sub-command supported is mask. In order to use this command, you'll need to know the location of the plugin JAR file on the filesystem.

MASKING-APP:> mask -j <plugin_jar_location>

You will be prompted to select an algorithm. This example runs maskApp in proj_dir and uses the JAR file created with the Create a New Project workflow:

MASKING-APP:> mask -j build/libs/demoProject.jar
/Users/******/demo-proj/build/libs/demoProject.jar
Loaded plugin demoProject version 1.0.0 (API version: 1.0.0) from [/Users/******/demo-proj/build/libs/demoProject.jar]
13:17:00.707 [main] INFO  global - Loaded plugin demoProject: Plugin {'embeddedName': 'demoProject', 'version': '1.0.0', 'author': 'Delphix Dev', 'apiVersion': '1.0.0'}
Framework:
* [0] Clobber
  [1] SampleAlgorithm
Select an algorithm framework: 0
Instance:
* [0] demoProject:Clobber
Select an instance of algorithm framework: Clobber: 0
Selected algorithm: com.delphix.demo.Clobber(Clobber) instance: demoProject:Clobber, data type: STRING
Input value to be masked('null' for null, 'doneMasking' to finish): Test1
Masked value: TTTTT
Input value to be masked('null' for null, 'doneMasking' to finish): test2
Masked value: ttttt
Input value to be masked('null' for null, 'doneMasking' to finish): 1 more test
Masked value: 11111111111
Input value to be masked('null' for null, 'doneMasking' to finish):

When you invoke the mask sub-command, you will first be presented with a list of possible frameworks (aka. Algorithm Components) to choose from. These correspond with the Java classes that implement the MaskingAlgorithm interface in the plugin file. Once you have selected a framework, you will be presented with a list of each pre-defined instance to choose from. If the algorithm supports creating new instances, that option will be present as well. Once an instance is selected, you're ready to enter test values and see the masked result.

Note

In order to be usable, each class that implements MaskingComponent must also be listed in the appropriate service description file. Refer to this section for details.

The selection marked with a star is the default selection; you may always press return at the prompt to make the default selection.

Note

When a Multi-Column algorithm is selected, the prompt will contain the order to provide the input values in. They should be placed on a single row, separated by a comma.

Enter CSV-formatted values for the following columns in the following order: date1(LOCAL_DATE_TIME), date2(LOCAL_DATE_TIME)

Missing Algorithms

If an algorithm seems to be missing from the list, or an algorithm's behavior does not seem to match the latest version of the code, it may be necessary to rebuild the plugin JAR:

$ cd <proj_dir>; ./gradlew jar

Running an Algorithm Using maskScript

Algorithms may be also be tested using the SDK maskScript. The maskScript utility is non-interactive, which lets you conveniently process input files using a masking algorithm. Each input line is considered a separate value to be masked. The algorithm framework and instance are selected using command-line options. This example uses the "Redaction X" algorithm instance from the Sample Algorithm plugin. This plugin can be built using the process described here.

Create a small sample input file:

$ echo "Adam
Amy
Brandon" > test_input.txt

Mask each line of the file to standard output:

$ cat test_input.txt | maskScript mask -j algorithm/build/libs/algorithm.jar -n "Sample Plugin:Redaction Z"
Jun 19, 2020 1:51:54 PM com.delphix.masking.api.provider.LogService info
INFO: Loaded plugin Sample Plugin: Plugin {'embeddedName': 'Sample Plugin', 'version': '1.0.0', 'author': 'Delphix', 'apiVersion': '1.0.0'}
ZZZZ
ZZZ
ZZZZZZZ
Jun 19, 2020 1:51:54 PM com.delphix.masking.api.provider.LogService info
INFO: StringRedaction: Masked a total of 3 values

Note

When masking using a Multi-Column algorithm, the inputs in the file must be provided in the same format they would be provided when using the mask subcommand of the maskApp (i.e.: comma-separated list of expected values). If unsure of the order, use the mask subcommand in the maskApp to see what the expected order is.

Redirecting Informational Messages

To remove all informational message from the output, redirect standard error to /dev/null or an alternate location:

$ cat test_input.txt | maskScript mask -j algorithm/build/libs/algorithm.jar -n "Sample Plugin:Redaction Z" 2>/dev/null