Class ReportGenerator
- java.lang.Object
-
- org.owasp.dependencycheck.reporting.ReportGenerator
-
@NotThreadSafe public class ReportGenerator extends java.lang.Object
The ReportGenerator is used to, as the name implies, generate reports. Internally the generator uses the Velocity Templating Engine. The ReportGenerator exposes a list of Dependencies to the template when generating the report.- Author:
- Jeremy Long
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReportGenerator.Format
An enumeration of the report formats.
-
Constructor Summary
Constructors Constructor Description ReportGenerator(java.lang.String applicationName, java.lang.String groupID, java.lang.String artifactID, java.lang.String version, java.util.List<Dependency> dependencies, java.util.List<Analyzer> analyzers, DatabaseProperties properties, Settings settings)
ReportGenerator(java.lang.String applicationName, java.lang.String groupID, java.lang.String artifactID, java.lang.String version, java.util.List<Dependency> dependencies, java.util.List<Analyzer> analyzers, DatabaseProperties properties, Settings settings, ExceptionCollection exceptions)
Constructs a new ReportGenerator.ReportGenerator(java.lang.String applicationName, java.util.List<Dependency> dependencies, java.util.List<Analyzer> analyzers, DatabaseProperties properties, Settings settings)
ReportGenerator(java.lang.String applicationName, java.util.List<Dependency> dependencies, java.util.List<Analyzer> analyzers, DatabaseProperties properties, Settings settings, ExceptionCollection exceptions)
Constructs a new ReportGenerator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.io.File
getReportFile(java.lang.String outputLocation, ReportGenerator.Format format)
Determines the report file name based on the give output location and format.protected void
processTemplate(java.lang.String template, java.io.File file)
Generates a report from a given Velocity Template.protected void
processTemplate(java.lang.String templateName, java.io.OutputStream outputStream)
Generates a report from a given Velocity Template.void
write(java.lang.String outputLocation, java.lang.String format)
Writes the dependency-check report to the given output location.void
write(java.lang.String outputLocation, ReportGenerator.Format format)
Writes the dependency-check report(s).
-
-
-
Constructor Detail
-
ReportGenerator
@Deprecated public ReportGenerator(java.lang.String applicationName, java.util.List<Dependency> dependencies, java.util.List<Analyzer> analyzers, DatabaseProperties properties, Settings settings)
Deprecated.Constructs a new ReportGenerator.- Parameters:
applicationName
- the application name being analyzeddependencies
- the list of dependenciesanalyzers
- the list of analyzers usedproperties
- the database properties (containing timestamps of the NVD CVE data)settings
- a reference to the database settings
-
ReportGenerator
public ReportGenerator(java.lang.String applicationName, java.util.List<Dependency> dependencies, java.util.List<Analyzer> analyzers, DatabaseProperties properties, Settings settings, ExceptionCollection exceptions)
Constructs a new ReportGenerator.- Parameters:
applicationName
- the application name being analyzeddependencies
- the list of dependenciesanalyzers
- the list of analyzers usedproperties
- the database properties (containing timestamps of the NVD CVE data)settings
- a reference to the database settingsexceptions
- a collection of exceptions that may have occurred during the analysis- Since:
- 5.1.0
-
ReportGenerator
@Deprecated public ReportGenerator(java.lang.String applicationName, java.lang.String groupID, java.lang.String artifactID, java.lang.String version, java.util.List<Dependency> dependencies, java.util.List<Analyzer> analyzers, DatabaseProperties properties, Settings settings)
Deprecated.Constructs a new ReportGenerator.- Parameters:
applicationName
- the application name being analyzedgroupID
- the group id of the project being analyzedartifactID
- the application id of the project being analyzedversion
- the application version of the project being analyzeddependencies
- the list of dependenciesanalyzers
- the list of analyzers usedproperties
- the database properties (containing timestamps of the NVD CVE data)settings
- a reference to the database settings
-
ReportGenerator
public ReportGenerator(java.lang.String applicationName, java.lang.String groupID, java.lang.String artifactID, java.lang.String version, java.util.List<Dependency> dependencies, java.util.List<Analyzer> analyzers, DatabaseProperties properties, Settings settings, ExceptionCollection exceptions)
Constructs a new ReportGenerator.- Parameters:
applicationName
- the application name being analyzedgroupID
- the group id of the project being analyzedartifactID
- the application id of the project being analyzedversion
- the application version of the project being analyzeddependencies
- the list of dependenciesanalyzers
- the list of analyzers usedproperties
- the database properties (containing timestamps of the NVD CVE data)settings
- a reference to the database settingsexceptions
- a collection of exceptions that may have occurred during the analysis- Since:
- 5.1.0
-
-
Method Detail
-
write
public void write(java.lang.String outputLocation, java.lang.String format) throws ReportException
Writes the dependency-check report to the given output location.- Parameters:
outputLocation
- the path where the reports should be writtenformat
- the format the report should be written in (a valid member ofReportGenerator.Format
) or even the path to a custom velocity template (either fully qualified or the template name on the class path).- Throws:
ReportException
- is thrown if there is an error creating out the reports
-
write
public void write(java.lang.String outputLocation, ReportGenerator.Format format) throws ReportException
Writes the dependency-check report(s).- Parameters:
outputLocation
- the path where the reports should be writtenformat
- the format the report should be written in (seeReportGenerator.Format
)- Throws:
ReportException
- is thrown if there is an error creating out the reports
-
getReportFile
public static java.io.File getReportFile(java.lang.String outputLocation, ReportGenerator.Format format)
Determines the report file name based on the give output location and format. If the output location contains a full file name that has the correct extension for the given report type then the output location is returned. However, if the output location is a directory, this method will generate the correct name for the given output format.- Parameters:
outputLocation
- the specified output locationformat
- the report format- Returns:
- the report File
-
processTemplate
protected void processTemplate(java.lang.String template, java.io.File file) throws ReportException
Generates a report from a given Velocity Template. The template name provided can be the name of a template contained in the jar file, such as 'XmlReport' or 'HtmlReport', or the template name can be the path to a template file.- Parameters:
template
- the name of the template to loadfile
- the output file to write the report to- Throws:
ReportException
- is thrown when the report cannot be generated
-
processTemplate
protected void processTemplate(java.lang.String templateName, java.io.OutputStream outputStream) throws ReportException
Generates a report from a given Velocity Template. The template name provided can be the name of a template contained in the jar file, such as 'XmlReport' or 'HtmlReport', or the template name can be the path to a template file.- Parameters:
templateName
- the name of the template to loadoutputStream
- the OutputStream to write the report to- Throws:
ReportException
- is thrown when an exception occurs
-
-