-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes to add conditional masking policy feature (#62)
- Loading branch information
Showing
11 changed files
with
138 additions
and
50 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
integration_tests/macros/snow-mask-ddl/create_masking_policy_mp_conditional_contacts_pii.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% macro create_masking_policy_mp_conditional_contacts_pii(node_database, node_schema, masked_column) %} | ||
|
||
CREATE MASKING POLICY IF NOT EXISTS {{node_database}}.{{node_schema}}.mp_conditional_contacts_pii AS ( | ||
{{masked_column}} string, | ||
last_name string | ||
) RETURNS string -> | ||
CASE | ||
WHEN CURRENT_ROLE() IN ('ANALYST') THEN {{masked_column}} | ||
WHEN CURRENT_ROLE() IN ('DEVELOPER') AND last_name like 'A%' THEN {{masked_column}} | ||
WHEN CURRENT_ROLE() IN ('DEVELOPER') AND last_name like 'B%' THEN SHA2({{masked_column}}) | ||
WHEN CURRENT_ROLE() IN ('DEVELOPER') AND last_name='Skeffington' THEN '*TARGETED_MASKING*' | ||
WHEN CURRENT_ROLE() IN ('SYSADMIN') THEN SHA2({{masked_column}}) | ||
ELSE '**********' | ||
END | ||
|
||
{% endmacro %} |
16 changes: 16 additions & 0 deletions
16
integration_tests/macros/snow-mask-ddl/create_masking_policy_mp_conditional_customer_pii.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% macro create_masking_policy_mp_conditional_customer_pii(node_database, node_schema, masked_column) %} | ||
|
||
CREATE MASKING POLICY IF NOT EXISTS {{node_database}}.{{node_schema}}.mp_conditional_customer_pii AS ( | ||
{{masked_column}} string, | ||
store_id int, | ||
active int | ||
) RETURNS string -> | ||
CASE | ||
WHEN CURRENT_ROLE() IN ('ANALYST') AND active=1 AND store_id=1 THEN {{masked_column}} | ||
WHEN CURRENT_ROLE() IN ('ANALYST') AND active=1 AND store_id=2 THEN SHA2({{masked_column}}) | ||
WHEN CURRENT_ROLE() IN ('ANALYST') AND active=0 THEN '**********' | ||
WHEN CURRENT_ROLE() IN ('SYSADMIN') THEN SHA2({{masked_column}}) | ||
ELSE '**********' | ||
END | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: stg_contacts | ||
description: "" | ||
columns: | ||
- name: contact_id | ||
description: "" | ||
- name: first_name | ||
description: "" | ||
- name: last_name | ||
description: "" | ||
- name: email | ||
description: "Email Address" | ||
meta: | ||
masking_policy: mp_email | ||
- name: gender | ||
- name: stg_contacts | ||
description: "" | ||
columns: | ||
- name: contact_id | ||
description: "" | ||
- name: first_name | ||
description: "" | ||
meta: | ||
masking_policy: mp_conditional_contacts_pii | ||
mp_conditional_columns: | ||
- last_name | ||
- name: last_name | ||
description: "" | ||
- name: email | ||
description: "Email Address" | ||
meta: | ||
masking_policy: mp_email | ||
- name: gender | ||
description: "" | ||
|
||
- name: ip_address | ||
description: "" | ||
- name: ip_address | ||
description: "" | ||
|
||
- name: ssn | ||
description: "" | ||
- name: ssn | ||
description: "" | ||
|
||
- name: phone | ||
description: "" | ||
- name: phone | ||
description: "" |
15 changes: 15 additions & 0 deletions
15
macros/snow-mask-ddl/create_masking_policy_mp_conditional_pii.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% macro create_masking_policy_mp_conditional_pii(node_database, node_schema, masked_column) %} | ||
|
||
CREATE MASKING POLICY IF NOT EXISTS {{node_database}}.{{node_schema}}.mp_conditional_pii AS ( | ||
{{masked_column}} string, | ||
my_conditional_col_1 string, | ||
my_conditional_col_2 string | ||
) RETURNS string -> | ||
CASE | ||
WHEN CURRENT_ROLE() IN ('ANALYST') AND my_conditional_col_1='foo' THEN {{masked_column}} | ||
WHEN CURRENT_ROLE() IN ('ANALYST') AND my_conditional_col_2='bar' THEN SHA2({{masked_column}}) | ||
WHEN CURRENT_ROLE() IN ('SYSADMIN') THEN SHA2({{masked_column}}) | ||
ELSE '**********' | ||
END | ||
|
||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters