Spec

Pydantic models for anonymization and pseudonymization configuration.

An AnonymizationConfig maps onto a sequence of column-level rules and can be loaded from the same JSON/YAML config files used by the rest of the framework.

class scamander.models.anonymization_config.spec.AnonymizationConfig(*, name: str, rules: list[AnonymizationRule])

Basisklassen: BaseModel

Named set of column anonymization rules.

name

Descriptive name used for logging and audit trails.

Type:

str

rules

Ordered list of per-column anonymization rules. Rules are applied in sequence, so the same column can be transformed more than once if needed.

Type:

list[scamander.models.anonymization_config.spec.AnonymizationRule]

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class scamander.models.anonymization_config.spec.AnonymizationRule(*, column: str, method: Literal['hash', 'mask', 'redact', 'generalize', 'generalize_date', 'encrypt', 'fake'], hash_key: str | None = None, mask_char: str = '*', visible_prefix: int = 0, visible_suffix: int = 0, bins: list[float] | None = None, labels: list[str] | None = None, encrypt_key: str | None = None, faker_provider: str | None = None, date_unit: Literal['month', 'year'] | None = None)

Basisklassen: BaseModel

Configuration for a single column anonymization or pseudonymization rule.

column

Target column name.

Type:

str

method

Technique to apply — one of hash, mask, redact, generalize, encrypt, or fake.

Type:

Literal[‘hash’, ‘mask’, ‘redact’, ‘generalize’, ‘generalize_date’, ‘encrypt’, ‘fake’]

hash_key

Optional HMAC-SHA256 secret (any string). When omitted, plain SHA-256 is used. Providing a key ensures consistent output only for parties that know the same secret (pseudonymization).

Type:

str | None

mask_char

Single replacement character for mask. Default "*".

Type:

str

visible_prefix

Number of leading characters to keep for mask.

Type:

int

visible_suffix

Number of trailing characters to keep for mask.

Type:

int

bins

Ordered bin boundaries for generalize (N+1 floats define N buckets). Example: [0.0, 18.0, 65.0, 120.0].

Type:

list[float] | None

labels

Bucket labels for generalize (N strings, one per bucket). Example: ["child", "adult", "senior"].

Type:

list[str] | None

encrypt_key

Base-64 encoded 32-byte AES-256 key for encrypt. Generate one with: import os, base64; base64.b64encode(os.urandom(32)).decode().

Type:

str | None

faker_provider

Faker provider method name for fake. Examples: "name", "email", "phone_number", "address".

Type:

str | None

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].