Skip to content

Commit

Permalink
Collection-Level Masking Strategy Override and Erase After (#17)
Browse files Browse the repository at this point in the history
Define two things on Collection Meta to support erasure operations at the row level for database connectors:

- Defines a masking strategy override under Collection Meta that will override Policy-based masking strategies if applicable and supported. 
- Also allow `erase_after` to be specified for DSR's (specifically for database connectors).  We can manually specify that one collection should be erased after another.
  • Loading branch information
pattisdr authored Sep 24, 2024
1 parent 62777a3 commit 5a66350
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ The types of changes are:

## [Unreleased](https://github.com/ethyca/fideslang/compare/3.0.5...main)

### Changed

- Add collection-level masking strategy overrides and support specifying one collection to be erased after another [#17](https://github.com/ethyca/fideslang/pull/17)


## [3.0.5](https://github.com/ethyca/fideslang/compare/3.0.4...3.0.5)

### Added
Expand Down
14 changes: 14 additions & 0 deletions src/fideslang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
)


class MaskingStrategies(str, Enum):
"""Possible options for masking strategy overrides"""

DELETE = "delete"


class MaskingStrategyOverride(BaseModel):
"""Overrides policy-level masking strategies."""

strategy: MaskingStrategies


class FidesModel(BaseModel):
"""The base model for most top-level Fides objects."""

Expand Down Expand Up @@ -515,7 +527,9 @@ class CollectionMeta(BaseModel):
"""Collection-level specific annotations used for query traversal"""

after: Optional[List[FidesCollectionKey]] = None
erase_after: Optional[List[FidesCollectionKey]] = None
skip_processing: Optional[bool] = False
masking_strategy_override: Optional[MaskingStrategyOverride] = None


class DatasetCollection(FidesopsMetaBackwardsCompat):
Expand Down
19 changes: 18 additions & 1 deletion tests/fideslang/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
FidesDatasetReference,
FidesMeta,
FidesModel,
MaskingStrategies,
MaskingStrategyOverride,
Policy,
PolicyRule,
PrivacyDeclaration,
Expand Down Expand Up @@ -642,7 +644,7 @@ def test_specify_fides_meta_with_custom_request_field(self):
length=None,
return_all_elements=None,
read_only=None,
custom_request_field="site_id"
custom_request_field="site_id",
)

def test_specify_both_fidesops_meta_and_fides_meta(self):
Expand Down Expand Up @@ -789,6 +791,21 @@ def test_collection_key_has_too_many_components(self):
def test_valid_collection_key(self):
CollectionMeta(after=[FidesCollectionKey("test_dataset.test_collection")])

def test_delete_masking_strategy(self):
meta = CollectionMeta(masking_strategy_override={"strategy": "delete"})

assert meta.masking_strategy_override == MaskingStrategyOverride(
strategy=MaskingStrategies.DELETE
)

def test_erase_after(self):
meta = CollectionMeta(
erase_after=[FidesCollectionKey("test_dataset.test_collection")]
)

assert meta.erase_after == [FidesCollectionKey("test_dataset.test_collection")]



class TestAnyUrlString:
def test_valid_url(self):
Expand Down

0 comments on commit 5a66350

Please sign in to comment.