Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add masking strategy override to FidesMeta #23

Merged
merged 7 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The types of changes are:

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

- Add field-level masking strategy overrides [#23](https://github.com/ethyca/fideslang/pull/23)

## [3.0.8](https://github.com/ethyca/fideslang/compare/3.0.7...3.0.8)

Expand Down
15 changes: 13 additions & 2 deletions src/fideslang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from datetime import datetime
from enum import Enum
from typing import Annotated, Dict, List, Optional, Union
from typing import Annotated, Dict, List, Optional, Union, Any

from packaging.version import InvalidVersion, Version
from pydantic import (
Expand Down Expand Up @@ -69,11 +69,18 @@ class MaskingStrategies(str, Enum):


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

strategy: MaskingStrategies


class FieldMaskingStrategyOverride(BaseModel): # type: ignore[misc]
"""Overrides field-level masking strategies."""

strategy: str
configuration: Optional[Dict[str, Any]] = {} # type: ignore[misc]


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

Expand Down Expand Up @@ -418,6 +425,10 @@ class FidesMeta(BaseModel):
default=None,
description="Optionally specify that a field may be used as a custom request field in DSRs. The value is the name of the field in the DSR.",
)
masking_strategy_override: Optional[FieldMaskingStrategyOverride] = Field(
default=None,
description="Optionally specify a masking strategy override for this field.",
)

@field_validator("data_type")
@classmethod
Expand Down
Loading