Class 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
    • Constructor Detail

      • 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 analyzed
        dependencies - the list of dependencies
        analyzers - the list of analyzers used
        properties - the database properties (containing timestamps of the NVD CVE data)
        settings - a reference to the database settings
        exceptions - 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)
        Constructs a new ReportGenerator.
        Parameters:
        applicationName - the application name being analyzed
        groupID - the group id of the project being analyzed
        artifactID - the application id of the project being analyzed
        version - the application version of the project being analyzed
        dependencies - the list of dependencies
        analyzers - the list of analyzers used
        properties - 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 analyzed
        groupID - the group id of the project being analyzed
        artifactID - the application id of the project being analyzed
        version - the application version of the project being analyzed
        dependencies - the list of dependencies
        analyzers - the list of analyzers used
        properties - the database properties (containing timestamps of the NVD CVE data)
        settings - a reference to the database settings
        exceptions - 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 written
        format - the format the report should be written in (a valid member of ReportGenerator.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 written
        format - the format the report should be written in (see ReportGenerator.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 location
        format - 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 load
        file - 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 load
        outputStream - the OutputStream to write the report to
        Throws:
        ReportException - is thrown when an exception occurs