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

LA 88 segment md5 override #5514

Merged
merged 6 commits into from
Nov 20, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The types of changes are:
- Added namespace support for Snowflake [#5486](https://github.com/ethyca/fides/pull/5486)
- Added support for field-level masking overrides [#5446](https://github.com/ethyca/fides/pull/5446)
- Added BigQuery Enterprise access request integration test [#5504](https://github.com/ethyca/fides/pull/5504)
- Added MD5 email hashing for Segment's Right to Forget endpoint requests [#5514](https://github.com/ethyca/fides/pull/5514)

### Changed
- Allow hiding systems via a `hidden` parameter and add two flags on the `/system` api endpoint; `show_hidden` and `dnd_relevant`, to display only systems with integrations [#5484](https://github.com/ethyca/fides/pull/5484)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import hashlib
import json
from typing import Any, Dict, List

from fides.api.models.policy import Policy
from fides.api.models.privacy_request import PrivacyRequest
from fides.api.schemas.saas.shared_schemas import HTTPMethod, SaaSRequestParams
from fides.api.service.connectors.saas.authenticated_client import AuthenticatedClient
from fides.api.service.saas_request.saas_request_override_factory import (
SaaSRequestType,
register,
)


@register("segment_delete_md5", [SaaSRequestType.DELETE])
def segment_delete_md5(
client: AuthenticatedClient,
param_values_per_row: List[Dict[str, Any]],
policy: Policy,
privacy_request: PrivacyRequest,
secrets: Dict[str, Any],
) -> int:
rows_deleted = 0

headers = {
"Content-Type": "application/json",
}

for row_param_values in param_values_per_row:
email = row_param_values["email"]
hashed_email = hashlib.md5(email.encode("utf-8")).hexdigest()

payload = json.dumps(
{
"regulation_type": "Suppress_With_Delete",
"attributes": {"name": "userId", "values": [hashed_email]},
}
)

workspace_name = row_param_values["workspace_name"]

client.send(
SaaSRequestParams(
method=HTTPMethod.POST,
path=f"/v1beta/workspaces/{workspace_name}/regulations",
headers=headers,
body=payload,
)
)
rows_deleted += 1

return rows_deleted
Loading