Skip to content

Commit

Permalink
fix: some compatability issues in the gitlab report (#7349)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHorrocks1 authored Jan 25, 2025
1 parent 7e792df commit 28b951d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.text.WordUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.Context;
Expand Down Expand Up @@ -273,6 +274,7 @@ private VelocityContext createContext(String applicationName, List<Dependency> d
ctxt.put("rpt", new ReportTool());
ctxt.put("checksum", Checksum.class);
ctxt.put("WordUtils", new WordUtils());
ctxt.put("StringUtils", new StringUtils());
ctxt.put("VENDOR", EvidenceType.VENDOR);
ctxt.put("PRODUCT", EvidenceType.PRODUCT);
ctxt.put("VERSION", EvidenceType.VERSION);
Expand Down
27 changes: 19 additions & 8 deletions core/src/main/resources/templates/gitlabReport.vsl
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@
},

## optional properties
"name": "$enc.json($vulnerability.name)",
"name": "$enc.json($StringUtils.truncate($vulnerability.name, 255))",
#if($vulnerability.description)
"description": "$enc.json($vulnerability.description)",
#end
#if($vulnerability.unscoredSeverity)
#if($vulnerability.unscoredSeverity.equals("0.0"))
#set($severity = "Unknown")
Expand All @@ -116,15 +118,24 @@
"severity": "$severity.substring(0,1).toUpperCase()$severity.substring(1)",
## "solution": "" --> not implemented
"links": [
#set($prepend_comma = false)
#foreach( $ref in $vulnerability.getReferences(true) )
{
#if($ref.name)
## optional property
"name": "$enc.json($ref.name)",
#if($ref.url)
#if($prepend_comma)
,
#set($prepend_comma = false)
#end
{
#if($ref.name)
## optional property
"name": "$enc.json($ref.name)",
#end
"url": "$enc.json($ref.url)"
}
#if( $foreach.hasNext )
#set($prepend_comma = true)
#end
#end
"url": "$enc.json($ref.url)"
}
#if( $foreach.hasNext ),#end
#end
]
## "details": [], --> not implemented
Expand Down

0 comments on commit 28b951d

Please sign in to comment.