From 0949361240f7843894934d8f293c037d3e92a4e2 Mon Sep 17 00:00:00 2001 From: nscuro Date: Mon, 12 Feb 2024 17:42:33 +0100 Subject: [PATCH] Fix notification templates Resolves issues identified while working on https://github.com/DependencyTrack/hyades/pull/1073 Signed-off-by: nscuro --- .../notification/publisher/cswebex.peb | 2 +- .../notification/publisher/email.peb | 57 ++++++++----------- .../templates/notification/publisher/jira.peb | 10 ++-- .../notification/publisher/mattermost.peb | 2 +- .../notification/publisher/msteams.peb | 26 ++++----- .../notification/publisher/slack.peb | 22 +++---- .../notification/publisher/webhook.peb | 2 +- 7 files changed, 57 insertions(+), 64 deletions(-) diff --git a/src/main/resources/templates/notification/publisher/cswebex.peb b/src/main/resources/templates/notification/publisher/cswebex.peb index 3f4129597..7249ea8f6 100644 --- a/src/main/resources/templates/notification/publisher/cswebex.peb +++ b/src/main/resources/templates/notification/publisher/cswebex.peb @@ -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") }}"} \ No newline at end of file +{"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") }}"} \ No newline at end of file diff --git a/src/main/resources/templates/notification/publisher/email.peb b/src/main/resources/templates/notification/publisher/email.peb index 33b825ef8..40b596b9f 100644 --- a/src/main/resources/templates/notification/publisher/email.peb +++ b/src/main/resources/templates/notification/publisher/email.peb @@ -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 @@ -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 }} @@ -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 }} diff --git a/src/main/resources/templates/notification/publisher/jira.peb b/src/main/resources/templates/notification/publisher/jira.peb index 399f7f259..7a9e8dc46 100644 --- a/src/main/resources/templates/notification/publisher/jira.peb +++ b/src/main/resources/templates/notification/publisher/jira.peb @@ -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 %} diff --git a/src/main/resources/templates/notification/publisher/mattermost.peb b/src/main/resources/templates/notification/publisher/mattermost.peb index 9a7c59a26..9ab35449b 100644 --- a/src/main/resources/templates/notification/publisher/mattermost.peb +++ b/src/main/resources/templates/notification/publisher/mattermost.peb @@ -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 %}" } \ No newline at end of file diff --git a/src/main/resources/templates/notification/publisher/msteams.peb b/src/main/resources/templates/notification/publisher/msteams.peb index 57be4b866..c4b7841d9 100644 --- a/src/main/resources/templates/notification/publisher/msteams.peb +++ b/src/main/resources/templates/notification/publisher/msteams.peb @@ -7,8 +7,8 @@ { "activityTitle": "Dependency-Track", "activitySubtitle": "{{ timestamp }}", - "activityImage": "https://raw.githubusercontent.com/DependencyTrack/branding/master/dt-logo-symbol-icon-dark-background.png", - {% if notification.group == "NEW_VULNERABILITY" %} + "activityImage": "https://raw.githubusercontent.com/DependencyTrack/branding/master/dt-logo-symbol-blue-background.png", + {% if notification.group == "GROUP_NEW_VULNERABILITY" %} "facts": [ { "name": "VulnID", @@ -24,21 +24,21 @@ }, { "name": "Component", - "value": "{{ subject.component.toString | escape(strategy="json") }}" + "value": "{{ subject.component | summarize | escape(strategy="json") }}" } ], - {% elseif notification.group == "NEW_VULNERABLE_DEPENDENCY" %} + {% elseif notification.group == "GROUP_NEW_VULNERABLE_DEPENDENCY" %} "facts": [ { "name": "Project", - "value": "{{ subject.dependency.project.toString | escape(strategy="json") }}" + "value": "{{ subject.dependency.project | summarize | escape(strategy="json") }}" }, { "name": "Component", - "value": "{{ subject.dependency.component.toString | escape(strategy="json") }}" + "value": "{{ subject.dependency.component | summarize | escape(strategy="json") }}" } ], - {% elseif notification.group == "PROJECT_AUDIT_CHANGE" %} + {% elseif notification.group == "GROUP_PROJECT_AUDIT_CHANGE" %} "facts": [ { "name": "Analysis Type", @@ -46,7 +46,7 @@ }, { "name": "Analysis State", - "value": "{{ subject.analysis.analysisState | escape(strategy="json") }}" + "value": "{{ subject.analysis.state | escape(strategy="json") }}" }, { "name": "Suppressed", @@ -66,14 +66,14 @@ }, { "name": "Component", - "value": "{{ subject.component.toString | escape(strategy="json") }}" + "value": "{{ subject.component | summarize | escape(strategy="json") }}" }, { "name": "Project", - "value": "{{ subject.project.toString | escape(strategy="json") }}" + "value": "{{ subject.project | summarize | escape(strategy="json") }}" } ], - {% elseif notification.group == "POLICY_VIOLATION" %} + {% elseif notification.group == "GROUP_POLICY_VIOLATION" %} "facts": [ { "name": "Subject", @@ -89,11 +89,11 @@ }, { "name": "Component", - "value": "{{ subject.component.toString | escape(strategy="json") }}" + "value": "{{ subject.component | summarize | escape(strategy="json") }}" }, { "name": "Project", - "value": "{{ subject.project.toString | escape(strategy="json") }}" + "value": "{{ subject.project | summarize | escape(strategy="json") }}" } ], {% else %} diff --git a/src/main/resources/templates/notification/publisher/slack.peb b/src/main/resources/templates/notification/publisher/slack.peb index c3947b057..7e94de3b7 100644 --- a/src/main/resources/templates/notification/publisher/slack.peb +++ b/src/main/resources/templates/notification/publisher/slack.peb @@ -1,4 +1,4 @@ -{% if notification.group == "NEW_VULNERABILITY" %} +{% if notification.group == "GROUP_NEW_VULNERABILITY" %} { "blocks": [ { @@ -57,7 +57,7 @@ }, { "type": "plain_text", - "text": "{{ subject.component.toString | escape(strategy="json") }}" + "text": "{{ subject.component | summarize | escape(strategy="json") }}" } ] }, @@ -86,7 +86,7 @@ } ] } -{% elseif notification.group == "NEW_VULNERABLE_DEPENDENCY" %} +{% elseif notification.group == "GROUP_NEW_VULNERABLE_DEPENDENCY" %} { "blocks": [ { @@ -121,7 +121,7 @@ }, { "type": "plain_text", - "text": "{{ subject.component.toString | escape(strategy="json") }}" + "text": "{{ subject.component | summarize | escape(strategy="json") }}" }, { "type": "mrkdwn", @@ -129,7 +129,7 @@ }, { "type": "plain_text", - "text": "{{ subject.component.project.toString | escape(strategy="json") }}" + "text": "{{ subject.component.project | summarize | escape(strategy="json") }}" } ] }, @@ -158,7 +158,7 @@ } ] } -{% elseif notification.group == "PROJECT_AUDIT_CHANGE" %} +{% elseif notification.group == "GROUP_PROJECT_AUDIT_CHANGE" %} { "blocks": [ { @@ -194,7 +194,7 @@ { "type": "plain_text", "emoji": true, - "text": "{{ subject.analysis.analysisState | escape(strategy="json") }}" + "text": "{{ subject.analysis.state | escape(strategy="json") }}" }, { "type": "mrkdwn", @@ -239,7 +239,7 @@ }, { "type": "plain_text", - "text": "{{ subject.component.toString | escape(strategy="json") }}" + "text": "{{ subject.component | summarize | escape(strategy="json") }}" }, { "type": "mrkdwn", @@ -247,7 +247,7 @@ }, { "type": "plain_text", - "text": "{{ subject.project.toString | escape(strategy="json") }}" + "text": "{{ subject.project | summarize | escape(strategy="json") }}" } ] }, @@ -285,7 +285,7 @@ } ] } -{% elseif notification.group == "POLICY_VIOLATION" %} +{% elseif notification.group == "GROUP_POLICY_VIOLATION" %} { "blocks": [ { @@ -346,7 +346,7 @@ }, { "type": "plain_text", - "text": "{{ subject.component.toString | escape(strategy="json") }}" + "text": "{{ subject.component | summarize | escape(strategy="json") }}" }, { "type": "mrkdwn", diff --git a/src/main/resources/templates/notification/publisher/webhook.peb b/src/main/resources/templates/notification/publisher/webhook.peb index 5a174a0f8..234beab86 100644 --- a/src/main/resources/templates/notification/publisher/webhook.peb +++ b/src/main/resources/templates/notification/publisher/webhook.peb @@ -6,6 +6,6 @@ "timestamp": "{{ timestamp }}", "title": "{{ notification.title | escape(strategy="json") }}", "content": "{{ notification.content | escape(strategy="json") }}", - "subject": {{ subjectJson | raw }} + "subject": {% if subjectJson != null %}{{ subjectJson | raw }}{% else %}null{% endif %} } } \ No newline at end of file