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

Show systems without privacy declarations on data map #1603

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -42,6 +42,7 @@ The types of changes are:

* Handle malformed tokens [#1523](https://github.com/ethyca/fides/pull/1523)
* Remove thrown exception from getAllPrivacyRequests method [#1592](https://github.com/ethyca/fides/pull/1593)
* Include systems without a privacy declaration on data map [#1603](https://github.com/ethyca/fides/pull/1603)


### Docs
Expand Down
104 changes: 64 additions & 40 deletions src/fides/ctl/core/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
)
from fides.ctl.core.utils import echo_green, get_all_level_fields

EMPTY_COLUMN_PLACEHOLDER = "N/A"


def generate_dataset_records(
server_dataset_list: List,
Expand Down Expand Up @@ -174,45 +176,67 @@ def generate_system_records(
system.data_protection_impact_assessment.dict()
)
)
for declaration in system.privacy_declarations:
data_use = formatted_data_uses[declaration.data_use]
data_categories = declaration.data_categories or []
data_subjects = [
formatted_data_subjects[data_subject_fides_key]
for data_subject_fides_key in declaration.data_subjects
]
dataset_references = declaration.dataset_references or ["N/A"]
cartesian_product_of_declaration = [
(
system.fides_key,
system.name,
system.description,
system.data_responsibility_title,
system.administrating_department,
third_country_list,
system_dependencies,
declaration.name,
category,
data_use["name"],
data_use["legal_basis"],
data_use["special_category"],
data_use["recipients"],
data_use["legitimate_interest"],
data_use["legitimate_interest_impact_assessment"],
subject["name"],
subject["rights_available"],
subject["automated_decisions_or_profiling"],
declaration.data_qualifier,
data_protection_impact_assessment["is_required"],
data_protection_impact_assessment["progress"],
data_protection_impact_assessment["link"],
dataset_reference,
)
for category in data_categories
for subject in data_subjects
for dataset_reference in dataset_references
if system.privacy_declarations:
for declaration in system.privacy_declarations:
data_use = formatted_data_uses[declaration.data_use]
data_categories = declaration.data_categories or []
data_subjects = [
formatted_data_subjects[data_subject_fides_key]
for data_subject_fides_key in declaration.data_subjects
]
dataset_references = declaration.dataset_references or [
EMPTY_COLUMN_PLACEHOLDER
]
cartesian_product_of_declaration = [
(
system.fides_key,
system.name,
system.description,
system.data_responsibility_title,
system.administrating_department,
third_country_list,
system_dependencies,
declaration.name,
category,
data_use["name"],
data_use["legal_basis"],
data_use["special_category"],
data_use["recipients"],
data_use["legitimate_interest"],
data_use["legitimate_interest_impact_assessment"],
subject["name"],
subject["rights_available"],
subject["automated_decisions_or_profiling"],
declaration.data_qualifier,
data_protection_impact_assessment["is_required"],
data_protection_impact_assessment["progress"],
data_protection_impact_assessment["link"],
dataset_reference,
)
for category in data_categories
for subject in data_subjects
for dataset_reference in dataset_references
]
output_list += cartesian_product_of_declaration
else:
system_row = [
system.fides_key,
system.name,
system.description,
system.data_responsibility_title,
system.administrating_department,
third_country_list,
system_dependencies,
data_protection_impact_assessment["is_required"],
data_protection_impact_assessment["progress"],
data_protection_impact_assessment["link"],
]
output_list += cartesian_product_of_declaration
length_to_na = 12
start_position = 6
SteveDMurphy marked this conversation as resolved.
Show resolved Hide resolved
for i in range(length_to_na):
system_row.insert(i + start_position, EMPTY_COLUMN_PLACEHOLDER)
system_row.append(EMPTY_COLUMN_PLACEHOLDER)
SteveDMurphy marked this conversation as resolved.
Show resolved Hide resolved
output_list += [tuple(system_row)]

return output_list

Expand Down Expand Up @@ -376,7 +400,7 @@ def build_joined_dataframe(

# merge systems and datasets
joined_df = systems_df.merge(datasets_df, how="left", on=["dataset.fides_key"])
joined_df.fillna("N/A", inplace=True)
joined_df.fillna(EMPTY_COLUMN_PLACEHOLDER, inplace=True)
## create a set of third_country attrs to combine as a single entity
joined_df["third_country_combined"] = [
convert_tuple_to_string(i)
Expand Down Expand Up @@ -408,7 +432,7 @@ def build_joined_dataframe(
> 1
].drop_duplicates()

delete_df["dataset.name"] = "N/A"
delete_df["dataset.name"] = EMPTY_COLUMN_PLACEHOLDER

joined_df = (
pd.merge(joined_df, delete_df, indicator=True, how="outer")
Expand Down
14 changes: 14 additions & 0 deletions tests/ctl/core/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ def test_system_records_to_export(
assert len(output_list) == 3


@pytest.mark.unit
def test_system_records_to_export_sans_privacy_declaration(
test_sample_system_taxonomy: Generator, test_config: FidesConfig
) -> None:
"""
Asserts that unique records for systems without a privacy declaratopm
SteveDMurphy marked this conversation as resolved.
Show resolved Hide resolved
are returned properly (including the header row)
"""
test_sample_system_taxonomy["system"][0].privacy_declarations = []
output_list = export.generate_system_records(test_sample_system_taxonomy)
print(output_list)
assert len(output_list) == 2


@pytest.mark.unit
def test_dataset_records_to_export(test_sample_dataset_taxonomy: Generator) -> None:
"""
Expand Down