Clean up and validate low static-scan findings

This commit is contained in:
Ryan Ahearn
2022-08-19 14:32:11 +00:00
parent 53f2519c2a
commit 3c035531aa
6 changed files with 13 additions and 12 deletions

View File

@@ -18,7 +18,7 @@ from sqlalchemy.orm.exc import NoResultFound
from app.serialised_models import SerialisedService from app.serialised_models import SerialisedService
GENERAL_TOKEN_ERROR_MESSAGE = 'Invalid token: make sure your API token matches the example at https://docs.notifications.service.gov.uk/rest-api.html#authorisation-header' # noqa GENERAL_TOKEN_ERROR_MESSAGE = 'Invalid token: make sure your API token matches the example at https://docs.notifications.service.gov.uk/rest-api.html#authorisation-header' # nosec B105
AUTH_DB_CONNECTION_DURATION_SECONDS = Histogram( AUTH_DB_CONNECTION_DURATION_SECONDS = Histogram(
'auth_db_connection_duration_seconds', 'auth_db_connection_duration_seconds',

View File

@@ -38,7 +38,7 @@ class NotificationProviderClients(object):
return self.email_clients.get(name) return self.email_clients.get(name)
def get_client_by_name_and_type(self, name, notification_type): def get_client_by_name_and_type(self, name, notification_type):
assert notification_type in ['email', 'sms'] assert notification_type in ['email', 'sms'] # nosec B101
if notification_type == 'email': if notification_type == 'email':
return self.get_email_client(name) return self.get_email_client(name)

View File

@@ -544,7 +544,8 @@ def populate_organisation_agreement_details_from_file(file_name):
current_app.logger.info(f"Updating {org.name}") current_app.logger.info(f"Updating {org.name}")
assert org.agreement_signed if not org.agreement_signed:
raise RuntimeError('Agreement was not signed')
org.agreement_signed_version = float(row[1]) org.agreement_signed_version = float(row[1])
org.agreement_signed_on_behalf_of_name = row[2].strip() org.agreement_signed_on_behalf_of_name = row[2].strip()

View File

@@ -179,7 +179,7 @@ class Config(object):
SMS_CODE_TEMPLATE_ID = '36fb0730-6259-4da1-8a80-c8de22ad4246' SMS_CODE_TEMPLATE_ID = '36fb0730-6259-4da1-8a80-c8de22ad4246'
EMAIL_2FA_TEMPLATE_ID = '299726d2-dba6-42b8-8209-30e1d66ea164' EMAIL_2FA_TEMPLATE_ID = '299726d2-dba6-42b8-8209-30e1d66ea164'
NEW_USER_EMAIL_VERIFICATION_TEMPLATE_ID = 'ece42649-22a8-4d06-b87f-d52d5d3f0a27' NEW_USER_EMAIL_VERIFICATION_TEMPLATE_ID = 'ece42649-22a8-4d06-b87f-d52d5d3f0a27'
PASSWORD_RESET_TEMPLATE_ID = '474e9242-823b-4f99-813d-ed392e7f1201' PASSWORD_RESET_TEMPLATE_ID = '474e9242-823b-4f99-813d-ed392e7f1201' # nosec B105 - this is not a password
ALREADY_REGISTERED_EMAIL_TEMPLATE_ID = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb' ALREADY_REGISTERED_EMAIL_TEMPLATE_ID = '0880fbb1-a0c6-46f0-9a8e-36c986381ceb'
CHANGE_EMAIL_CONFIRMATION_TEMPLATE_ID = 'eb4d9930-87ab-4aef-9bce-786762687884' CHANGE_EMAIL_CONFIRMATION_TEMPLATE_ID = 'eb4d9930-87ab-4aef-9bce-786762687884'
SERVICE_NOW_LIVE_TEMPLATE_ID = '618185c6-3636-49cd-b7d2-6f6f5eb3bdde' SERVICE_NOW_LIVE_TEMPLATE_ID = '618185c6-3636-49cd-b7d2-6f6f5eb3bdde'
@@ -426,7 +426,7 @@ class Development(Config):
# Config.GOVUK_ALERTS_CLIENT_ID: ['govuk-alerts-secret-key'] # Config.GOVUK_ALERTS_CLIENT_ID: ['govuk-alerts-secret-key']
# } # }
SECRET_KEY = 'dev-notify-secret-key' SECRET_KEY = 'dev-notify-secret-key' # nosec B105 - this is only used in development
DANGEROUS_SALT = 'dev-notify-salt' DANGEROUS_SALT = 'dev-notify-salt'
MMG_INBOUND_SMS_AUTH = ['testkey'] MMG_INBOUND_SMS_AUTH = ['testkey']

View File

@@ -1647,7 +1647,7 @@ class Notification(db.Model):
""" """
# this should only ever be called for letter notifications - it makes no sense otherwise and I'd rather not # this should only ever be called for letter notifications - it makes no sense otherwise and I'd rather not
# get the two code flows mixed up at all # get the two code flows mixed up at all
assert self.notification_type == LETTER_TYPE assert self.notification_type == LETTER_TYPE # nosec B101 - current calling code already validates the correct type
if self.status in [NOTIFICATION_CREATED, NOTIFICATION_SENDING]: if self.status in [NOTIFICATION_CREATED, NOTIFICATION_SENDING]:
return NOTIFICATION_STATUS_LETTER_ACCEPTED return NOTIFICATION_STATUS_LETTER_ACCEPTED

View File

@@ -108,7 +108,7 @@ def __format_message(e):
error_path = e.path.popleft() error_path = e.path.popleft()
# no need to catch IndexError exception explicity as # no need to catch IndexError exception explicity as
# error_path is None if e.path has no items # error_path is None if e.path has no items
except Exception: except IndexError:
pass pass
return error_path return error_path