09-28-2023 10:23 PM
Hi Team,
The community is amazing and very helpful. Kudos to everyone behind it.
I'm working on encrypting certain fields(PII) coming from SFDC sources and using encrypt field snap for the same. For that I'm having to add the fields manually in the snap. But I want to develop a generic pipeline for multiple source objects from SFDC where the fields to be encrypted would be varying(I can store those details of objects and fields in a file or config table to identify them dynamically). I'm not able to find an efficient way for the same as the fields tab in encrypt field snap is not having option to create an expression, leaving with no option except adding them manually. I'd appreciate if anyone could help me understand if there's a way I can achieve that.
Thanks in advance !
Solved! Go to Solution.
09-29-2023 12:48 PM - edited 09-29-2023 12:48 PM
@manichandana_ch - The Encrypt Field snap allows you to send any object element: even a sub-object. So you can move all the fields you want to encrypt into a sub-object and have the encrypt snap work on that whole element. For example, I have my PII elements in the "sensitive" sub-object and pass that to the snap:
If you want to see my whole pipeline, download and decompress the attached zip and import the pipeline (SLP) and expression library (EXPR) files into your project.
I hope this helps!
10-02-2023 04:27 AM
@manichandana_ch - I'm glad that seems to work for your use case! Let me explain a couple things in the more generic solution. The first thing to explain is the use of the Expression Library (encrypt.expr) that is configured in the Pipeline Properties.
I'm a big advocate for the use of Expression Libraries, especially since you can store static variables and create inline functions to replace complex or re-usable code in your pipelines. In this case, I'm simply storing the list of sensitive fields that I want to encrypt and referencing it generically in the first Mapper (Move fields to encrypt):
{}.extend($).filter((val,key)=> lib.encrypt.sensitive.indexOf(key) < 0)
.extend({ "sensitive" : $.filter((val,key)=> lib.encrypt.sensitive.indexOf(key) >= 0) })
The above statement is worth unpacking a bit. This uses object and array methods to move the sensitive fields to a sub-element of the root object.
In the last Mapper in the pipeline (Move sensitive fields to root), we are simply moving the "sensitive" sub-object fields up to the root level of the document.
Hope this helps!
10-12-2023 09:44 AM
@manichandana_ch - One way I can see to do this pretty simply is by creating a child pipeline for each type of object you want to encrypt and call that dynamically from your main pipeline that is reading and writing to your endpoints. Assuming that you are reading from your source generically using pipeline parameters (or expression library reference), you could create a set of "encryption" child pipelines: one pipeline for each source object. These child pipelines only need to contain the Encrypt Field snap, configured with the appropriate fields to be encrypted and named using a standard convention, such as "Encrypt SFDC Account", "Encrypt SFDC Contact", etc. Then in your main pipeline, use a Pipeline Execute snap configured as follows:
Hope this helps!
10-04-2023 02:06 AM
@koryknick Thanks for such a detailed and clear explanation. It's very kind of you to not just provide a solution, but explain it clearly. I'm working on my pipeline to implement the same.
I need to try exploring the use of expression library and the functions more , as they seem to provide solution to any/most of the use cases 🙂
10-09-2023 09:29 AM
Hi @koryknick
I'm not sure why but facing issues recently with the pipeline you shared, even though nothing's been changed. Could you please help me understand the issue and resolve it. Thanks in Advance !
10-09-2023 11:34 AM
I believe the error means you are missing an account on the Encrypt snap.
10-12-2023 04:25 AM - edited 10-12-2023 04:27 AM
Hi @koryknick ,
The solution you suggested worked fine, but now the requirement is to just encrypt and load them to parquet files. Downstreams are going to decrypt it (probably it is redshift and decrypts using redshift decrypt function). I tried doing that in redshift via DBeaver, but not able to decrypt the sensitive column group that we encrypted. Now I need to only encrypt the fields and individually. I need to use encrypt field snap. Would you be able to suggest a way for that?
Thanks in Advance !
10-12-2023 09:44 AM
@manichandana_ch - One way I can see to do this pretty simply is by creating a child pipeline for each type of object you want to encrypt and call that dynamically from your main pipeline that is reading and writing to your endpoints. Assuming that you are reading from your source generically using pipeline parameters (or expression library reference), you could create a set of "encryption" child pipelines: one pipeline for each source object. These child pipelines only need to contain the Encrypt Field snap, configured with the appropriate fields to be encrypted and named using a standard convention, such as "Encrypt SFDC Account", "Encrypt SFDC Contact", etc. Then in your main pipeline, use a Pipeline Execute snap configured as follows:
Hope this helps!