diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bfb9b7..9f8b47e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ The types of changes are: ## [Unreleased](https://github.com/ethyca/fideslang/compare/3.0.9...main) +### Deprecated +- Deprecated `Cookies` model and `.cookies` property on `System` and `PrivacyDeclaration` [#199](https://github.com/IABTechLab/fideslang/pull/199) + ## [3.0.9](https://github.com/ethyca/fideslang/compare/3.0.8...3.0.9) ### Added diff --git a/src/fideslang/models.py b/src/fideslang/models.py index b46ae16..ff7ac9f 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -8,6 +8,7 @@ from datetime import datetime from enum import Enum from typing import Annotated, Dict, List, Optional, Union, Any +from warnings import warn from packaging.version import InvalidVersion, Version from pydantic import ( @@ -283,15 +284,6 @@ class DataCategory(FidesModel, DefaultModel): _matching_parent_key: classmethod = matching_parent_key_validator -class Cookies(BaseModel): - """The Cookies resource model""" - - name: str - path: Optional[str] = None - domain: Optional[str] = None - model_config = ConfigDict(from_attributes=True) - - class DataSubjectRights(BaseModel): """ The DataSubjectRights resource model. @@ -806,7 +798,7 @@ class Policy(FidesModel): _sort_rules: classmethod = field_validator("rules")(sort_list_objects_by_name) # type: ignore[assignment] -class PrivacyDeclaration(BaseModel): +class PrivacyDeclaration(BaseModel): # type: ignore[misc] """ The PrivacyDeclaration resource model. @@ -879,12 +871,24 @@ class PrivacyDeclaration(BaseModel): default_factory=list, description="The categories of personal data that this system shares with third parties.", ) - cookies: Optional[List[Cookies]] = Field( + cookies: Optional[Any] = Field( # type: ignore default=None, - description="Cookies associated with this data use to deliver services and functionality", + description="Deprecated, do not use.", + deprecated=True, ) model_config = ConfigDict(from_attributes=True) + @field_validator("cookies") + @classmethod + def validate_cookies(cls, value: Optional[Any]) -> None: # type: ignore + """ + Validate that the `cookies` field is deprecated and warn that it should not be used. + """ + if value is not None: + warn( + "The 'cookies' field is deprecated and should not be used. Any value given as this field will be ignored." + ) + class SystemMetadata(BaseModel): """ @@ -968,7 +972,7 @@ def verify_type_is_flowable(cls, value: str) -> str: return value -class System(FidesModel): +class System(FidesModel): # type: ignore[misc] """ The System resource model. @@ -1096,11 +1100,23 @@ class System(FidesModel): default=None, description="A URL that points to the system's publicly accessible legitimate interest disclosure.", ) - cookies: Optional[List[Cookies]] = Field( + cookies: Optional[Any] = Field( # type: ignore default=None, - description="System-level cookies unassociated with a data use to deliver services and functionality", + description="Deprecated, do not use.", + deprecated=True, ) + @field_validator("cookies") + @classmethod + def validate_cookies(cls, value: Optional[Any]) -> None: # type: ignore + """ + Validate that the `cookies` field is deprecated and warn that it should not be used. + """ + if value is not None: + warn( + "The 'cookies' field is deprecated and should not be used. Any value given as this field will be ignored." + ) + _sort_privacy_declarations: classmethod = field_validator("privacy_declarations")( # type: ignore[assignment] sort_list_objects_by_name ) diff --git a/tests/fideslang/test_models.py b/tests/fideslang/test_models.py index ff96123..aa84120 100644 --- a/tests/fideslang/test_models.py +++ b/tests/fideslang/test_models.py @@ -5,7 +5,6 @@ from fideslang import DataFlow, Dataset, Organization, PrivacyDeclaration, System from fideslang.models import ( ContactDetails, - Cookies, DataResponsibilityTitle, DatasetCollection, DatasetField, @@ -133,6 +132,7 @@ def test_system_valid(self) -> None: system_type="SYSTEM", tags=["some", "tags"], ) + assert system.name == "Test System" assert system.fides_key == "test_system" assert system.description == "Test Policy" @@ -152,7 +152,9 @@ def test_system_valid(self) -> None: ] assert system.meta == {"some": "meta stuff"} assert system.organization_fides_key == "1" - assert system.cookies == [Cookies(name="test_cookie", path=None, domain=None)] + assert ( + system.cookies == None + ), "Cookies are deprecated and should be ignored on the model" assert system.system_type == "SYSTEM" assert system.tags == ["some", "tags"] assert system.privacy_declarations == [ @@ -174,7 +176,7 @@ def test_system_valid(self) -> None: data_shared_with_third_parties=False, third_parties=None, shared_categories=[], - cookies=[Cookies(name="test_cookie", path="/", domain="example.com")], + cookies=None, # Cookies are deprecated and should be ignored on the model ) ]