Skip to content

Commit 28b951d

Browse files
fix: some compatability issues in the gitlab report (#7349)
1 parent 7e792df commit 28b951d

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

core/src/main/java/org/owasp/dependencycheck/reporting/ReportGenerator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2424
import org.apache.commons.io.FilenameUtils;
2525
import org.apache.commons.text.WordUtils;
26+
import org.apache.commons.lang3.StringUtils;
2627
import org.apache.velocity.VelocityContext;
2728
import org.apache.velocity.app.VelocityEngine;
2829
import org.apache.velocity.context.Context;
@@ -273,6 +274,7 @@ private VelocityContext createContext(String applicationName, List<Dependency> d
273274
ctxt.put("rpt", new ReportTool());
274275
ctxt.put("checksum", Checksum.class);
275276
ctxt.put("WordUtils", new WordUtils());
277+
ctxt.put("StringUtils", new StringUtils());
276278
ctxt.put("VENDOR", EvidenceType.VENDOR);
277279
ctxt.put("PRODUCT", EvidenceType.PRODUCT);
278280
ctxt.put("VERSION", EvidenceType.VERSION);

core/src/main/resources/templates/gitlabReport.vsl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@
9898
},
9999

100100
## optional properties
101-
"name": "$enc.json($vulnerability.name)",
101+
"name": "$enc.json($StringUtils.truncate($vulnerability.name, 255))",
102+
#if($vulnerability.description)
102103
"description": "$enc.json($vulnerability.description)",
104+
#end
103105
#if($vulnerability.unscoredSeverity)
104106
#if($vulnerability.unscoredSeverity.equals("0.0"))
105107
#set($severity = "Unknown")
@@ -116,15 +118,24 @@
116118
"severity": "$severity.substring(0,1).toUpperCase()$severity.substring(1)",
117119
## "solution": "" --> not implemented
118120
"links": [
121+
#set($prepend_comma = false)
119122
#foreach( $ref in $vulnerability.getReferences(true) )
120-
{
121-
#if($ref.name)
122-
## optional property
123-
"name": "$enc.json($ref.name)",
123+
#if($ref.url)
124+
#if($prepend_comma)
125+
,
126+
#set($prepend_comma = false)
127+
#end
128+
{
129+
#if($ref.name)
130+
## optional property
131+
"name": "$enc.json($ref.name)",
132+
#end
133+
"url": "$enc.json($ref.url)"
134+
}
135+
#if( $foreach.hasNext )
136+
#set($prepend_comma = true)
137+
#end
124138
#end
125-
"url": "$enc.json($ref.url)"
126-
}
127-
#if( $foreach.hasNext ),#end
128139
#end
129140
]
130141
## "details": [], --> not implemented

0 commit comments

Comments
 (0)