From 19e7e51dd2cfe365ebe3709ef9b07dc8391ab82e Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Tue, 6 Jun 2023 14:52:28 -0500 Subject: [PATCH 01/10] Add optional cookies field to PrivacyDeclaration. --- src/fideslang/models.py | 3 +++ tests/fideslang/test_models.py | 1 + 2 files changed, 4 insertions(+) diff --git a/src/fideslang/models.py b/src/fideslang/models.py index 49c19f19..a5db416b 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -818,6 +818,9 @@ class PrivacyDeclaration(BaseModel): ingress: Optional[List[FidesKey]] = Field( description="The resources from which data is received. Any `fides_key`s included in this list reference `DataFlow` entries in the `ingress` array of any `System` resources to which this `PrivacyDeclaration` is applied." ) + cookies: Optional[List[str]] = Field( + description="Cookies utilized by the system to deliver services and functionality" + ) @validator("dataset_references") @classmethod diff --git a/tests/fideslang/test_models.py b/tests/fideslang/test_models.py index 4c3cf276..94074959 100644 --- a/tests/fideslang/test_models.py +++ b/tests/fideslang/test_models.py @@ -84,6 +84,7 @@ def test_system_valid(self) -> None: egress=["test_system_2"], ingress=["test_system_3"], name="declaration-name", + cookies=["test_cookie"], ) ], registry_id=1, From 5ae4b91e73a5a41f9e8784d0adbca0efe53b71da Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Tue, 6 Jun 2023 14:54:05 -0500 Subject: [PATCH 02/10] Update changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a4113be..61115776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The types of changes are: ### Changed - Make `meta` property of `System` and `Dataset` models more permissive [#113](https://github.com/ethyca/fideslang/pull/113) +- Add `cookies` property to `PrivacyDeclaration` [#115](https://github.com/ethyca/fideslang/pull/115) ## [1.4.0](https://github.com/ethyca/fideslang/compare/1.3.4...1.4.0) From 5ed6a4ed1a8d4711117cebafcfc4fecb600552a2 Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Tue, 13 Jun 2023 14:17:03 -0500 Subject: [PATCH 03/10] Add cookies to system as well. --- src/fideslang/models.py | 5 ++++- tests/fideslang/test_models.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fideslang/models.py b/src/fideslang/models.py index a5db416b..6ace6d71 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -819,7 +819,7 @@ class PrivacyDeclaration(BaseModel): description="The resources from which data is received. Any `fides_key`s included in this list reference `DataFlow` entries in the `ingress` array of any `System` resources to which this `PrivacyDeclaration` is applied." ) cookies: Optional[List[str]] = Field( - description="Cookies utilized by the system to deliver services and functionality" + description="Cookies associated with this data use to deliver services and functionality" ) @validator("dataset_references") @@ -962,6 +962,9 @@ class System(FidesModel): default=DataProtectionImpactAssessment(), description=DataProtectionImpactAssessment.__doc__, ) + cookies: Optional[List[str]] = Field( + description="Cookies utilized by the system to deliver services and functionality" + ) _sort_privacy_declarations: classmethod = validator( "privacy_declarations", allow_reuse=True diff --git a/tests/fideslang/test_models.py b/tests/fideslang/test_models.py index 94074959..abd69590 100644 --- a/tests/fideslang/test_models.py +++ b/tests/fideslang/test_models.py @@ -74,6 +74,7 @@ def test_system_valid(self) -> None: ], meta={"some": "meta stuff"}, name="Test System", + cookies=["test_cookie"], organization_fides_key=1, privacy_declarations=[ PrivacyDeclaration( From df9a5d2e02183094a96b2bb8b53d89e3e4b20cfb Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Tue, 13 Jun 2023 14:29:25 -0500 Subject: [PATCH 04/10] Update changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e14b1462..b2b4fe5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ The types of changes are: ## [Unreleased](https://github.com/ethyca/fideslang/compare/1.4.1...main) + +### Changed + +- Add `cookies` property to `PrivacyDeclaration` and `System` [#115](https://github.com/ethyca/fideslang/pull/115) + ### Fixed - Fix Fideslang visual explorer on docs site [#123](https://github.com/ethyca/fideslang/pull/123) @@ -25,7 +30,6 @@ The types of changes are: ### Changed - Make `meta` property of `System` and `Dataset` models more permissive [#113](https://github.com/ethyca/fideslang/pull/113) -- Add `cookies` property to `PrivacyDeclaration` [#115](https://github.com/ethyca/fideslang/pull/115) ## [1.4.0](https://github.com/ethyca/fideslang/compare/1.3.4...1.4.0) From 5862d6a1b5aa946c56d7eaf12ef2ca44bf60cf63 Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Tue, 13 Jun 2023 16:37:33 -0500 Subject: [PATCH 05/10] Remove cookies from system. --- src/fideslang/models.py | 3 --- tests/fideslang/test_models.py | 1 - 2 files changed, 4 deletions(-) diff --git a/src/fideslang/models.py b/src/fideslang/models.py index 67eece4d..ff6dcebe 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -963,9 +963,6 @@ class System(FidesModel): default=DataProtectionImpactAssessment(), description=DataProtectionImpactAssessment.__doc__, ) - cookies: Optional[List[str]] = Field( - description="Cookies utilized by the system to deliver services and functionality" - ) _sort_privacy_declarations: classmethod = validator( "privacy_declarations", allow_reuse=True diff --git a/tests/fideslang/test_models.py b/tests/fideslang/test_models.py index c8b6899d..aa6b0211 100644 --- a/tests/fideslang/test_models.py +++ b/tests/fideslang/test_models.py @@ -74,7 +74,6 @@ def test_system_valid(self) -> None: ], meta={"some": "meta stuff"}, name="Test System", - cookies=["test_cookie"], organization_fides_key=1, privacy_declarations=[ PrivacyDeclaration( From 56bf61d5b223809d2aec3e0cbaa6132996d2088b Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Tue, 13 Jun 2023 21:44:37 -0500 Subject: [PATCH 06/10] Create Cookies pydantic model. --- src/fideslang/models.py | 11 +++++++++-- tests/fideslang/test_models.py | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/fideslang/models.py b/src/fideslang/models.py index ff6dcebe..928b736d 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -178,6 +178,10 @@ class DataQualifier(FidesModel): _no_self_reference: classmethod = no_self_reference_validator +class Cookies(BaseModel): + name: str + + class DataSubjectRights(BaseModel): """ The DataSubjectRights resource model. @@ -819,8 +823,8 @@ class PrivacyDeclaration(BaseModel): ingress: Optional[List[FidesKey]] = Field( description="The resources from which data is received. Any `fides_key`s included in this list reference `DataFlow` entries in the `ingress` array of any `System` resources to which this `PrivacyDeclaration` is applied." ) - cookies: Optional[List[str]] = Field( - description="Cookies associated with this data use to deliver services and functionality" + cookies: Optional[List[Cookies]] = Field( + description="Cookies associated with this data use to deliver services and functionality", ) @validator("dataset_references") @@ -963,6 +967,9 @@ class System(FidesModel): default=DataProtectionImpactAssessment(), description=DataProtectionImpactAssessment.__doc__, ) + cookies: Optional[List[Cookies]] = Field( + description="Cookies associated with this system to deliver services and functionality" + ) _sort_privacy_declarations: classmethod = validator( "privacy_declarations", allow_reuse=True diff --git a/tests/fideslang/test_models.py b/tests/fideslang/test_models.py index aa6b0211..a23e710a 100644 --- a/tests/fideslang/test_models.py +++ b/tests/fideslang/test_models.py @@ -75,6 +75,7 @@ def test_system_valid(self) -> None: meta={"some": "meta stuff"}, name="Test System", organization_fides_key=1, + cookies=[{"name": "test_cookie"}], privacy_declarations=[ PrivacyDeclaration( data_categories=[], @@ -84,7 +85,7 @@ def test_system_valid(self) -> None: egress=["test_system_2"], ingress=["test_system_3"], name="declaration-name", - cookies=["test_cookie"], + cookies=[{"name": "test_cookie"}], ) ], registry_id=1, From ab9a9ea257d7715506b995020d7d5170fe65f41a Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Tue, 13 Jun 2023 22:05:25 -0500 Subject: [PATCH 07/10] Add orm_mode is True to Cookies model. --- src/fideslang/models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fideslang/models.py b/src/fideslang/models.py index 928b736d..64e961e5 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -179,8 +179,14 @@ class DataQualifier(FidesModel): class Cookies(BaseModel): + """The Cookies resource model""" name: str + class Config: + """Config for the cookies""" + + orm_mode = True + class DataSubjectRights(BaseModel): """ From c519be39265ba5947980d2113b7a3b9675024dc0 Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Wed, 14 Jun 2023 18:54:37 -0500 Subject: [PATCH 08/10] Add path and domain to cookies --- src/fideslang/models.py | 3 +++ tests/fideslang/test_models.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fideslang/models.py b/src/fideslang/models.py index 64e961e5..7fe4ce66 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -180,7 +180,10 @@ class DataQualifier(FidesModel): class Cookies(BaseModel): """The Cookies resource model""" + name: str + path: Optional[str] + domain: Optional[str] class Config: """Config for the cookies""" diff --git a/tests/fideslang/test_models.py b/tests/fideslang/test_models.py index a23e710a..0bb2ec61 100644 --- a/tests/fideslang/test_models.py +++ b/tests/fideslang/test_models.py @@ -85,7 +85,9 @@ def test_system_valid(self) -> None: egress=["test_system_2"], ingress=["test_system_3"], name="declaration-name", - cookies=[{"name": "test_cookie"}], + cookies=[ + {"name": "test_cookie", "path": "/", "domain": "example.com"} + ], ) ], registry_id=1, From 6e93ab4ea7d35713201d48b3314b8d25df0815cb Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Thu, 15 Jun 2023 11:30:16 -0500 Subject: [PATCH 09/10] Remove cookies from System, as they can't be defined here. Commit some other linting/sorting changes. --- src/fideslang/_version.py | 2 +- src/fideslang/models.py | 4 ---- src/fideslang/relationships.py | 2 +- tests/conftest.py | 2 +- tests/fideslang/test_relationships.py | 10 ++++++++-- tests/fideslang/test_validation.py | 7 ++++++- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/fideslang/_version.py b/src/fideslang/_version.py index a2907cb8..12d61995 100644 --- a/src/fideslang/_version.py +++ b/src/fideslang/_version.py @@ -13,12 +13,12 @@ """Git implementation of _version.py.""" import errno +import functools import os import re import subprocess import sys from typing import Callable, Dict -import functools def get_keywords(): diff --git a/src/fideslang/models.py b/src/fideslang/models.py index 7fe4ce66..f806f601 100644 --- a/src/fideslang/models.py +++ b/src/fideslang/models.py @@ -976,10 +976,6 @@ class System(FidesModel): default=DataProtectionImpactAssessment(), description=DataProtectionImpactAssessment.__doc__, ) - cookies: Optional[List[Cookies]] = Field( - description="Cookies associated with this system to deliver services and functionality" - ) - _sort_privacy_declarations: classmethod = validator( "privacy_declarations", allow_reuse=True )(sort_list_objects_by_name) diff --git a/src/fideslang/relationships.py b/src/fideslang/relationships.py index f1b241e9..9e18c627 100644 --- a/src/fideslang/relationships.py +++ b/src/fideslang/relationships.py @@ -6,7 +6,7 @@ import inspect from enum import Enum from functools import reduce -from typing import Optional, List, Set +from typing import List, Optional, Set from fideslang.models import BaseModel, FidesKey, Taxonomy from fideslang.utils import get_resource_by_fides_key diff --git a/tests/conftest.py b/tests/conftest.py index d5cb7eb8..e41f992f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ """Common fixtures to be used across tests.""" +import os from typing import Any, Dict -import os import pytest import yaml diff --git a/tests/fideslang/test_relationships.py b/tests/fideslang/test_relationships.py index db099b44..4943741c 100644 --- a/tests/fideslang/test_relationships.py +++ b/tests/fideslang/test_relationships.py @@ -35,7 +35,10 @@ def test_find_referenced_fides_keys_2(): name="test_dc", fides_key="test_dc", description="test description", - egress=[DataFlow(fides_key="key_1", type="system", data_categories=None), DataFlow(fides_key="key_2", type="system", data_categories=None)], + egress=[ + DataFlow(fides_key="key_1", type="system", data_categories=None), + DataFlow(fides_key="key_2", type="system", data_categories=None), + ], system_type="test", privacy_declarations=None, ) @@ -66,7 +69,10 @@ def test_get_referenced_missing_keys(): name="test_system", fides_key="test_system", description="test description", - egress=[DataFlow(fides_key="key_3", type="system", data_categories=None), DataFlow(fides_key="key_4", type="system", data_categories=None)], + egress=[ + DataFlow(fides_key="key_3", type="system", data_categories=None), + DataFlow(fides_key="key_4", type="system", data_categories=None), + ], system_type="test", privacy_declarations=None, ) diff --git a/tests/fideslang/test_validation.py b/tests/fideslang/test_validation.py index 012b8b8e..6ddd0a67 100644 --- a/tests/fideslang/test_validation.py +++ b/tests/fideslang/test_validation.py @@ -226,7 +226,12 @@ def test_create_valid_system(): dataset_references=[], ) ], - egress=[DataFlow(fides_key="another_system", type="system", data_categories=None), DataFlow(fides_key="yet_another_system", type="system", data_categories=None)], + egress=[ + DataFlow(fides_key="another_system", type="system", data_categories=None), + DataFlow( + fides_key="yet_another_system", type="system", data_categories=None + ), + ], ) assert True From 523cc7d26ad9f503fa333b60fdb46c3190b72341 Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Mon, 19 Jun 2023 08:40:42 -0500 Subject: [PATCH 10/10] Update changelog. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2b4fe5a..27fd65de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ The types of changes are: ### Changed -- Add `cookies` property to `PrivacyDeclaration` and `System` [#115](https://github.com/ethyca/fideslang/pull/115) +- Add `Cookies` schema and similar property to `PrivacyDeclaration` [#115](https://github.com/ethyca/fideslang/pull/115) ### Fixed