Search code examples
palantir-foundryfoundry-code-repositories

How can I hide sensitive variables in code repository?


I'm working on a transform that requires a sensitive parameter and I would like to know if there is any way of hiding this information, for example:

instead of this:

 x = 'sensitive'
   ...do stuff with x 

do this:

x = GLOBAL_HIDDEN_VARIABLE
     ...do stuff with x

Solution

  • oundry has an app called Cipher that allows you to encrypt sensitive data while keeping the data operational. Functions code repositories can be used to interact with CipherText object properties, enabling sophisticated logic like bulk encryption or bulk decryption.

    For the examples below assume we have an EncryptedCustomer object with the following properties:

    • An encrypted CipherText name
    • A unique, unencrypted integer id

    Cipher Image

    You can then create a function the decrypts the name below

    import { Function, Integer, OntologyEditFunction, Edits } from "@foundry/functions-api";
    import { Objects, EncryptedCustomers } from "@foundry/ontology-api";
    
    @Function()
    public async decryptEncryptedCustomer(customer: EncryptedCustomers): Promise<string | undefined> {
        return await customer.name?.decryptAsync();
    }
    

    You can build on this function to use the original value as a part of transforms that reference a hidden variable. For more details check out the official documentation.