New implementations and updates for security scan

This commit is contained in:
Andrii V 2026-01-16 16:53:31 +01:00
parent 9ce6ca8fd8
commit 6fe5736648
18 changed files with 145 additions and 33 deletions

View file

@ -124,6 +124,15 @@ def send_email(recipients, subject, body="", html_body="", email_config=None, ex
try:
mailer = get_mailer(transformed_email_confing, email_config)
log.debug(
"Preparing email: server=%s, sender=%s, recipients=%s, subject=%s, dev_mode=%s",
mail_server,
transformed_email_confing.get("default_sender"),
recipients,
subject,
dev_mod,
)
message = Message(
subject=subject,
sender=transformed_email_confing["default_sender"],
@ -132,7 +141,9 @@ def send_email(recipients, subject, body="", html_body="", email_config=None, ex
html=html_body,
extra_headers=extra_headers,
)
log.debug("Sending email via mailer...")
mailer.send_immediately(message)
log.info("Email sent successfully to %s", recipients)
statsd = StatsdClient.statsd
if statsd:

View file

@ -1036,7 +1036,7 @@ def link_to_user(author, length=0, **kwargs):
if length:
display_person = shorter(display_person, length)
if user and user.username not in [user.DEFAULT_USER, user.GHOST_USER, user.AI_USER]:
if user and user.username not in [user.DEFAULT_USER, user.GHOST_USER, user.AI_USER, user.SECURITY_USER]:
return link_to(escape(display_person), route_path("user_profile", username=user.username), **kwargs)
else:
return escape(display_person)

View file

@ -484,7 +484,7 @@ class SimpleVCS(object):
auth_user = user_obj.AuthUser()
if (
user_obj
and user_obj.username not in [User.DEFAULT_USER, User.GHOST_USER, User.AI_USER]
and user_obj.username not in [User.DEFAULT_USER, User.GHOST_USER, User.AI_USER, User.SECURITY_USER]
and user_obj.user_data.get("force_password_change")
):
reason = "password change required"

View file

@ -879,7 +879,10 @@ def create_test_repositories(test_path, config):
def password_changed(auth_user, session):
# Never report password change in case of default user, anonymous user or system user.
if auth_user.username in [User.DEFAULT_USER, User.GHOST_USER, User.AI_USER] or auth_user.user_id is None:
if (
auth_user.username in [User.DEFAULT_USER, User.GHOST_USER, User.AI_USER, User.SECURITY_USER]
or auth_user.user_id is None
):
return False
password_hash = md5(safe_bytes(auth_user.password)) if auth_user.password else None