Skip to content

Commit

Permalink
Add more debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Shumway committed Jul 23, 2024
1 parent bba3fb1 commit e956ca5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
7 changes: 2 additions & 5 deletions app/aws/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,12 @@ def extract_personalisation(job):
print(hilite(f"first_row again: {first_row}"))
personalisation = {}
job_row = 0

row_csv_module = csv.reader(job)
for row_module in row_csv_module:
print(hilite(f"CSV MODULE ROW: {row_module}"))

for row in job:
row = row.split(",")
for row in row_csv_module:
print(hilite(f"row: {row}"))
temp = dict(zip(first_row, row))
print(hilite(f"temp: {temp}"))
personalisation[job_row] = temp
job_row = job_row + 1
print(hilite(f"job_row: {job_row}"))
Expand Down
4 changes: 2 additions & 2 deletions app/celery/provider_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from app.delivery import send_to_providers
from app.enums import NotificationStatus
from app.exceptions import NotificationTechnicalFailureException
from app.utils import utc_now
from app.utils import hilite, utc_now

# This is the amount of time to wait after sending an sms message before we check the aws logs and look for delivery
# receipts
Expand Down Expand Up @@ -100,7 +100,7 @@ def deliver_sms(self, notification_id):
notification = notifications_dao.get_notification_by_id(notification_id)
ansi_green = "\033[32m"
ansi_reset = "\033[0m"

print(hilite(f"notification inside of deliver_sms: {notification}"))
if not notification:
raise NoResultFound()
if (
Expand Down
1 change: 1 addition & 0 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def __total_sending_limits_for_job_exceeded(service, job, job_id):
def save_sms(self, service_id, notification_id, encrypted_notification, sender_id=None):
"""Persist notification to db and place notification in queue to send to sns."""
notification = encryption.decrypt(encrypted_notification)
print(hilite(f"notification at the top of save_sms: {notification}"))
# SerialisedService and SerialisedTemplate classes are
# used here to grab the same service and template from the cache
# to improve performance.
Expand Down
3 changes: 2 additions & 1 deletion app/clients/sms/aws_sns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
from time import monotonic

from app.utils import hilite
import botocore
import phonenumbers
from boto3 import client
Expand Down Expand Up @@ -54,7 +55,7 @@ def send_sms(self, to, content, reference, sender=None, international=False):
to = phonenumbers.format_number(
match.number, phonenumbers.PhoneNumberFormat.E164
)

print(hilite(f"to in send_sms: {to}"))
# See documentation
# https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html#sms_publish_sdk
attributes = {
Expand Down
2 changes: 2 additions & 0 deletions app/delivery/send_to_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def send_sms_to_provider(notification):
notification.job_id,
notification.job_row_number,
)
print(hilite(f"recipient: {recipient}"))

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (private)
as clear text.
except Exception:
# It is our 2facode, maybe
key = f"2facode-{notification.id}".replace(" ", "")
Expand All @@ -108,6 +109,7 @@ def send_sms_to_provider(notification):
"sender": notification.reply_to_text,
"international": notification.international,
}
print(hilite(f"send_sms_kwargs: {send_sms_kwargs}"))

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (private)
as clear text.
db.session.close() # no commit needed as no changes to objects have been made above

message_id = provider.send_sms(**send_sms_kwargs)
Expand Down
3 changes: 2 additions & 1 deletion app/job/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
notifications_filter_schema,
unarchived_template_schema,
)
from app.utils import midnight_n_days_ago, pagination_links
from app.utils import hilite, midnight_n_days_ago, pagination_links

job_blueprint = Blueprint("job", __name__, url_prefix="/service/<uuid:service_id>/job")

Expand Down Expand Up @@ -172,6 +172,7 @@ def create_job(service_id):
raise InvalidRequest("Create job is not allowed: service is inactive ", 403)

data = request.get_json()
print(hilite(f"data at the top of create_job: {data}"))
original_file_name = data.get("original_file_name")
data.update({"service": service_id})
try:
Expand Down

0 comments on commit e956ca5

Please sign in to comment.