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

HA-399 deprecate cookies #27

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 31 additions & 15 deletions src/fideslang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, how does this work? have we tested how this actually manifests in application use?

i don't think we use this builtin anywhere else, so it'd just be good to verify that it surfaces in the way you'd want/expect.

i think the two things to test would be specifying a cookies attribute on an API call to the /systems endpoint, and using the CLI to push/pull a system definition with cookies


from packaging.version import InvalidVersion, Version
from pydantic import (
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
)
Expand Down
8 changes: 5 additions & 3 deletions tests/fideslang/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from fideslang import DataFlow, Dataset, Organization, PrivacyDeclaration, System
from fideslang.models import (
ContactDetails,
Cookies,
DataResponsibilityTitle,
DatasetCollection,
DatasetField,
Expand Down Expand Up @@ -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"
Expand All @@ -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 == [
Expand All @@ -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
)
]

Expand Down
Loading