Skip to content

Commit 6dddf25

Browse files
authored
Merge pull request #62 from dpguthrie/masking
add masking
2 parents 7c46d80 + 9443aaf commit 6dddf25

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

dbt_project.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ clean-targets: # directories to be removed by `dbt clean`
2727
- "dbt_modules"
2828
- "dbt_packages"
2929

30+
on-run-start:
31+
- "{{ dbt_snow_mask.create_masking_policy('sources')}}"
32+
- "{{ dbt_snow_mask.apply_masking_policy('sources')}}"
33+
3034
vars:
3135
start_date: '1999-01-01'
3236
disable_dbt_artifacts_autoupload: "{% if env_var('DBT_TARGET_ENV') == 'prod' %}false{% else %}true{% endif %}"
3337
disable_run_results: "{% if env_var('DBT_TARGET_ENV') == 'prod' %}false{% else %}true{% endif %}"
3438
disable_tests_results: "{% if env_var('DBT_TARGET_ENV') == 'prod' %}false{% else %}true{% endif %}"
3539
disable_dbt_invocation_autoupload: "{% if env_var('DBT_TARGET_ENV') == 'prod' %}false{% else %}true{% endif %}"
40+
use_force_applying_masking_policy: "True"
3641

3742
# Configuring models
3843
# Full documentation: https://docs.getdbt.com/docs/configuring-models

dependencies.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ packages:
1212
version: ["<3.0.0"]
1313
- package: elementary-data/elementary
1414
version: 0.12.1
15+
- package: entechlog/dbt_snow_mask
16+
version: 0.2.4
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% macro create_masking_policy_encrypt_pii(node_database, node_schema) %}
2+
3+
CREATE MASKING POLICY IF NOT EXISTS {{ node_database }}.{{ node_schema }}.encrypt_pii AS (val string)
4+
RETURNS string ->
5+
CASE
6+
WHEN CURRENT_ROLE() IN ('TRANSFORMER') THEN val
7+
ELSE SHA2(val)
8+
END
9+
10+
{% endmacro %}

models/staging/tpch/_tpch__models.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ models:
2323
description: market segment of the customer
2424
- name: comment
2525
description: '{{ doc("comment") }}'
26-
meta:
27-
joins:
28-
- join: stg_tpch_nations
29-
sql_on: ${stg_tpch_customers.nation_key} = ${stg_tpch_nations.nation_key}
3026

3127
- name: stg_tpch_line_items
3228
description: staging layer for line items data
@@ -83,10 +79,6 @@ models:
8379
description: foreign key to stg_tpch_regions
8480
- name: comment
8581
description: additional commentary
86-
meta:
87-
joins:
88-
- join: stg_tpch_regions
89-
sql_on: ${stg_tpch_nations.region_key} = ${stg_tpch_regions.region_key}
9082

9183
- name: stg_tpch_orders
9284
description: staging layer for orders data
@@ -131,10 +123,6 @@ models:
131123
description: '{{ doc("cost") }}'
132124
- name: comment
133125
description: '{{ doc("comment") }}'
134-
meta:
135-
joins:
136-
- join: stg_tpch_suppliers
137-
sql_on: ${stg_tpch_part_suppliers.supplier_key} = ${stg_tpch_suppliers.supplier_key}
138126

139127
- name: stg_tpch_parts
140128
description: staging layer for parts data
@@ -194,7 +182,3 @@ models:
194182
description: '{{ doc("account_balance") }}'
195183
- name: comment
196184
description: '{{ doc("comment") }}'
197-
meta:
198-
joins:
199-
- join: stg_tpch_nations
200-
sql_on: ${stg_tpch_suppliers.nation_key} = ${stg_tpch_nations.nation_key}

models/staging/tpch/_tpch__sources.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ sources:
5757
- unique
5858
- name: c_name
5959
description: customer id
60+
meta:
61+
masking_policy: encrypt_pii
6062
- name: c_address
6163
description: address of the customer
64+
meta:
65+
masking_policy: encrypt_pii
6266
- name: c_nationkey
6367
description: foreign key to stg_tpch_nations
6468
tests:
@@ -67,6 +71,8 @@ sources:
6771
field: n_nationkey
6872
- name: c_phone
6973
description: phone number of the customer
74+
meta:
75+
masking_policy: encrypt_pii
7076
- name: c_acctbal
7177
description: raw account balance
7278
- name: c_mktsegment

package-lock.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ packages:
99
version: 2.6.2
1010
- package: elementary-data/elementary
1111
version: 0.12.1
12-
sha1_hash: 4602085df3a0e934c8834bc00192f0207fdaa3b7
12+
- package: entechlog/dbt_snow_mask
13+
version: 0.2.4
14+
sha1_hash: 297b60f83c9161c116f2335d60f69f831892b5e1

0 commit comments

Comments
 (0)