ethyca-fides 2.67.2b3__py2.py3-none-any.whl → 2.67.2rc0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ethyca-fides might be problematic. Click here for more details.
- {ethyca_fides-2.67.2b3.dist-info → ethyca_fides-2.67.2rc0.dist-info}/METADATA +2 -2
- {ethyca_fides-2.67.2b3.dist-info → ethyca_fides-2.67.2rc0.dist-info}/RECORD +112 -114
- fides/_version.py +3 -3
- fides/api/db/crud.py +41 -24
- fides/api/graph/traversal.py +1 -1
- fides/api/main.py +1 -2
- fides/api/models/detection_discovery/core.py +20 -33
- fides/api/models/manual_task/manual_task.py +6 -3
- fides/api/models/privacy_request/privacy_request.py +0 -78
- fides/api/service/privacy_request/dsr_package/dsr_report_builder.py +19 -3
- fides/api/task/conditional_dependencies/evaluator.py +19 -12
- fides/api/task/conditional_dependencies/schemas.py +0 -51
- fides/api/task/create_request_tasks.py +3 -5
- fides/api/task/filter_results.py +1 -1
- fides/api/task/manual/manual_task_address.py +2 -4
- fides/api/task/manual/manual_task_graph_task.py +83 -87
- fides/api/task/manual/manual_task_utils.py +201 -84
- fides/api/tasks/storage.py +0 -3
- fides/api/util/aws_util.py +13 -1
- fides/api/util/storage_util.py +0 -19
- fides/config/__init__.py +0 -4
- fides/config/config_proxy.py +0 -7
- fides/config/utils.py +0 -1
- fides/ui-build/static/admin/404.html +1 -1
- fides/ui-build/static/admin/_next/static/{4v0_8k2Uo2QWG7nSdQ6A3 → Y7C7V1jdXK7rWXDIdtD13}/_buildManifest.js +1 -1
- fides/ui-build/static/admin/_next/static/chunks/pages/integrations/{[id]-330475705adbd36f.js → [id]-e0a755c69081fffa.js} +1 -1
- fides/ui-build/static/admin/add-systems/manual.html +1 -1
- fides/ui-build/static/admin/add-systems/multiple.html +1 -1
- fides/ui-build/static/admin/add-systems.html +1 -1
- fides/ui-build/static/admin/consent/configure/add-vendors.html +1 -1
- fides/ui-build/static/admin/consent/configure.html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience/[id].html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience/new.html +1 -1
- fides/ui-build/static/admin/consent/privacy-experience.html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices/[id].html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices/new.html +1 -1
- fides/ui-build/static/admin/consent/privacy-notices.html +1 -1
- fides/ui-build/static/admin/consent/properties.html +1 -1
- fides/ui-build/static/admin/consent/reporting.html +1 -1
- fides/ui-build/static/admin/consent.html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects/[projectUrn]/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects/[projectUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/projects.html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/resources/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-catalog/[systemId]/resources.html +1 -1
- fides/ui-build/static/admin/data-catalog.html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center/[monitorId]/[systemId].html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center/[monitorId].html +1 -1
- fides/ui-build/static/admin/data-discovery/action-center.html +1 -1
- fides/ui-build/static/admin/data-discovery/activity.html +1 -1
- fides/ui-build/static/admin/data-discovery/detection/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-discovery/detection.html +1 -1
- fides/ui-build/static/admin/data-discovery/discovery/[resourceUrn].html +1 -1
- fides/ui-build/static/admin/data-discovery/discovery.html +1 -1
- fides/ui-build/static/admin/datamap.html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId]/[collectionName]/[...subfieldNames].html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId]/[collectionName].html +1 -1
- fides/ui-build/static/admin/dataset/[datasetId].html +1 -1
- fides/ui-build/static/admin/dataset/new.html +1 -1
- fides/ui-build/static/admin/dataset.html +1 -1
- fides/ui-build/static/admin/datastore-connection/[id].html +1 -1
- fides/ui-build/static/admin/datastore-connection/new.html +1 -1
- fides/ui-build/static/admin/datastore-connection.html +1 -1
- fides/ui-build/static/admin/index.html +1 -1
- fides/ui-build/static/admin/integrations/[id].html +1 -1
- fides/ui-build/static/admin/integrations.html +1 -1
- fides/ui-build/static/admin/lib/fides-preview.js +1 -1
- fides/ui-build/static/admin/login/[provider].html +1 -1
- fides/ui-build/static/admin/login.html +1 -1
- fides/ui-build/static/admin/messaging/[id].html +1 -1
- fides/ui-build/static/admin/messaging/add-template.html +1 -1
- fides/ui-build/static/admin/messaging.html +1 -1
- fides/ui-build/static/admin/poc/ant-components.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/AntForm.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikAntFormItem.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikControlled.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikField.html +1 -1
- fides/ui-build/static/admin/poc/form-experiments/FormikSpreadField.html +1 -1
- fides/ui-build/static/admin/poc/forms.html +1 -1
- fides/ui-build/static/admin/poc/table-migration.html +1 -1
- fides/ui-build/static/admin/privacy-requests/[id].html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure/messaging.html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure/storage.html +1 -1
- fides/ui-build/static/admin/privacy-requests/configure.html +1 -1
- fides/ui-build/static/admin/privacy-requests.html +1 -1
- fides/ui-build/static/admin/properties/[id].html +1 -1
- fides/ui-build/static/admin/properties/add-property.html +1 -1
- fides/ui-build/static/admin/properties.html +1 -1
- fides/ui-build/static/admin/reporting/datamap.html +1 -1
- fides/ui-build/static/admin/settings/about/alpha.html +1 -1
- fides/ui-build/static/admin/settings/about.html +1 -1
- fides/ui-build/static/admin/settings/consent/[configuration_id]/[purpose_id].html +1 -1
- fides/ui-build/static/admin/settings/consent.html +1 -1
- fides/ui-build/static/admin/settings/custom-fields.html +1 -1
- fides/ui-build/static/admin/settings/domain-records.html +1 -1
- fides/ui-build/static/admin/settings/domains.html +1 -1
- fides/ui-build/static/admin/settings/email-templates.html +1 -1
- fides/ui-build/static/admin/settings/locations.html +1 -1
- fides/ui-build/static/admin/settings/organization.html +1 -1
- fides/ui-build/static/admin/settings/regulations.html +1 -1
- fides/ui-build/static/admin/systems/configure/[id]/test-datasets.html +1 -1
- fides/ui-build/static/admin/systems/configure/[id].html +1 -1
- fides/ui-build/static/admin/systems.html +1 -1
- fides/ui-build/static/admin/taxonomy.html +1 -1
- fides/ui-build/static/admin/user-management/new.html +1 -1
- fides/ui-build/static/admin/user-management/profile/[id].html +1 -1
- fides/ui-build/static/admin/user-management.html +1 -1
- fides/api/task/conditional_dependencies/operators.py +0 -150
- fides/config/privacy_center_settings.py +0 -17
- {ethyca_fides-2.67.2b3.dist-info → ethyca_fides-2.67.2rc0.dist-info}/WHEEL +0 -0
- {ethyca_fides-2.67.2b3.dist-info → ethyca_fides-2.67.2rc0.dist-info}/entry_points.txt +0 -0
- {ethyca_fides-2.67.2b3.dist-info → ethyca_fides-2.67.2rc0.dist-info}/licenses/LICENSE +0 -0
- {ethyca_fides-2.67.2b3.dist-info → ethyca_fides-2.67.2rc0.dist-info}/top_level.txt +0 -0
- /fides/ui-build/static/admin/_next/static/{4v0_8k2Uo2QWG7nSdQ6A3 → Y7C7V1jdXK7rWXDIdtD13}/_ssgManifest.js +0 -0
|
@@ -7,11 +7,11 @@ from fides.api.common_exceptions import AwaitingAsyncTaskCallback
|
|
|
7
7
|
from fides.api.models.attachment import AttachmentType
|
|
8
8
|
from fides.api.models.manual_task import (
|
|
9
9
|
ManualTask,
|
|
10
|
+
ManualTaskConfig,
|
|
10
11
|
ManualTaskConfigurationType,
|
|
11
12
|
ManualTaskEntityType,
|
|
12
13
|
ManualTaskFieldType,
|
|
13
14
|
ManualTaskInstance,
|
|
14
|
-
ManualTaskSubmission,
|
|
15
15
|
StatusType,
|
|
16
16
|
)
|
|
17
17
|
from fides.api.models.privacy_request import PrivacyRequest
|
|
@@ -23,7 +23,6 @@ from fides.api.task.manual.manual_task_utils import (
|
|
|
23
23
|
get_manual_task_for_connection_config,
|
|
24
24
|
)
|
|
25
25
|
from fides.api.util.collection_util import Row
|
|
26
|
-
from fides.api.util.storage_util import format_size
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
class ManualTaskGraphTask(GraphTask):
|
|
@@ -123,36 +122,29 @@ class ManualTaskGraphTask(GraphTask):
|
|
|
123
122
|
# request has started, while allowing different config types (access vs erasure)
|
|
124
123
|
# to have separate instances.
|
|
125
124
|
# ------------------------------------------------------------------
|
|
126
|
-
existing_task_instance =
|
|
127
|
-
(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
existing_task_instance = (
|
|
126
|
+
db.query(ManualTaskInstance)
|
|
127
|
+
.join(ManualTaskInstance.config) # Join to access config information
|
|
128
|
+
.filter(
|
|
129
|
+
ManualTaskInstance.task_id == manual_task.id,
|
|
130
|
+
ManualTaskInstance.entity_id == privacy_request.id,
|
|
131
|
+
ManualTaskInstance.entity_type == ManualTaskEntityType.privacy_request,
|
|
132
|
+
# Only check for instances of the same config type
|
|
133
|
+
ManualTaskConfig.config_type == allowed_config_type,
|
|
134
|
+
)
|
|
135
|
+
.first()
|
|
134
136
|
)
|
|
135
137
|
if existing_task_instance:
|
|
136
138
|
# An instance already exists for this privacy request and config type – no need
|
|
137
139
|
# to create another one tied to a newer config version.
|
|
138
140
|
return
|
|
139
141
|
|
|
140
|
-
#
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
for config in sorted(
|
|
146
|
-
manual_task.configs,
|
|
147
|
-
key=lambda c: c.version if hasattr(c, "version") else 0,
|
|
148
|
-
reverse=True,
|
|
149
|
-
)
|
|
150
|
-
if config.is_current and config.config_type == allowed_config_type
|
|
151
|
-
),
|
|
152
|
-
None,
|
|
153
|
-
)
|
|
142
|
+
# Check each active config for instances (now we know none exist yet for this config type)
|
|
143
|
+
for config in manual_task.configs:
|
|
144
|
+
if not config.is_current or config.config_type != allowed_config_type:
|
|
145
|
+
# Skip configs that are not current or not relevant for this request type
|
|
146
|
+
continue
|
|
154
147
|
|
|
155
|
-
if config:
|
|
156
148
|
ManualTaskInstance.create(
|
|
157
149
|
db=db,
|
|
158
150
|
data={
|
|
@@ -164,6 +156,7 @@ class ManualTaskGraphTask(GraphTask):
|
|
|
164
156
|
},
|
|
165
157
|
)
|
|
166
158
|
|
|
159
|
+
# pylint: disable=too-many-branches,too-many-nested-blocks
|
|
167
160
|
def _get_submitted_data(
|
|
168
161
|
self,
|
|
169
162
|
db: Session,
|
|
@@ -175,90 +168,93 @@ class ManualTaskGraphTask(GraphTask):
|
|
|
175
168
|
Check if all manual task instances have submissions for ALL fields and return aggregated data
|
|
176
169
|
Returns None if any field submissions are missing (all fields must be completed or skipped)
|
|
177
170
|
"""
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
171
|
+
aggregated_data: dict[str, Any] = {}
|
|
172
|
+
|
|
173
|
+
def _format_size(size_bytes: int) -> str:
|
|
174
|
+
units = ["B", "KB", "MB", "GB", "TB"]
|
|
175
|
+
size = float(size_bytes)
|
|
176
|
+
for unit in units:
|
|
177
|
+
if size < 1024.0:
|
|
178
|
+
return f"{size:.1f} {unit}"
|
|
179
|
+
size /= 1024.0
|
|
180
|
+
return f"{size:.1f} PB"
|
|
181
|
+
|
|
182
|
+
candidate_instances: list[ManualTaskInstance] = (
|
|
183
|
+
db.query(ManualTaskInstance)
|
|
184
|
+
.filter(
|
|
185
|
+
ManualTaskInstance.task_id == manual_task.id,
|
|
186
|
+
ManualTaskInstance.entity_id == privacy_request.id,
|
|
187
|
+
ManualTaskInstance.entity_type == ManualTaskEntityType.privacy_request,
|
|
188
|
+
)
|
|
189
|
+
.all()
|
|
190
|
+
)
|
|
184
191
|
|
|
185
192
|
if not candidate_instances:
|
|
186
193
|
return None # No instance yet for this manual task
|
|
187
194
|
|
|
188
|
-
# Check for incomplete fields and update status in single pass
|
|
189
195
|
for inst in candidate_instances:
|
|
190
|
-
|
|
196
|
+
# Skip instances tied to other request types
|
|
197
|
+
if not inst.config or inst.config.config_type != allowed_config_type:
|
|
198
|
+
continue
|
|
199
|
+
|
|
200
|
+
all_fields = inst.config.field_definitions or []
|
|
201
|
+
|
|
202
|
+
# Every field must have a submission
|
|
203
|
+
if not all(inst.get_submission_for_field(f.id) for f in all_fields):
|
|
191
204
|
return None # At least one instance still incomplete
|
|
192
205
|
|
|
193
|
-
#
|
|
206
|
+
# Ensure status set
|
|
194
207
|
if inst.status != StatusType.completed:
|
|
195
208
|
inst.status = StatusType.completed
|
|
196
209
|
inst.save(db)
|
|
197
210
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
def _aggregate_submission_data(
|
|
203
|
-
self, instances: list[ManualTaskInstance]
|
|
204
|
-
) -> dict[str, Any]:
|
|
205
|
-
"""Aggregate submission data from all instances into a single dictionary."""
|
|
206
|
-
aggregated_data: dict[str, Any] = {}
|
|
207
|
-
|
|
208
|
-
for inst in instances:
|
|
209
|
-
# Filter valid submissions and process them
|
|
210
|
-
valid_submissions = (
|
|
211
|
-
submission
|
|
212
|
-
for submission in inst.submissions
|
|
213
|
-
if (
|
|
214
|
-
submission.field
|
|
215
|
-
and submission.field.field_key
|
|
216
|
-
and isinstance(submission.data, dict)
|
|
217
|
-
)
|
|
218
|
-
)
|
|
211
|
+
# Aggregate submission data from this instance
|
|
212
|
+
for submission in inst.submissions:
|
|
213
|
+
if not submission.field or not submission.field.field_key:
|
|
214
|
+
continue
|
|
219
215
|
|
|
220
|
-
for submission in valid_submissions:
|
|
221
216
|
field_key = submission.field.field_key
|
|
222
|
-
# We already checked isinstance(submission.data, dict) in valid_submissions
|
|
223
|
-
data_dict: dict[str, Any] = submission.data # type: ignore[assignment]
|
|
224
|
-
field_type = data_dict.get("field_type")
|
|
225
217
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
self._process_attachment_field(submission)
|
|
229
|
-
if field_type == ManualTaskFieldType.attachment.value
|
|
230
|
-
else data_dict.get("value")
|
|
231
|
-
)
|
|
218
|
+
if not isinstance(submission.data, dict):
|
|
219
|
+
continue
|
|
232
220
|
|
|
233
|
-
|
|
221
|
+
data_dict: dict[str, Any] = submission.data
|
|
234
222
|
|
|
235
|
-
|
|
236
|
-
self, submission: ManualTaskSubmission
|
|
237
|
-
) -> Optional[dict[str, dict[str, Any]]]:
|
|
238
|
-
"""Process attachment field and return attachment map or None."""
|
|
239
|
-
attachment_map: dict[str, dict[str, Any]] = {}
|
|
223
|
+
field_type = data_dict.get("field_type")
|
|
240
224
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
225
|
+
if field_type == ManualTaskFieldType.attachment.value:
|
|
226
|
+
attachment_map: dict[str, dict[str, Any]] = {}
|
|
227
|
+
for attachment in submission.attachments or []:
|
|
228
|
+
if (
|
|
229
|
+
attachment.attachment_type
|
|
230
|
+
== AttachmentType.include_with_access_package
|
|
231
|
+
):
|
|
232
|
+
try:
|
|
233
|
+
size, url = attachment.retrieve_attachment()
|
|
234
|
+
attachment_map[attachment.file_name] = {
|
|
235
|
+
"url": str(url) if url else None,
|
|
236
|
+
"size": (_format_size(size) if size else "Unknown"),
|
|
237
|
+
}
|
|
238
|
+
except (
|
|
239
|
+
Exception
|
|
240
|
+
) as exc: # pylint: disable=broad-exception-caught
|
|
241
|
+
logger.warning(
|
|
242
|
+
"Error retrieving attachment {}: {}",
|
|
243
|
+
attachment.file_name,
|
|
244
|
+
str(exc),
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
aggregated_data[field_key] = attachment_map or None
|
|
248
|
+
else:
|
|
249
|
+
aggregated_data[field_key] = data_dict.get("value")
|
|
250
|
+
|
|
251
|
+
return aggregated_data if aggregated_data else None
|
|
256
252
|
|
|
257
253
|
def dry_run_task(self) -> int:
|
|
258
254
|
"""Return estimated row count for dry run - manual tasks don't have predictable counts"""
|
|
259
255
|
return 1 # Placeholder - manual tasks generate variable data
|
|
260
256
|
|
|
261
|
-
# Provide erasure support for manual tasks
|
|
257
|
+
# NEW METHOD: Provide erasure support for manual tasks
|
|
262
258
|
@retry(action_type=ActionType.erasure, default_return=0)
|
|
263
259
|
def erasure_request(
|
|
264
260
|
self,
|
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
from typing import Optional
|
|
2
|
-
|
|
3
|
-
from loguru import logger
|
|
4
1
|
from sqlalchemy.orm import Session
|
|
5
2
|
|
|
6
3
|
from fides.api.graph.config import (
|
|
7
4
|
Collection,
|
|
8
5
|
CollectionAddress,
|
|
9
|
-
|
|
6
|
+
Field,
|
|
10
7
|
GraphDataset,
|
|
11
8
|
ScalarField,
|
|
12
9
|
)
|
|
10
|
+
from fides.api.graph.graph import Node
|
|
11
|
+
from fides.api.graph.traversal import TraversalNode
|
|
13
12
|
from fides.api.models.connectionconfig import ConnectionConfig
|
|
14
13
|
|
|
15
14
|
# Import application models
|
|
16
15
|
from fides.api.models.manual_task import (
|
|
17
16
|
ManualTask,
|
|
18
|
-
|
|
17
|
+
ManualTaskConfig,
|
|
19
18
|
ManualTaskConfigurationType,
|
|
19
|
+
ManualTaskEntityType,
|
|
20
|
+
ManualTaskInstance,
|
|
20
21
|
)
|
|
22
|
+
from fides.api.models.privacy_request import PrivacyRequest
|
|
23
|
+
from fides.api.schemas.policy import ActionType
|
|
21
24
|
from fides.api.task.manual.manual_task_address import ManualTaskAddress
|
|
22
25
|
|
|
23
|
-
PRIVACY_REQUEST_CONFIG_TYPES = {
|
|
24
|
-
ManualTaskConfigurationType.access_privacy_request,
|
|
25
|
-
ManualTaskConfigurationType.erasure_privacy_request,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
26
|
|
|
29
27
|
def get_connection_configs_with_manual_tasks(db: Session) -> list[ConnectionConfig]:
|
|
30
28
|
"""
|
|
31
29
|
Get all connection configs that have manual tasks.
|
|
32
30
|
"""
|
|
33
|
-
|
|
31
|
+
return (
|
|
34
32
|
db.query(ConnectionConfig)
|
|
35
33
|
.join(ManualTask, ConnectionConfig.id == ManualTask.parent_entity_id)
|
|
36
34
|
.filter(ManualTask.parent_entity_type == "connection_config")
|
|
37
35
|
.filter(ConnectionConfig.disabled.is_(False))
|
|
38
36
|
.all()
|
|
39
37
|
)
|
|
40
|
-
return connection_configs
|
|
41
38
|
|
|
42
39
|
|
|
43
40
|
def get_manual_task_addresses(db: Session) -> list[CollectionAddress]:
|
|
@@ -51,11 +48,12 @@ def get_manual_task_addresses(db: Session) -> list[CollectionAddress]:
|
|
|
51
48
|
# Get all connection configs that have manual tasks (excluding disabled ones)
|
|
52
49
|
connection_configs_with_manual_tasks = get_connection_configs_with_manual_tasks(db)
|
|
53
50
|
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
# Create addresses for all connections that have manual tasks
|
|
52
|
+
manual_task_addresses = []
|
|
53
|
+
for config in connection_configs_with_manual_tasks:
|
|
54
|
+
manual_task_addresses.append(ManualTaskAddress.create(config.key))
|
|
55
|
+
|
|
56
|
+
return manual_task_addresses
|
|
59
57
|
|
|
60
58
|
|
|
61
59
|
def get_manual_task_for_connection_config(
|
|
@@ -75,18 +73,20 @@ def get_manual_task_for_connection_config(
|
|
|
75
73
|
)
|
|
76
74
|
|
|
77
75
|
|
|
78
|
-
def
|
|
76
|
+
def create_manual_data_traversal_node(
|
|
77
|
+
db: Session, address: CollectionAddress
|
|
78
|
+
) -> "TraversalNode":
|
|
79
79
|
"""
|
|
80
|
-
Create
|
|
80
|
+
Create a TraversalNode for a manual_data collection
|
|
81
81
|
"""
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
]
|
|
89
|
-
for config in
|
|
82
|
+
connection_key = address.dataset
|
|
83
|
+
|
|
84
|
+
# Get manual tasks for this connection to determine fields
|
|
85
|
+
manual_task = get_manual_task_for_connection_config(db, connection_key)
|
|
86
|
+
|
|
87
|
+
# Create fields based on ManualTaskConfigFields
|
|
88
|
+
fields: list[Field] = []
|
|
89
|
+
for config in manual_task.configs:
|
|
90
90
|
for field in config.field_definitions:
|
|
91
91
|
# Create a scalar field for each manual task field
|
|
92
92
|
# Extract data categories from field metadata if available
|
|
@@ -99,94 +99,211 @@ def create_data_category_scalar_fields(manual_task: ManualTask) -> list[ScalarFi
|
|
|
99
99
|
# Manual task fields don't have complex relationships
|
|
100
100
|
)
|
|
101
101
|
fields.append(scalar_field)
|
|
102
|
-
return fields
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def create_conditional_dependency_scalar_fields(
|
|
106
|
-
field_addresses: set[str],
|
|
107
|
-
) -> list[ScalarField]:
|
|
108
|
-
fields: list[ScalarField] = []
|
|
109
|
-
for field_address in field_addresses:
|
|
110
|
-
# Use the full field address as the field name to preserve collection context
|
|
111
|
-
# This allows the manual task to receive data from specific collections
|
|
112
|
-
# e.g., "user.name" or "customer.profile.email" instead of just "name" or "email"
|
|
113
|
-
logger.info(
|
|
114
|
-
f"Creating conditional dependency scalar field for field address: {field_address}"
|
|
115
|
-
)
|
|
116
|
-
field_address_obj = FieldAddress.from_string(field_address)
|
|
117
102
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)
|
|
124
|
-
|
|
103
|
+
# Create a synthetic Collection
|
|
104
|
+
collection = Collection(
|
|
105
|
+
name=ManualTaskAddress.MANUAL_DATA_COLLECTION,
|
|
106
|
+
fields=fields,
|
|
107
|
+
# Manual tasks don't have complex dependencies
|
|
108
|
+
after=set(),
|
|
109
|
+
)
|
|
125
110
|
|
|
126
|
-
|
|
111
|
+
# Create a synthetic GraphDataset
|
|
112
|
+
dataset = GraphDataset(
|
|
113
|
+
name=connection_key,
|
|
114
|
+
collections=[collection],
|
|
115
|
+
connection_key=connection_key,
|
|
116
|
+
after=set(),
|
|
117
|
+
)
|
|
127
118
|
|
|
119
|
+
node = Node(dataset, collection)
|
|
120
|
+
traversal_node = TraversalNode(node)
|
|
128
121
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
return traversal_node
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def create_manual_task_instances_for_privacy_request(
|
|
126
|
+
db: Session, privacy_request: PrivacyRequest
|
|
127
|
+
) -> list[ManualTaskInstance]:
|
|
128
|
+
"""Create ManualTaskInstance entries for all active manual tasks relevant to a privacy request."""
|
|
129
|
+
instances = []
|
|
130
|
+
|
|
131
|
+
# Get all connection configs that have manual tasks (excluding disabled ones)
|
|
132
|
+
connection_configs_with_manual_tasks = get_connection_configs_with_manual_tasks(db)
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
for dependency in manual_task.conditional_dependencies
|
|
142
|
-
if dependency.condition_type == ManualTaskConditionalDependencyType.leaf
|
|
143
|
-
and dependency.field_address is not None
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
# Create scalar fields for data category fields and conditional dependency field addresses
|
|
147
|
-
fields: list[ScalarField] = []
|
|
148
|
-
fields.extend(create_data_category_scalar_fields(manual_task))
|
|
149
|
-
fields.extend(
|
|
150
|
-
create_conditional_dependency_scalar_fields(conditional_field_addresses)
|
|
134
|
+
# Determine the privacy request type based on policy rules
|
|
135
|
+
has_access_rules = bool(
|
|
136
|
+
privacy_request.policy.get_rules_for_action(action_type=ActionType.access)
|
|
137
|
+
)
|
|
138
|
+
has_erasure_rules = bool(
|
|
139
|
+
privacy_request.policy.get_rules_for_action(action_type=ActionType.erasure)
|
|
151
140
|
)
|
|
152
141
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
142
|
+
for connection_config in connection_configs_with_manual_tasks:
|
|
143
|
+
manual_tasks = (
|
|
144
|
+
db.query(ManualTask)
|
|
145
|
+
.filter(
|
|
146
|
+
ManualTask.parent_entity_id == connection_config.id,
|
|
147
|
+
ManualTask.parent_entity_type == "connection_config",
|
|
148
|
+
)
|
|
149
|
+
.all()
|
|
150
|
+
)
|
|
156
151
|
|
|
157
|
-
|
|
152
|
+
for manual_task in manual_tasks:
|
|
153
|
+
# Get the active config for this manual task, filtered by request type
|
|
154
|
+
active_config_query = db.query(ManualTaskConfig).filter(
|
|
155
|
+
ManualTaskConfig.task_id == manual_task.id,
|
|
156
|
+
ManualTaskConfig.is_current.is_(True),
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
# Filter by configuration type based on privacy request type
|
|
160
|
+
if has_access_rules and has_erasure_rules:
|
|
161
|
+
# If both access and erasure rules exist, include both types
|
|
162
|
+
active_config_query = active_config_query.filter(
|
|
163
|
+
ManualTaskConfig.config_type.in_(
|
|
164
|
+
[
|
|
165
|
+
ManualTaskConfigurationType.access_privacy_request,
|
|
166
|
+
ManualTaskConfigurationType.erasure_privacy_request,
|
|
167
|
+
]
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
elif has_access_rules:
|
|
171
|
+
# Only access rules - only include access configurations
|
|
172
|
+
active_config_query = active_config_query.filter(
|
|
173
|
+
ManualTaskConfig.config_type
|
|
174
|
+
== ManualTaskConfigurationType.access_privacy_request
|
|
175
|
+
)
|
|
176
|
+
elif has_erasure_rules:
|
|
177
|
+
# Only erasure rules - only include erasure configurations
|
|
178
|
+
active_config_query = active_config_query.filter(
|
|
179
|
+
ManualTaskConfig.config_type
|
|
180
|
+
== ManualTaskConfigurationType.erasure_privacy_request
|
|
181
|
+
)
|
|
182
|
+
else:
|
|
183
|
+
# No relevant rules - skip this manual task
|
|
184
|
+
continue
|
|
185
|
+
|
|
186
|
+
active_configs = active_config_query.all()
|
|
187
|
+
|
|
188
|
+
if not active_configs:
|
|
189
|
+
continue # Skip if no active configs
|
|
190
|
+
|
|
191
|
+
# Create instances for each active config
|
|
192
|
+
for active_config in active_configs:
|
|
193
|
+
# Check if instance already exists for this config
|
|
194
|
+
existing_instance = (
|
|
195
|
+
db.query(ManualTaskInstance)
|
|
196
|
+
.filter(
|
|
197
|
+
ManualTaskInstance.entity_id == privacy_request.id,
|
|
198
|
+
ManualTaskInstance.entity_type == "privacy_request",
|
|
199
|
+
ManualTaskInstance.task_id == manual_task.id,
|
|
200
|
+
ManualTaskInstance.config_id == active_config.id,
|
|
201
|
+
)
|
|
202
|
+
.first()
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
if not existing_instance:
|
|
206
|
+
instance = ManualTaskInstance(
|
|
207
|
+
entity_id=privacy_request.id,
|
|
208
|
+
entity_type=ManualTaskEntityType.privacy_request,
|
|
209
|
+
task_id=manual_task.id,
|
|
210
|
+
config_id=active_config.id,
|
|
211
|
+
)
|
|
212
|
+
db.add(instance)
|
|
213
|
+
instances.append(instance)
|
|
214
|
+
|
|
215
|
+
if instances:
|
|
216
|
+
db.commit()
|
|
217
|
+
|
|
218
|
+
return instances
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def get_manual_task_instances_for_privacy_request(
|
|
222
|
+
db: Session, privacy_request: PrivacyRequest
|
|
223
|
+
) -> list[ManualTaskInstance]:
|
|
224
|
+
"""Get all manual task instances for a privacy request."""
|
|
225
|
+
return (
|
|
226
|
+
db.query(ManualTaskInstance)
|
|
227
|
+
.filter(
|
|
228
|
+
ManualTaskInstance.entity_id == privacy_request.id,
|
|
229
|
+
ManualTaskInstance.entity_type == "privacy_request",
|
|
230
|
+
)
|
|
231
|
+
.all()
|
|
232
|
+
)
|
|
158
233
|
|
|
159
234
|
|
|
160
|
-
def create_manual_task_artificial_graphs(
|
|
235
|
+
def create_manual_task_artificial_graphs(
|
|
236
|
+
db: Session,
|
|
237
|
+
) -> list:
|
|
161
238
|
"""
|
|
162
239
|
Create artificial GraphDataset objects for manual tasks that can be included
|
|
163
240
|
in the main dataset graph during the dataset configuration phase.
|
|
164
241
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
242
|
+
Manual tasks should be treated as data sources/datasets rather than being
|
|
243
|
+
appended to the traversal graph later.
|
|
244
|
+
|
|
245
|
+
Manual task collections are designed as root nodes that execute immediately when
|
|
246
|
+
the privacy request starts, in parallel with identity processing. They don't depend
|
|
247
|
+
on identity data since they provide manually-entered data rather than consuming it.
|
|
168
248
|
|
|
169
249
|
Args:
|
|
170
250
|
db: Database session
|
|
251
|
+
policy: The policy being executed (optional, for filtering manual task configs)
|
|
171
252
|
|
|
172
253
|
Returns:
|
|
173
|
-
List of GraphDataset objects representing manual tasks as
|
|
254
|
+
List of GraphDataset objects representing manual tasks as root nodes
|
|
174
255
|
"""
|
|
256
|
+
|
|
175
257
|
manual_task_graphs = []
|
|
176
258
|
manual_addresses = get_manual_task_addresses(db)
|
|
177
259
|
|
|
178
260
|
for address in manual_addresses:
|
|
179
261
|
connection_key = address.dataset
|
|
180
262
|
|
|
181
|
-
# Get
|
|
182
|
-
|
|
263
|
+
# Get manual tasks for this connection to determine fields
|
|
264
|
+
manual_task = get_manual_task_for_connection_config(db, connection_key)
|
|
265
|
+
|
|
266
|
+
# Create fields based only on ManualTaskConfigFields
|
|
267
|
+
fields: list = []
|
|
268
|
+
|
|
269
|
+
# Manual task collections act as root nodes - they don't need identity dependencies
|
|
270
|
+
# since they provide manually-entered data rather than consuming identity data.
|
|
271
|
+
current_configs = [
|
|
272
|
+
config for config in manual_task.configs if config.is_current
|
|
273
|
+
]
|
|
274
|
+
for config in current_configs:
|
|
275
|
+
if config.config_type not in [
|
|
276
|
+
ManualTaskConfigurationType.access_privacy_request,
|
|
277
|
+
ManualTaskConfigurationType.erasure_privacy_request,
|
|
278
|
+
]:
|
|
279
|
+
continue
|
|
280
|
+
|
|
281
|
+
for field in config.field_definitions:
|
|
282
|
+
# Create a scalar field for each manual task field
|
|
283
|
+
field_metadata = field.field_metadata or {}
|
|
284
|
+
data_categories = field_metadata.get("data_categories", [])
|
|
285
|
+
|
|
286
|
+
scalar_field = ScalarField(
|
|
287
|
+
name=field.field_key,
|
|
288
|
+
data_categories=data_categories,
|
|
289
|
+
)
|
|
290
|
+
fields.append(scalar_field)
|
|
291
|
+
|
|
292
|
+
if fields: # Only create graph if there are fields
|
|
293
|
+
# Create a synthetic Collection
|
|
294
|
+
collection = Collection(
|
|
295
|
+
name=ManualTaskAddress.MANUAL_DATA_COLLECTION,
|
|
296
|
+
fields=fields,
|
|
297
|
+
# Manual tasks have no dependencies - they're root nodes
|
|
298
|
+
after=set(),
|
|
299
|
+
)
|
|
183
300
|
|
|
184
|
-
|
|
185
|
-
# Create a synthetic GraphDataset with all manual task collections
|
|
301
|
+
# Create a synthetic GraphDataset
|
|
186
302
|
graph_dataset = GraphDataset(
|
|
187
303
|
name=connection_key,
|
|
188
304
|
collections=[collection],
|
|
189
305
|
connection_key=connection_key,
|
|
306
|
+
after=set(),
|
|
190
307
|
)
|
|
191
308
|
|
|
192
309
|
manual_task_graphs.append(graph_dataset)
|
fides/api/tasks/storage.py
CHANGED
|
@@ -122,9 +122,6 @@ def upload_to_s3( # pylint: disable=R0913
|
|
|
122
122
|
s3_client = get_s3_client(
|
|
123
123
|
auth_method,
|
|
124
124
|
storage_secrets,
|
|
125
|
-
assume_role_arn=CONFIG.credentials.get( # pylint: disable=no-member
|
|
126
|
-
"storage", {}
|
|
127
|
-
).get("aws_s3_assume_role_arn"),
|
|
128
125
|
)
|
|
129
126
|
except (ClientError, ParamValidationError) as e:
|
|
130
127
|
logger.error(f"Error getting s3 client: {str(e)}")
|
fides/api/util/aws_util.py
CHANGED
|
@@ -7,6 +7,7 @@ from loguru import logger
|
|
|
7
7
|
|
|
8
8
|
from fides.api.common_exceptions import StorageUploadError
|
|
9
9
|
from fides.api.schemas.storage.storage import AWSAuthMethod, StorageSecrets
|
|
10
|
+
from fides.config import CONFIG
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
def get_aws_session(
|
|
@@ -94,11 +95,22 @@ def get_s3_client(
|
|
|
94
95
|
|
|
95
96
|
If an `assume_role_arn` is provided, the secrets will be used to
|
|
96
97
|
assume that role and return a Session instantiated with that role.
|
|
98
|
+
|
|
99
|
+
If no `assume_role_arn` is provided, and `aws_s3_assume_role_arn` is
|
|
100
|
+
configured in the global `credentials.storage` config, then the secrets
|
|
101
|
+
will be used to assume that role and return a Session instantiated with
|
|
102
|
+
that role.
|
|
97
103
|
"""
|
|
104
|
+
|
|
105
|
+
configured_assume_role_arn = CONFIG.credentials.get( # pylint: disable=no-member
|
|
106
|
+
"storage", {}
|
|
107
|
+
).get( # pylint: disable=no-member
|
|
108
|
+
"aws_s3_assume_role_arn"
|
|
109
|
+
)
|
|
98
110
|
session = get_aws_session(
|
|
99
111
|
auth_method=auth_method,
|
|
100
112
|
storage_secrets=storage_secrets,
|
|
101
|
-
assume_role_arn=assume_role_arn,
|
|
113
|
+
assume_role_arn=assume_role_arn or configured_assume_role_arn,
|
|
102
114
|
)
|
|
103
115
|
|
|
104
116
|
# Configure S3 client to use signature version 4 for KMS compatibility
|