-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PROPOSAL] External masks library #240
Comments
Some suggestions: In this context, "generator" is a list, so I suggest using the plural form: generators:
-
- Or this the generator (singular) that is defined with a list of masks ? Make the git support explicit in the URL scheme:
|
To embed the generator in a binary and expose it using the "pimo://" scheme, consider the following example:
This way, you can include the generator within the |
Yes, the generator is defined by the whole list |
Note: first post updated A generator could also be defined like this filename : nir.yml masking:
- selector:
jsonpath: "gender" #if present then gender is used a parameter
masks:
- add: true #add parameter if not present
- randomChoice: [1, 2]
preserve: "value" #preserve parameter value if present
# other parameters ...
- selector:
jsonpath: "nir"
masks:
- add: true #in this example, the result will be created in a new subfield
- template: '{{if eq .gender "M" }}1{{else}}2{{end}}{{.birth_date | substr 8 10}}{{.birth_date | substr 3 5}}{{.department_code | printf "%02d"}}{{.city_code | printf "%03d"}}{{.order | printf "%03d"}}'
- template: '{{ sub 97 (mod (int64 .nir_start) 97)}}' This is a normal masking definition except for the preserve "value" option that does not exist yet. The call to the generator : - selector:
jsonpath: "nir"
mask:
generate:
using: "nir"
with:
gender: # this field is of type MaskType
- constant: 2 MaskType : Line 167 in 8daf79d
This way, generator can use other generators, for example person.yml version: "1"
masking:
- selector:
jsonpath: "first_name"
mask:
- add: true
- generate:
using: "first_name_fr_FR"
- selector:
jsonpath: "last_name"
mask:
- add: true
- generate:
using: "last_name_fr_FR"
- selector:
jsonpath: "." # generate in the current document
mask:
- add: true
- generate:
using: "nir" person-with-coherence.yml version: "1"
masking:
- selector:
jsonpath: "."
mask:
- add: true
- generate:
using: "person"
seed: "." |
Definitions
A masking definition contains the following parts :
The generator is usually defined by the
mask
part of the masking.yml, except for "hash" and "hashInUri" masks which contains a coherence element.The coherence is usually defined by some properties added to the mask :
seed
,cache
or thehash
part in "hash" and "hashInUri" masks.The location is defined by the selector part.
What we need to store in a masking library, is only the generator part.When applied in a given context, we can choose where we apply it (selector) and how we handle consistency (cache, seed, hash + what source field is used).Note: we can allow coherence information in some dedicated masks.
Note: we can allow selector information in case of multiple fields output.
Examples
This generator :
Can be used in differnt contexts :
How to define a mask library
The library should expose a variety of data types
This can be done by storing a single file for each data type, that contains the list of masks to apply.
filename : person_name_fr_FR.yml
It's similar to a normal masking. Except for the "." jsonpath that allow to write on the current location in the json stream (where the mask is applied).
Some generators can take parameters
filename : nir.yml
How to use masks library
The library can be a folder, a git repository, a website, ...
A new property need to be created to load the library, in the masking.yml
Then a mask from library can be used via a new type of mask
Passing parameters : option 1
or, if we want to use an existing field as parameter
Passing parameters : option 2
The text was updated successfully, but these errors were encountered: