PCI Vault Logo
Rule Engine

PCI Vault has a rule engine for transforming data on certain endpoints. This is very handy for sanitising input for the purpose of operating on the data later.

Each rule will have a list of one or more operations that are applied in the order that they have been specified in. Each operation must have an input field, an output field, and a name for specifying which operation to be applied. Some operations also have required or optional arguments to further control their behaviour.

No-op

noop does nothing but can be used to copy a value from one field to another.

Stringify

stringify converts data of any type to a string.

Substring

substr attempts to take a substring from a string. If taking the substring fails, the value is just copied.

Optional Fields:

  • start: The index on which to start the substring (default is 0).
  • end: The index on which to end the substring (default is 0).

Both start and end is 0-indexed, but if the end index is 0, it will be changed to the length of the input field. Negative indices will be subtracted from the length of the input.
E.g. for the string "012345", if start is -2, and end is 0. The substring will be "45".

Parse Float

parse_float attempts to parse a float from a string. If the input value is not a string, or if parsing fails, the value is just copied.

Convert To Int

convert_to_int attempts to convert any input to an integer. If the input value is a string, the int will be parsed using the base specified. If the input value is a float, the fractional part will be discarded. If the input value is a boolean, true will resolve to 1 and false to 0. If conversion fails, the value is just copied.

Optional Fields:

  • base: For strings, try to parse integers in the specified base (default is 10).

Replace

replace replaces all occurrences of the substr argument with new_str. Make new_str an empty string to effectively remove all occurrences of substr. If the input is not a string, the value is just copied.

Required Fields:

  • substr: The substring to replace.
  • new_str: The replacement string.

Mask

mask masks the substring specified by start and end. If unspecified, start and end will default to 0 and the length of the input string, respectively. If the input is not a string, the value is just copied.

Optional Fields:

  • char: The character to use for masking (default is *).
  • start: The index on which to start the substring (default is 0).
  • end: The index on which to end the substring (default is 0).

Both start and end is 0-indexed, but if the end index is 0, it will be changed to the length of the input field. Negative indices will be subtracted from the length of the input.
E.g. for the string "012345", if start is -2, and end is 0. The masked output will be "0123**".

Format

format can be used to embed values from the JSON in an arbitrary string, and also to concatenate fields. The formatting rules applied are the same rules used by Golang's formatting library.

Required Fields:

  • format_string: The template string to format. Use the %v directive to insert a value into the string.
  • keys: The keys to insert into the format_string.

The format string can be any string. The "keys" argument must contain a list of strings, each string representing a key for the value to be formatted. If the operation fails, the return value will be the value of the input field, otherwise the input field is just ignored.

E.g. for a format string "%v/%v" with values "2023" and "12", the output will be "2023/12".