Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix notification templates #571

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"markdown":"**{{ notification.title | escape(strategy="json") }}**{% if notification.group == "NEW_VULNERABILITY" %}\n**VulnID:** {{ subject.vulnerability.vulnId | escape(strategy="json") }}\n**Severity:** {{ subject.vulnerability.severity | escape(strategy="json") }}\n**Source:** {{ subject.vulnerability.source | escape(strategy="json") }}\n**Component:** {{ subject.component.toString | escape(strategy="json") }}\n**Actions:**\n[View Vulnerability]({{ baseUrl }}/vulnerability/?source={{ subject.vulnerability.source | escape(strategy="json") }}&vulnId={{ subject.vulnerability.vulnId | escape(strategy="json") }}){% elseif notification.group == "NEW_VULNERABLE_DEPENDENCY" %}\n**Project:** {{ subject.dependency.project.toString | escape(strategy="json") }}\n**Component:** {{ subject.dependency.component.toString | escape(strategy="json") }}\n**Actions:**\n[View Project]({{ baseUrl }}/projects/?uuid={{ subject.dependency.project.uuid | escape(strategy="json") }}){% endif %}\n[View Component]({{ baseUrl }}/component/?uuid={{ subject.dependency.component.uuid | escape(strategy="json") }})\n**Description:** {{ notification.content | escape(strategy="json") }}"}
{"markdown":"**{{ notification.title | escape(strategy="json") }}**{% if notification.group == "GROUP_NEW_VULNERABILITY" %}\n**VulnID:** {{ subject.vulnerability.vulnId | escape(strategy="json") }}\n**Severity:** {{ subject.vulnerability.severity | escape(strategy="json") }}\n**Source:** {{ subject.vulnerability.source | escape(strategy="json") }}\n**Component:** {{ subject.component | summarize | escape(strategy="json") }}\n**Actions:**\n[View Vulnerability]({{ baseUrl }}/vulnerability/?source={{ subject.vulnerability.source | escape(strategy="json") }}&vulnId={{ subject.vulnerability.vulnId | escape(strategy="json") }}){% elseif notification.group == "GROUP_NEW_VULNERABLE_DEPENDENCY" %}\n**Project:** {{ subject.project | summarize | escape(strategy="json") }}\n**Component:** {{ subject.component | summarize | escape(strategy="json") }}\n**Actions:**\n[View Project]({{ baseUrl }}/projects/?uuid={{ subject.project.uuid | escape(strategy="json") }}){% endif %}\n[View Component]({{ baseUrl }}/component/?uuid={{ subject.component.uuid | escape(strategy="json") }})\n**Description:** {{ notification.content | escape(strategy="json") }}"}
57 changes: 25 additions & 32 deletions src/main/resources/templates/notification/publisher/email.peb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{{ notification.title }}

--------------------------------------------------------------------------------
{% if notification.group == "NEW_VULNERABILITY" %}
{% if notification.group == "GROUP_NEW_VULNERABILITY" %}
Vulnerability ID: {{ subject.vulnerability.vulnId }}
Vulnerability URL: {{ baseUrl }}/vulnerability/?source={{ subject.vulnerability.source }}&vulnId={{ subject.vulnerability.vulnId }}
Severity: {{ subject.vulnerability.severity }}
Source: {{ subject.vulnerability.source }}
Component: {{ subject.component.toString }}
Component: {{ subject.component | summarize }}
Component URL: {{ baseUrl }}/component/?uuid={{ subject.component.uuid }}
Project: {{ subject.component.project.name }}
Version: {{ subject.component.project.version }}
Description: {{ subject.component.project.description }}
Project URL: {{ baseUrl }}/projects/{{ subject.component.project.uuid }}
Project: {{ subject.project.name }}
Version: {{ subject.project.version }}
Description: {{ subject.project.description }}
Project URL: {{ baseUrl }}/projects/{{ subject.project.uuid }}
--------------------------------------------------------------------------------

