Skip to content

Commit e5360a4

Browse files
authored
Merge pull request #5532 from nscuro/backport-pr-5438
2 parents 770d772 + 10fed5f commit e5360a4

File tree

8 files changed

+100
-102
lines changed

8 files changed

+100
-102
lines changed

src/main/java/org/dependencytrack/model/Project.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -664,19 +664,15 @@ public void setDependencyGraph(List<Component> dependencyGraph) {
664664

665665
@Override
666666
public String toString() {
667-
if (getPurl() != null) {
668-
return getPurl().canonicalize();
669-
} else {
670-
StringBuilder sb = new StringBuilder();
671-
if (getGroup() != null) {
672-
sb.append(getGroup()).append(" : ");
673-
}
674-
sb.append(getName());
675-
if (getVersion() != null) {
676-
sb.append(" : ").append(getVersion());
677-
}
678-
return sb.toString();
667+
StringBuilder sb = new StringBuilder();
668+
if (getGroup() != null) {
669+
sb.append(getGroup()).append(" : ");
670+
}
671+
sb.append(getName());
672+
if (getVersion() != null) {
673+
sb.append(" : ").append(getVersion());
679674
}
675+
return sb.toString();
680676
}
681677

682678
private final static class BooleanDefaultTrueSerializer extends JsonSerializer<Boolean> {

src/test/java/org/dependencytrack/notification/publisher/AbstractPublisherTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public void testInformWithNewVulnerabilityNotification() {
181181
.scope(NotificationScope.PORTFOLIO)
182182
.group(NotificationGroup.NEW_VULNERABILITY)
183183
.level(NotificationLevel.INFORMATIONAL)
184-
.title(NotificationConstants.Title.NEW_VULNERABILITY)
184+
.title(NotificationUtil.generateNotificationTitle(NotificationConstants.Title.NEW_VULNERABILITY, project))
185185
.content("")
186186
.timestamp(LocalDateTime.ofEpochSecond(66666, 666, ZoneOffset.UTC))
187187
.subject(subject);
@@ -318,6 +318,8 @@ public void testPublishWithScheduledNewPolicyViolationsNotification() {
318318
.isThrownBy(() -> publisherInstance.inform(PublishContext.from(notification), notification, createConfig()));
319319
}
320320

321+
322+
321323
private static Component createComponent(final Project project) {
322324
final var component = new Component();
323325
component.setProject(project);

src/test/java/org/dependencytrack/notification/publisher/JiraPublisherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public void testInformWithNewVulnerableDependencyNotification() {
222222
"name": "Task"
223223
},
224224
"summary": "[Dependency-Track] [NEW_VULNERABLE_DEPENDENCY] Vulnerable dependency introduced on project projectName",
225-
"description": "A component which contains one or more vulnerabilities has been added to your project.\\n\\\\\\\\\\n\\\\\\\\\\n*Project*\\n[pkg:maven/org.acme/projectName@projectVersion|https://example.com/projects/c9c9539a-e381-4b36-ac52-6a7ab83b2c95]\\n\\n*Component*\\n[componentName : componentVersion|https://example.com/components/94f87321-a5d1-4c2f-b2fe-95165debebc6]\\n\\n*Vulnerabilities*\\n- INT-001 (Medium)\\n"
225+
"description": "A component which contains one or more vulnerabilities has been added to your project.\\n\\\\\\\\\\n\\\\\\\\\\n*Project*\\n[projectName : projectVersion|https://example.com/projects/c9c9539a-e381-4b36-ac52-6a7ab83b2c95]\\n\\n*Component*\\n[componentName : componentVersion|https://example.com/components/94f87321-a5d1-4c2f-b2fe-95165debebc6]\\n\\n*Vulnerabilities*\\n- INT-001 (Medium)\\n"
226226
}
227227
}
228228
""")));

src/test/java/org/dependencytrack/notification/publisher/MattermostPublisherTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void testInformWithBomConsumedNotification() {
4040
{
4141
"username": "Dependency Track",
4242
"icon_url": "https://raw.githubusercontent.com/DependencyTrack/branding/master/dt-logo-symbol-blue-background.png",
43-
"text": "#### Bill of Materials Consumed\\nA CycloneDX BOM was consumed and will be processed\\n**Project**: pkg:maven/org.acme/projectName@projectVersion\\n[View Project](https://example.com/projects/c9c9539a-e381-4b36-ac52-6a7ab83b2c95)"
43+
"text": "#### Bill of Materials Consumed\\nA CycloneDX BOM was consumed and will be processed\\n**Project**: projectName : projectVersion\\n[View Project](https://example.com/projects/c9c9539a-e381-4b36-ac52-6a7ab83b2c95)"
4444
}
4545
""")));
4646
}
@@ -115,7 +115,7 @@ public void testInformWithNewVulnerabilityNotification() {
115115
{
116116
"username": "Dependency Track",
117117
"icon_url": "https://raw.githubusercontent.com/DependencyTrack/branding/master/dt-logo-symbol-blue-background.png",
118-
"text": "#### New Vulnerability Identified\\n\\n**Component**: componentName : componentVersion\\n**Vulnerability**: INT-001, MEDIUM\\n[View Component](https://example.com/components/94f87321-a5d1-4c2f-b2fe-95165debebc6) - [View Vulnerability](https://example.com/vulnerabilities/INTERNAL/INT-001)"
118+
"text": "#### New Vulnerability Identified on Project: [projectName : projectVersion]\\n\\n**Component**: componentName : componentVersion\\n**Vulnerability**: INT-001, MEDIUM\\n[View Component](https://example.com/components/94f87321-a5d1-4c2f-b2fe-95165debebc6) - [View Vulnerability](https://example.com/vulnerabilities/INTERNAL/INT-001)"
119119
}
120120
""")));
121121
}
@@ -145,7 +145,7 @@ public void testInformWithProjectAuditChangeNotification() {
145145
{
146146
"username": "Dependency Track",
147147
"icon_url": "https://raw.githubusercontent.com/DependencyTrack/branding/master/dt-logo-symbol-blue-background.png",
148-
"text": "#### Analysis Decision: Finding Suppressed\\n\\n**Project**: pkg:maven/org.acme/projectName@projectVersion\\n**Component**: componentName : componentVersion\\n**Vulnerability**: INT-001, MEDIUM\\n**Analysis**: FALSE_POSITIVE, suppressed: true\\n[View Project](https://example.com/projects/c9c9539a-e381-4b36-ac52-6a7ab83b2c95) - [View Component](https://example.com/components/94f87321-a5d1-4c2f-b2fe-95165debebc6) - [View Vulnerability](https://example.com/vulnerabilities/INTERNAL/INT-001)"
148+
"text": "#### Analysis Decision: Finding Suppressed\\n\\n**Project**: projectName : projectVersion\\n**Component**: componentName : componentVersion\\n**Vulnerability**: INT-001, MEDIUM\\n**Analysis**: FALSE_POSITIVE, suppressed: true\\n[View Project](https://example.com/projects/c9c9539a-e381-4b36-ac52-6a7ab83b2c95) - [View Component](https://example.com/components/94f87321-a5d1-4c2f-b2fe-95165debebc6) - [View Vulnerability](https://example.com/vulnerabilities/INTERNAL/INT-001)"
149149
}
150150
""")));
151151
}

