Skip to content

Commit

Permalink
Apply patches for email
Browse files Browse the repository at this point in the history
  • Loading branch information
ygalnezri committed Dec 12, 2024
1 parent e8453ff commit d88ffae
Show file tree
Hide file tree
Showing 11 changed files with 555 additions and 641 deletions.
2 changes: 1 addition & 1 deletion Watcher/Watcher/common/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,4 @@ def send_notification(channel, content_template, subscribers_filter, send_func,
email_list = [subscriber.user_rec.email for subscriber in subscribers.filter(email=True)]

except Exception as e:
print(f"Error sending notifications for {app_name}: {str(e)}")
print(f"{datetime.now()} - Error sending notifications for {app_name}: {str(e)}")
207 changes: 96 additions & 111 deletions Watcher/Watcher/common/mail_template/data_leak_group_template.py
Original file line number Diff line number Diff line change
@@ -1,157 +1,142 @@
from django.conf import settings

def get_data_leak_group_template(keyword, alerts_number):
body = f"""\
body = """\
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
/* Reset Styles */
body, table, td, p {{
body, p, table, td, div {
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
color: #333333;
font-family: Arial, Helvetica, sans-serif;
line-height: 1.6;
}}
}
body {{
background-color: #f9fafc;
/* Base Styles */
body {
background-color: #f5f7fa;
color: #2d3748;
font-size: 14px;
}}
.container {{
}
.container {
width: 100%;
max-width: 600px;
margin: 20px auto;
background: #ffffff;
border-radius: 8px;
border-radius: 30px;
overflow: hidden;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}}
}
/* Header */
.header {{
background: linear-gradient(135deg, #00267F 0%, #1a365d 100%);
color: #ffffff;
padding: 20px;
/* Header Styles */
.header {
background: #00267F;
padding: 30px 20px;
text-align: center;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}}
}
.header h1 {{
font-size: 24px;
.header h1 {
color: #ffffff;
font-size: 28px;
font-weight: 600;
margin: 0;
}}
text-transform: uppercase;
letter-spacing: 1px;
}
.header img {{
.header img {
width: 80px;
height: auto;
margin-bottom: 10px;
}}
/* Content */
.content {{
padding: 20px 30px;
}}
.content p {{
margin-bottom: 16px;
}}
.details {{
margin-bottom: 15px;
}
/* Content Styles */
.content {
padding: 40px 30px;
}
.content p {
margin-bottom: 20px;
color: #4a5568;
}
.word-list {
background: #f3f4f6;
padding: 15px;
border-left: 10px solid #00267F;
padding: 15px 10px 15px 10px;
margin: 20px 0;
border-left: 4px solid #00267F;
border-radius: 4px;
}}
.details p {{
margin: 5px 0;
}}
.details strong {{
color: #333333;
}}
/* Footer */
.footer {{
border-radius: 0 4px 4px 0;
}
.word-list p {
margin: 8px 0;
color: #2d3748;
font-size: 15px;
}
.word-list p:last-child {
margin-bottom: 0;
}
/* Footer Styles */
.footer {
background: #58c3d7;
padding: 30px 20px;
text-align: center;
padding: 20px;
color: #ffffff;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
}}
.footer img {{
margin: 10px auto;
width: 80px;
}}
.github-link {{
display: inline-block;
padding: 8px 15px;
background: rgba(255, 255, 255, 0.1);
border-radius: 5px;
}
.footer a {
color: #ffffff;
text-decoration: none;
transition: background 0.3s ease;
font-size: 14px;
display: inline-block;
padding: 8px 15px;
margin-top: 10px;
}}
.github-link:hover {{
background: rgba(255, 255, 255, 0.2);
}}
.github-link img {{
width: 20px;
height: 20px;
vertical-align: middle;
margin-right: 8px;
filter: invert(1);
}}
}
.classification {{
.classification {
text-align: center;
font-size: 12px;
color: #888888;
margin-top: 15px;
}}
color: #718096;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<!-- Header -->
<div class="header">
<img src="{settings.WATCHER_LOGO_BASE64}" alt="Watcher Logo">
<h1>Data Leak: Alerts</h1>
</div>
<table class="container" align="center">
<tr>
<!-- Header -->
<td class="header" colspan="2">
<img src=""" + str(settings.WATCHER_LOGO_BASE64) + """ " alt="Watcher Logo">
<h1>Data Leak Group Alerts</h1>
</td>
</tr>
<!-- Content -->
<div class="content">
<p>Dear team,</p>
<div class="details">
<p><strong>{alerts_number}</strong> New Data Leakage Alerts for <strong>{keyword}</strong> keyword</p>
</div>
<p>You can check more details <a href="{settings.WATCHER_URL}#/data_leak">here</a>.</p>
<p>Best Regards,</p>
<p><strong>Watcher</strong></p>
</div>
<tr>
<td class="content" colspan="2">
<p>Dear team,</p>
<p><strong>""" + str(alerts_number) + """</strong> new data leakage alerts have been detected for the keyword <strong>""" + str(keyword) + """</strong>.</p>
<p>You can check more details <a href=" """ + str(settings.WATCHER_URL + "#/data_leak") + """ ">here.</a></p>
<p>Kind Regards,<br><br><strong>Watcher</strong></p>
</td>
</tr>
<!-- Footer -->
<div class="footer">
<a href="https://github.com/thalesgroup-cert/Watcher" class="github-link">
<img src="https://cdnjs.cloudflare.com/ajax/libs/simple-icons/3.0.1/github.svg" alt="GitHub">
View Watcher on GitHub
</a>
</div>
</div>
<p class="classification">[{settings.EMAIL_CLASSIFICATION}]</p>
<tr>
<td class="footer" colspan="2">
<a href="https://github.com/thalesgroup-cert/Watcher" class="github-link">
<img src=""" + str(settings.GITHUB_LOGO) + """ " alt="GitHub">
</a>
</td>
</tr>
</table>
<p class="classification">[""" + str(settings.EMAIL_CLASSIFICATION) + """</p>
</body>
</html>
"""
Expand Down
Loading

0 comments on commit d88ffae

Please sign in to comment.