Other affected projects: {{ baseUrl }}{{ notification.subject.affectedProjects.frontendUri }}
{% elseif notification.group == "NEW_VULNERABLE_DEPENDENCY" %}
Project: {{ subject.component.project.toString }}
Other affected projects: {{ baseUrl }}{{ subject.affectedProjectsReference.frontendUri }}
{% elseif notification.group == "GROUP_NEW_VULNERABLE_DEPENDENCY" %}
Project: {{ subject.project | summarize }}
Project URL: {{ baseUrl }}/projects/?uuid={{ subject.component.project.uuid }}
Component: {{ subject.component.toString }}
Component: {{ subject.component | summarize }}
Component URL: {{ baseUrl }}/component/?uuid={{ subject.component.uuid }}

Vulnerabilities
Expand All @@ -31,47 +31,40 @@ Description:
{{ vulnerability.description }}

{% endfor %}
{% elseif notification.group == "PROJECT_AUDIT_CHANGE" %}
{% elseif notification.group == "GROUP_PROJECT_AUDIT_CHANGE" %}
Analysis Type: Project Analysis
{% if subject.analysis is null %}{% for comment in subject.violationAnalysis.analysisComments %} {% if loop.last and comment.commenter is not null %}
Commenter: {{ comment.commenter}}{% endif %}{% endfor %}
Violation Analysis State: {{ subject.violationAnalysis.analysisState }}
Violation Analysis State: {{ subject.violationAnalysis.state }}
Suppressed: {{ subject.violationAnalysis.suppressed }}
Policy: {{ subject.policyViolation.policyCondition.Policy.name }}
Policy Violation State: {{ subject.policyViolation.policyCondition.Policy.violationState }}
Policy: {{ subject.policyViolation.policyCondition.policy.name }}
Policy Violation State: {{ subject.policyViolation.policyCondition.policy.violationState }}
Policy Condition: subject == {{ subject.policyViolation.policyCondition.subject }} && value {{ subject.policyViolation.policyCondition.operator }} {{ subject.policyViolation.policyCondition.value }}
{% else %}{% for comment in subject.analysis.analysisComments %} {% if loop.last and comment.commenter is not null %}
Commenter: {{ comment.commenter}}{% endif %}{% endfor %}
Analysis State: {{ subject.analysis.analysisState }}
Analysis State: {{ subject.analysis.state }}
Suppressed: {{ subject.analysis.suppressed }}
Vulnerability ID: {{ subject.vulnerability.vulnId }}
Vulnerability URL: {{ baseUrl }}/vulnerability/?source={{ subject.vulnerability.source }}&vulnId={{ subject.vulnerability.vulnId }}
Severity: {{ subject.vulnerability.severity }}
Source: {{ subject.vulnerability.source }}
{% endif %}
Component: {{ subject.component.toString }}
Component: {{ subject.component | summarize }}
Component URL: {{ baseUrl }}/component/?uuid={{ subject.component.uuid }}
Project: {{ subject.component.project.toString }}
Description: {{ subject.component.project.description }}
Project URL: {{ baseUrl }}/projects/{{ subject.component.project.uuid }}
{% if notification.subject.affectedProjects|length > 1%}
--------------------------------------------------------------------------------

Other affected projects:
{% for affectedProject in notification.subject.affectedProjects %}{% if not (affectedProject.uuid == subject.component.project.uuid) %}
Project: [{{ affectedProject.name }} : {{ affectedProject.version }}]
Project URL: {{ baseUrl }}/projects/{{ affectedProject.uuid }}
{% endif %}{% endfor %}{% endif %}{% elseif notification.group == "BOM_CONSUMED" %}
Project: {{ subject.project | summarize }}
Description: {{ subject.project.description }}
Project URL: {{ baseUrl }}/projects/{{ subject.project.uuid }}
{% elseif notification.group == "GROUP_BOM_CONSUMED" %}
Project: {{ subject.project.name }}
Version: {{ subject.project.version }}
Description: {{ subject.project.description }}
Project URL: {{ baseUrl }}/projects/{{ subject.project.uuid }}
{% elseif notification.group == "BOM_PROCESSED" %}
{% elseif notification.group == "GROUP_BOM_PROCESSED" %}
Project: {{ subject.project.name }}
Version: {{ subject.project.version }}
Description: {{ subject.project.description }}
Project URL: {{ baseUrl }}/projects/{{ subject.project.uuid }}
{% elseif notification.group == "BOM_PROCESSING_FAILED" %}
{% elseif notification.group == "GROUP_BOM_PROCESSING_FAILED" %}
Project: {{ subject.project.name }}
Version: {{ subject.project.version }}
Description: {{ subject.project.description }}
Expand All @@ -81,17 +74,17 @@ Project URL: {{ baseUrl }}/projects/{{ subject.project.uuid }}

