-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #656 from NoamBAqua/noam-add-incident-email-template
Noam add incident email template
- Loading branch information
Showing
1 changed file
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
package postee.incident.html | ||
|
||
import data.postee.with_default | ||
|
||
############################################## Templates ################################################ | ||
|
||
# Main template to render message | ||
tpl := ` | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
%s | ||
<title>Incident Report</title> | ||
</head> | ||
<body> | ||
<div class="incident-container"> | ||
<!-- Thin Red Line --> | ||
<div class="severity-indicator"></div> | ||
<!-- Severity Box --> | ||
<div class="severity-box"> | ||
<span style="font-size: 23px">%s</span> <br> <span style="font-size: 13px">%s Severity</span> | ||
</div> | ||
<!-- Logo --> | ||
<div class="logo"> | ||
%s | ||
</div> | ||
<!-- Incident Overview --> | ||
<div class="section"> | ||
<h3>Incident Overview</h3> | ||
<div class="info-grid divider"> | ||
<p><strong>Category:</strong> %s</p> | ||
<p><strong>Host Name:</strong> %s</p> | ||
</div> | ||
<div class="info-grid divider"> | ||
<p><strong>Type:</strong> %s</p> | ||
<p><strong>Host ID:</strong> %s</p> | ||
</div> | ||
<div class="info-grid"> | ||
<p><strong>Name:</strong> %s</p> | ||
<p><strong>URL:</strong> <a href="%s">%s</a></p> | ||
<p><strong>Result:</strong> %s</p> | ||
</div> | ||
</div> | ||
<!-- Malware Detection --> | ||
<div class="section"> | ||
<h3>Malware Detection</h3> | ||
<div class="info-grid divider"> | ||
<p><strong>Malware Name:</strong> %s</p> | ||
<p><strong>Host IP:</strong> %s</p> | ||
</div> | ||
<div class="info-grid divider"> | ||
<p><strong>Malware Type:</strong> %s</p> | ||
<p><strong>Action:</strong> %s</p> | ||
</div> | ||
<div class="info-grid divider"> | ||
<p><strong>Scan Type:</strong> %s</p> | ||
<p><strong>Level:</strong> %s</p> | ||
</div> | ||
<div class="info-grid"> | ||
<p><strong>Resource:</strong> %s</p> | ||
<p><strong>Cluster:</strong> %s</p> | ||
</div> | ||
</div> | ||
<!-- Attack Details --> | ||
<div class="section"> | ||
<h3>Attack Details</h3> | ||
<p><strong>Tactics:</strong> %s</p> | ||
<p><strong>Techniques:</strong> %s</p> | ||
<p><strong>Rule Type:</strong> %s</p> | ||
</div> | ||
<!-- Policy Information --> | ||
<div class="section policy-details"> | ||
<p><strong>Response Policy Name:</strong> %s</p> | ||
<p><strong>Application Scope:</strong> %s</p> | ||
</div> | ||
<div class="copyright"> | ||
Copyright (C) 2022 Aqua Security Software Ltd. | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
` | ||
|
||
# Style definition with dynamic colors based on severity_score | ||
style := sprintf(` | ||
<style> | ||
body { | ||
font-family: Helvetica; | ||
margin: 0; | ||
padding: 0; | ||
color: #333; | ||
background-color: #f8f8f8; | ||
} | ||
.incident-container { | ||
margin: 20px auto; | ||
padding: 20px; | ||
background-color: #fff; | ||
border-radius: 8px; | ||
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); | ||
max-width: 800px; | ||
} | ||
.severity-indicator { | ||
background-color: %s; | ||
height: 5px; | ||
width: 100%%; | ||
margin: 0; | ||
} | ||
.severity-box { | ||
margin-left: 44px; | ||
display: inline-block; | ||
background-color: %s; | ||
color: #fff; | ||
padding: 10px 15px; | ||
font-size: 18px; | ||
font-weight: bold; | ||
border-bottom-left-radius: 7px; | ||
border-bottom-right-radius: 7px; | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
.logo { | ||
text-align: center; | ||
margin: 20px 0; | ||
} | ||
.logo img { | ||
height: 40px; | ||
} | ||
h3 { | ||
color: #183278; | ||
margin-top: 30px; | ||
} | ||
.section { | ||
margin-bottom: 20px; | ||
margin-left: 44px; | ||
color: #6B7887; | ||
} | ||
.divider { | ||
border-bottom: 1px solid #F3F5F9; | ||
width: 100%%; | ||
margin-bottom: 20px; | ||
} | ||
.info-grid { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
gap: 1rem; | ||
} | ||
.info-grid p { | ||
display: inline-block; | ||
vertical-align: middle; | ||
max-width: 290px; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
.policy-details { | ||
display: flex; | ||
justify-content: space-between; | ||
padding-right: 100px; | ||
} | ||
.policy-details p { | ||
overflow-wrap: break-word; | ||
word-wrap: break-word; | ||
white-space: normal; | ||
} | ||
.copyright { | ||
color: #405a75; | ||
font-family: "Inter-SemiBold", sans-serif; | ||
font-size: 15px; | ||
line-height: 26px; | ||
font-weight: 600; | ||
margin-top: 30px; | ||
text-align: center; | ||
} | ||
</style> | ||
`, [severity_color, severity_color]) | ||
|
||
logo := `<img | ||
class="aqua-logo" | ||
src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTEwIiBoZWlnaHQ9IjM1IiB2aWV3Qm94PSIwIDAgODggMjUiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzE0OTRfMTIzNjgpIj4KICAgIDxwYXRoIGQ9Ik0xNi45MDk5IDEwLjYxMjFWMS41NTEyOEMxNi45MTAxIDEuNDY1MTEgMTYuODkzMiAxLjM3OTc0IDE2Ljg2MDMgMS4zMDAwOUMxNi44MjczIDEuMjIwNDQgMTYuNzc4OSAxLjE0ODA3IDE2LjcxNzggMS4wODcxNEMxNi42NTY3IDEuMDI2MjEgMTYuNTg0MSAwLjk3NzkxIDE2LjUwNDIgMC45NDUwMjRDMTYuNDI0MyAwLjkxMjEzOSAxNi4zMzg3IDAuODk1MzEyIDE2LjI1MjMgMC44OTU1MU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NCA1MC43Njc3IDguNDM0NjIgNTAuNzY3NyA5LjMyNjk1VjI0LjE4MUg1My44NjQyVjkuMzI2OTVDNTMuODY0MiA1LjEzNzUzIDUwLjQ0NDYgMS43Mjc1NCA0Ni4yNDM0IDEuNzI3NTRaIiBmaWxsPSIjMDcyNDJEIj48L3BhdGg+CiAgPC9nPgogIDxkZWZzPgogICAgPGNsaXBQYXRoIGlkPSJjbGlwMF8xNDk0XzEyMzY4Ij4KICAgICAgPHJlY3Qgd2lkdGg9Ijg4IiBoZWlnaHQ9IjIzLjI4NTQiIGZpbGw9IndoaXRlIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIDAuODk1NTA4KSI+PC9yZWN0PgogICAgPC9jbGlwUGF0aD4KICA8L2RlZnM+Cjwvc3ZnPg==" | ||
alt="aqua" | ||
/>` | ||
|
||
|
||
# Determine colors based on input.severity_score | ||
severity_color = "#FF0036" { | ||
input.severity_score == 3 | ||
} else = "#BB0505" | ||
|
||
title:="Incident Detection" | ||
|
||
parsed_data := json.unmarshal(input.data) | ||
|
||
result = msg { | ||
msg := sprintf(tpl, [ | ||
style, | ||
sprintf("%v", [input.severity_score]), | ||
input.severity, | ||
logo, | ||
input.category, | ||
input.host, | ||
input.type, | ||
input.hostid, | ||
input.name, | ||
input.url, | ||
input.url, | ||
sprintf("%v", [parsed_data.result]), | ||
parsed_data.malware, | ||
parsed_data.hostip, | ||
parsed_data.malware_type, | ||
parsed_data.action, | ||
parsed_data.malware_scan_type, | ||
parsed_data.level, | ||
parsed_data.resource, | ||
input.cluster, | ||
parsed_data.tactic, | ||
parsed_data.technique, | ||
parsed_data.rule_type, | ||
input.response_policy_name, | ||
concat(", ", with_default(input, "application_scope", [])) | ||
]) | ||
} |