src/test/java/org/dependencytrack/notification/publisher/MsTeamsPublisherTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void testInformWithBomProcessingFailedNotification() {
100100
},
101101
{
102102
"name": "Project",
103-
"value": "pkg:maven/org.acme/projectName@projectVersion"
103+
"value": "projectName : projectVersion"
104104
},
105105
{
106106
"name": "Project URL",
@@ -146,7 +146,7 @@ public void testInformWithBomValidationFailedNotification() {
146146
},
147147
{
148148
"name": "Project",
149-
"value": "pkg:maven/org.acme/projectName@projectVersion"
149+
"value": "projectName : projectVersion"
150150
},
151151
{
152152
"name": "Project URL",
@@ -196,7 +196,7 @@ public void testInformWithBomProcessingFailedNotificationAndNoSpecVersionInSubje
196196
},
197197
{
198198
"name": "Project",
199-
"value": "pkg:maven/org.acme/projectName@projectVersion"
199+
"value": "projectName : projectVersion"
200200
},
201201
{
202202
"name": "Project URL",
@@ -258,8 +258,8 @@ public void testInformWithNewVulnerabilityNotification() {
258258
{
259259
"@type": "MessageCard",
260260
"@context": "http://schema.org/extensions",
261-
"summary": "New Vulnerability Identified",
262-
"title": "New Vulnerability Identified",
261+
"summary": "New Vulnerability Identified on Project: [projectName : projectVersion]",
262+
"title": "New Vulnerability Identified on Project: [projectName : projectVersion]",
263263
"sections": [
264264
{
265265
"activityTitle": "Dependency-Track",
@@ -310,7 +310,7 @@ public void testInformWithNewVulnerableDependencyNotification() {
310310
"facts": [
311311
{
312312
"name": "Project",
313-
"value": "pkg:maven/org.acme/projectName@projectVersion"
313+
"value": "projectName : projectVersion"
314314
},
315315
{
316316
"name": "Component",
@@ -372,7 +372,7 @@ public void testInformWithProjectAuditChangeNotification() {
372372
},
373373
{
374374
"name": "Project",
375-
"value": "pkg:maven/org.acme/projectName@projectVersion"
375+
"value": "projectName : projectVersion"
376376
}
377377
],
378378
"text": ""

0 commit comments

Comments
 (0)