Cause:
{{ subject.cause }}
{% elseif notification.group == "VEX_CONSUMED" %}
{% elseif notification.group == "GROUP_VEX_CONSUMED" %}
Project: {{ subject.project.name }}
Version: {{ subject.project.version }}
Description: {{ subject.project.description }}
Project URL: {{ baseUrl }}/projects/{{ subject.project.uuid }}
{% elseif notification.group == "VEX_PROCESSED" %}
{% elseif notification.group == "GROUP_VEX_PROCESSED" %}
Project: {{ subject.project.name }}
Version: {{ subject.project.version }}
Description: {{ subject.project.description }}
Project URL: {{ baseUrl }}/projects/{{ subject.project.uuid }}
{% elseif notification.group == "POLICY_VIOLATION" %}
{% elseif notification.group == "GROUP_POLICY_VIOLATION" %}
Project: {{ subject.project.name }}
Version: {{ subject.project.version }}
Description: {{ subject.project.description }}
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/templates/notification/publisher/jira.peb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"issuetype": {
"name": "{{ jiraTicketType }}"
},
"summary": "[Dependency-Track] [{{ notification.group | escape(strategy="json") }}] {% if notification.group == "NEW_VULNERABILITY" %}[{{ subject.vulnerability.severity }}] New {{ subject.vulnerability.severity | lower }} vulnerability identified: {{ subject.vulnerability.vulnId }}{% elseif notification.group == "NEW_VULNERABLE_DEPENDENCY" %}Vulnerable dependency introduced on project {{ subject.dependency.project.name | escape(strategy="json") }}{% else %}{{ notification.title | escape(strategy="json") }}{% endif %}",
{% if notification.group == "NEW_VULNERABILITY" %}
"description": "A new vulnerability has been identified on your project(s).\n\\\\\n\\\\\n*Vulnerability description*\n{code:none|bgColor=white|borderStyle=none}{{ subject.vulnerability.description | escape(strategy="json") }}{code}\n\n*VulnID*\n{{ subject.vulnerability.vulnId }}\n\n*Severity*\n{{ subject.vulnerability.severity | lower | capitalize }}\n\n*Component*\n[{{ subject.component | escape(strategy="json") }}|{{ baseUrl }}/components/{{ subject.component.uuid }}]\n\n*Affected project(s)*\n{% for project in subject.affectedProjects %}- [{{ project.name | escape(strategy="json") }} ({{ project.version | escape(strategy="json") }})|{{ baseUrl }}/projects/{{ project.uuid }}]\n{% endfor %}"
{% elseif notification.group == "NEW_VULNERABLE_DEPENDENCY" %}
"description": "A component which contains one or more vulnerabilities has been added to your project.\n\\\\\n\\\\\n*Project*\n[{{ subject.component.project | escape(strategy="json") }}|{{ baseUrl }}/projects/{{ subject.component.project.uuid }}]\n\n*Component*\n[{{ subject.component | escape(strategy="json") }}|{{ baseUrl }}/components/{{ subject.component.uuid }}]\n\n*Vulnerabilities*\n{% for vulnerability in subject.vulnerabilities %}- {{ vulnerability.vulnId }} ({{ vulnerability.severity | lower | capitalize }})\n{% endfor %}"
"summary": "[Dependency-Track] [{{ notification.group | escape(strategy="json") }}] {% if notification.group == "GROUP_NEW_VULNERABILITY" %}[{{ subject.vulnerability.severity }}] New {{ subject.vulnerability.severity | lower }} vulnerability identified: {{ subject.vulnerability.vulnId }}{% elseif notification.group == "GROUP_NEW_VULNERABLE_DEPENDENCY" %}Vulnerable dependency introduced on project {{ subject.dependency.project.name | escape(strategy="json") }}{% else %}{{ notification.title | escape(strategy="json") }}{% endif %}",
{% if notification.group == "GROUP_NEW_VULNERABILITY" %}
"description": "A new vulnerability has been identified on your project(s).\n\\\\\n\\\\\n*Vulnerability description*\n{code:none|bgColor=white|borderStyle=none}{{ subject.vulnerability.description | escape(strategy="json") }}{code}\n\n*VulnID*\n{{ subject.vulnerability.vulnId }}\n\n*Severity*\n{{ subject.vulnerability.severity | lower | capitalize }}\n\n*Component*\n[{{ subject.component | summarize | escape(strategy="json") }}|{{ baseUrl }}/components/{{ subject.component.uuid }}]\n\n*Affected project(s)*\n{% for project in subject.affectedProjectsList %}- [{{ project.name | escape(strategy="json") }} ({{ project.version | escape(strategy="json") }})|{{ baseUrl }}/projects/{{ project.uuid }}]\n{% endfor %}"
{% elseif notification.group == "GROUP_NEW_VULNERABLE_DEPENDENCY" %}
"description": "A component which contains one or more vulnerabilities has been added to your project.\n\\\\\n\\\\\n*Project*\n[{{ subject.component.project | summarize | escape(strategy="json") }}|{{ baseUrl }}/projects/{{ subject.component.project.uuid }}]\n\n*Component*\n[{{ subject.component | summarize | escape(strategy="json") }}|{{ baseUrl }}/components/{{ subject.component.uuid }}]\n\n*Vulnerabilities*\n{% for vulnerability in subject.vulnerabilities %}- {{ vulnerability.vulnId }} ({{ vulnerability.severity | lower | capitalize }})\n{% endfor %}"
{% else %}
"description": "{{ notification.content | escape(strategy="json") }}\n\\\\\n\\\\\n*Level*\n{{ notification.level }}\n\n"
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"username": "Dependency Track",
"icon_url": "https://raw.githubusercontent.com/DependencyTrack/branding/master/dt-logo-symbol-blue-background.png",
"text": "#### {{ notification.title | escape(strategy="json") }}\n{{ notification.content | escape(strategy="json") }}\n{% if notification.group == "NEW_VULNERABILITY" %}**Component**: {{ subject.component.toString | escape(strategy="json") }}\n**Vulnerability**: {{ subject.vulnerability.vulnId | escape(strategy="json") }}, {{ subject.vulnerability.severity | escape(strategy="json") }}\n[View Component]({{ baseUrl }}/components/{{ subject.component.uuid | escape(strategy="json") }}) - [View Vulnerability]({{ baseUrl }}/vulnerabilities/{{ subject.vulnerability.source | escape(strategy="json") }}/{{ subject.vulnerability.vulnId | escape(strategy="json") }}){% elseif notification.group == "NEW_VULNERABLE_DEPENDENCY" %}**Project**: {{ subject.project.toString | escape(strategy="json") }}\n**Component**: {{ subject.component.toString | escape(strategy="json") }}\n[View Project]({{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy="json") }}) - [View Component]({{ baseUrl }}/components/{{ subject.component.uuid | escape(strategy="json") }}){% elseif notification.group == "PROJECT_AUDIT_CHANGE" or notification.group == "GLOBAL_AUDIT_CHANGE" %}**Project**: {{ subject.project.toString | escape(strategy="json") }}\n**Component**: {{ subject.component.toString | escape(strategy="json") }}\n**Vulnerability**: {{ subject.vulnerability.vulnId | escape(strategy="json") }}, {{ subject.vulnerability.severity | escape(strategy="json") }}\n**Analysis**: {{ subject.analysis.analysisState | escape(strategy="json") }}, suppressed: {{ subject.analysis.suppressed | escape(strategy="json") }}\n[View Project]({{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy="json") }}) - [View Component]({{ baseUrl }}/components/{{ subject.component.uuid | escape(strategy="json") }}) - [View Vulnerability]({{ baseUrl }}/vulnerabilities/{{ subject.vulnerability.source | escape(strategy="json") }}/{{ subject.vulnerability.vulnId | escape(strategy="json") }}){% elseif notification.group == "BOM_CONSUMED" or notification.group == "BOM_PROCESSED" %}**Project**: {{ subject.project.toString | escape(strategy="json") }}\n[View Project]({{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy="json") }}){% elseif notification.group == "POLICY_VIOLATION" %}**Project**: {{ subject.project.toString | escape(strategy="json") }}\n**Component**: {{ subject.component.toString | escape(strategy="json") }}\n**Policy**: {{ subject.policyViolation.policyCondition.policy.violationState | escape(strategy="json") }}, {{ subject.policyViolation.policyCondition.policy.name | escape(strategy="json") }}\n[View Project]({{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy="json") }}) - [View Component]({{ baseUrl }}/components/{{ subject.component.uuid | escape(strategy="json") }}){% endif %}"
"text": "#### {{ notification.title | escape(strategy="json") }}\n{{ notification.content | escape(strategy="json") }}\n{% if notification.group == "GROUP_NEW_VULNERABILITY" %}**Component**: {{ subject.component | summarize | escape(strategy="json") }}\n**Vulnerability**: {{ subject.vulnerability.vulnId | escape(strategy="json") }}, {{ subject.vulnerability.severity | escape(strategy="json") }}\n[View Component]({{ baseUrl }}/components/{{ subject.component.uuid | escape(strategy="json") }}) - [View Vulnerability]({{ baseUrl }}/vulnerabilities/{{ subject.vulnerability.source | escape(strategy="json") }}/{{ subject.vulnerability.vulnId | escape(strategy="json") }}){% elseif notification.group == "GROUP_NEW_VULNERABLE_DEPENDENCY" %}**Project**: {{ subject.project | summarize | escape(strategy="json") }}\n**Component**: {{ subject.component | summarize | escape(strategy="json") }}\n[View Project]({{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy="json") }}) - [View Component]({{ baseUrl }}/components/{{ subject.component.uuid | escape(strategy="json") }}){% elseif notification.group == "GROUP_PROJECT_AUDIT_CHANGE" or notification.group == "GROUP_GLOBAL_AUDIT_CHANGE" %}**Project**: {{ subject.project | summarize | escape(strategy="json") }}\n**Component**: {{ subject.component | summarize | escape(strategy="json") }}\n**Vulnerability**: {{ subject.vulnerability.vulnId | escape(strategy="json") }}, {{ subject.vulnerability.severity | escape(strategy="json") }}\n**Analysis**: {{ subject.analysis.state | escape(strategy="json") }}, suppressed: {{ subject.analysis.suppressed | escape(strategy="json") }}\n[View Project]({{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy="json") }}) - [View Component]({{ baseUrl }}/components/{{ subject.component.uuid | escape(strategy="json") }}) - [View Vulnerability]({{ baseUrl }}/vulnerabilities/{{ subject.vulnerability.source | escape(strategy="json") }}/{{ subject.vulnerability.vulnId | escape(strategy="json") }}){% elseif notification.group == "GROUP_BOM_CONSUMED" or notification.group == "GROUP_BOM_PROCESSED" %}**Project**: {{ subject.project | summarize | escape(strategy="json") }}\n[View Project]({{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy="json") }}){% elseif notification.group == "GROUP_POLICY_VIOLATION" %}**Project**: {{ subject.project | summarize | escape(strategy="json") }}\n**Component**: {{ subject.component | summarize | escape(strategy="json") }}\n**Policy**: {{ subject.policyViolation.policyCondition.policy.violationState | escape(strategy="json") }}, {{ subject.policyViolation.policyCondition.policy.name | escape(strategy="json") }}\n[View Project]({{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy="json") }}) - [View Component]({{ baseUrl }}/components/{{ subject.component.uuid | escape(strategy="json") }}){% endif %}"
}
Loading
Loading