Skip to content

Commit

Permalink
Issue1456: Fix for persistent email reminders (data-dot-all#1457)
Browse files Browse the repository at this point in the history
### Feature or Bugfix
- Bugfix

### Relates
- data-dot-all#1456

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Anushka Singh <[email protected]>
Co-authored-by: trajopadhye <[email protected]>
Co-authored-by: Mohit Arora <[email protected]>
Co-authored-by: rbernota <[email protected]>
Co-authored-by: Rick Bernotas <[email protected]>
Co-authored-by: Raj Chopde <[email protected]>
Co-authored-by: Noah Paige <[email protected]>
Co-authored-by: dlpzx <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jaidisido <[email protected]>
Co-authored-by: dlpzx <[email protected]>
Co-authored-by: mourya-33 <[email protected]>
Co-authored-by: nikpodsh <[email protected]>
Co-authored-by: MK <[email protected]>
Co-authored-by: Manjula <[email protected]>
Co-authored-by: Zilvinas Saltys <[email protected]>
Co-authored-by: Zilvinas Saltys <[email protected]>
Co-authored-by: Daniel Lorch <[email protected]>
Co-authored-by: Tejas Rajopadhye <[email protected]>
Co-authored-by: Zilvinas Saltys <[email protected]>
Co-authored-by: Sofia Sazonova <[email protected]>
Co-authored-by: Sofia Sazonova <[email protected]>
  • Loading branch information
23 people authored Aug 6, 2024
1 parent 5dd10c9 commit f69af72
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
25 changes: 12 additions & 13 deletions backend/dataall/modules/shares_base/db/share_object_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,16 @@ def fetch_submitted_shares_with_notifications(session):
A method used by the scheduled ECS Task to run fetch_submitted_shares_with_notifications() process against ALL shared objects in ALL
active share objects within dataall
"""
with session() as session:
pending_shares = (
session.query(ShareObject)
.join(
Notification,
and_(
ShareObject.shareUri == func.split_part(Notification.target_uri, '|', 1),
ShareObject.datasetUri == func.split_part(Notification.target_uri, '|', 2),
),
)
.filter(and_(Notification.type == 'SHARE_OBJECT_SUBMITTED', ShareObject.status == 'Submitted'))
.all()
pending_shares = (
session.query(ShareObject)
.join(
Notification,
and_(
ShareObject.shareUri == func.split_part(Notification.target_uri, '|', 1),
ShareObject.datasetUri == func.split_part(Notification.target_uri, '|', 2),
),
)
return pending_shares
.filter(and_(Notification.type == 'SHARE_OBJECT_SUBMITTED', ShareObject.status == 'Submitted'))
.all()
)
return pending_shares
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import logging
import os
import sys
from dataall.base.loader import load_modules, ImportMode
from dataall.modules.shares_base.db.share_object_models import ShareObject
from dataall.base.db import get_engine
from dataall.base.aws.sqs import SqsQueue
from dataall.core.tasks.service_handlers import Worker
from backend.dataall.modules.shares_base.db.share_object_repositories import ShareObjectRepository
from dataall.modules.shares_base.db.share_object_repositories import ShareObjectRepository
from dataall.modules.shares_base.services.share_notification_service import ShareNotificationService
from dataall.modules.datasets_base.db.dataset_repositories import DatasetBaseRepository

Expand Down Expand Up @@ -39,6 +38,7 @@ def persistent_email_reminders(engine):


if __name__ == '__main__':
load_modules(modes={ImportMode.SHARES_TASK})
ENVNAME = os.environ.get('envname', 'local')
ENGINE = get_engine(envname=ENVNAME)
persistent_email_reminders(engine=ENGINE)
8 changes: 7 additions & 1 deletion deploy/stacks/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def __init__(
# This is used for sending data.all share weblinks in the email notifications.
if custom_domain and custom_domain.get('hosted_zone_name'):
self.env_vars.update({'frontend_domain_url': f'https://{custom_domain["hosted_zone_name"]}'})
email_sender = (
custom_domain.get('email_notification_sender_email_id', 'noreply')
+ '@'
+ custom_domain.get('hosted_zone_name')
)
self.env_vars.update({'email_sender_id': email_sender})

cluster = ecs.Cluster(
self,
Expand Down Expand Up @@ -330,7 +336,7 @@ def add_share_reapplier_task(self):

self.ecs_task_definitions_families.append(share_reapplier_task_definition.family)

@run_if(['modules.dataset_base.features.share_notifications.email.persistent_reminders'])
@run_if(['modules.datasets_base.features.share_notifications.email.persistent_reminders'])
def add_persistent_email_reminders_task(self):
persistent_email_reminders_task, persistent_email_reminders_task_def = self.set_scheduled_task(
cluster=self.ecs_cluster,
Expand Down

0 comments on commit f69af72

Please sign in to comment.