-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Problem:
Currently, the PIMO tool provides a RandomInt mask for masking data in a JSONline stream. However, it lacks the ability to specify a median parameter for generating random numbers within a range, which can be useful in certain scenarios.
Proposed Solution:
Integrate a 'median' parameter into the RandomInt mask to allow users to control the distribution of random numbers within the specified range.
Example:
version: "1"
masking:
- selector:
jsonpath: "age"
mask:
randomInt:
min: 25
median: 28
max: 32Workaround:
While waiting for the integration of the 'median' parameter into the RandomInt mask, users can achieve similar behavior by combining masks. Below is a workaround using existing PIMO masks:
version: "1"
masking:
- selector:
jsonpath: "segment"
masks:
- add-transient : ""
- randomChoice:
- "upper"
- "lower"
- selector:
jsonpath: "value"
masks:
- template : |-
{{ if eq .segment "lower" -}}
{{- MaskRandomInt (int .min) (int .median) -}}
{{- else -}}
{{- MaskRandomInt (int .median) (int .max) -}}
{{- end }}
- fromjson: "value"
This workaround calculates a random number within the range defined by 'min' and 'max', centered around the 'median' value. It utilizes the existing MaskRandomInt function and template capabilities to achieve the desired behavior.