public abstract class BaseDependencyCheckMojo
extends org.apache.maven.plugin.AbstractMojo
implements org.apache.maven.reporting.MavenReport
| Constructor and Description |
|---|
BaseDependencyCheckMojo() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkForFailure(List<Dependency> dependencies)
Checks to see if a vulnerability has been identified with a CVSS score that is above the threshold set in the
configuration.
|
protected boolean |
excludeFromScan(org.apache.maven.artifact.Artifact a)
Tests is the artifact should be included in the scan (i.e.
|
void |
execute()
Executes dependency-check.
|
void |
generate(org.codehaus.doxia.sink.Sink sink,
Locale locale)
Deprecated.
|
void |
generate(org.apache.maven.doxia.sink.Sink sink,
Locale locale)
Generates the Dependency-Check Site Report.
|
String |
getCategoryName()
Returns the category name.
|
protected String |
getConnectionString()
Returns the connection string.
|
protected File |
getCorrectOutputDirectory()
Returns the correct output directory depending on if a site is being executed or not.
|
protected File |
getCorrectOutputDirectory(org.apache.maven.project.MavenProject current)
Returns the correct output directory depending on if a site is being executed or not.
|
protected File |
getDataFile(org.apache.maven.project.MavenProject current)
Returns the correct output directory depending on if a site is being executed or not.
|
protected String |
getDataFileContextKey()
Returns the key used to store the path to the data file that is saved by
writeDataFile(). |
protected String |
getFormat()
Returns the report format.
|
File |
getOutputDirectory()
Returns the output directory.
|
protected String |
getOutputDirectoryContextKey()
Returns the key used to store the path to the output directory.
|
String |
getOutputName()
Returns the output name.
|
protected org.apache.maven.project.MavenProject |
getProject()
Returns a reference to the current project.
|
protected List<org.apache.maven.project.MavenProject> |
getReactorProjects()
Returns the list of Maven Projects in this build.
|
File |
getReportOutputDirectory()
Returns the report output directory.
|
protected Engine |
initializeEngine()
Initializes a new
Engine that can be used for scanning. |
boolean |
isExternalReport()
Returns whether this is an external report.
|
protected void |
populateSettings()
Takes the properties supplied and updates the dependency-check settings.
|
protected List<Dependency> |
readDataFile(org.apache.maven.project.MavenProject project)
Reads the serialized scan data from disk.
|
abstract void |
runCheck()
Executes the dependency-check scan and generates the necassary report.
|
protected void |
scanArtifacts(org.apache.maven.project.MavenProject project,
Engine engine)
Scans the project's artifacts and adds them to the engine's dependency list.
|
void |
setReportOutputDirectory(File directory)
Sets the Reporting output directory.
|
protected void |
showSummary(org.apache.maven.project.MavenProject mp,
List<Dependency> dependencies)
Generates a warning message listing a summary of dependencies and their associated CPE and CVE entries.
|
protected void |
writeDataFile(org.apache.maven.project.MavenProject mp,
File writeTo,
List<Dependency> dependencies)
Writes the scan data to disk.
|
protected void |
writeReports(Engine engine,
org.apache.maven.project.MavenProject p,
File outputDir)
Generates the reports for a given dependency-check engine.
|
getLog, getPluginContext, setLog, setPluginContextprotected String getConnectionString()
public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
execute in interface org.apache.maven.plugin.Mojoorg.apache.maven.plugin.MojoExecutionException - thrown if there is an exception executing the mojoorg.apache.maven.plugin.MojoFailureException - thrown if dependency-check failed the build@Deprecated public final void generate(org.codehaus.doxia.sink.Sink sink, Locale locale) throws org.apache.maven.reporting.MavenReportException
generate(org.apache.maven.doxia.sink.Sink, java.util.Locale) instead.generate in interface org.apache.maven.reporting.MavenReportsink - the sink to write the report tolocale - the locale to use when generating the reportorg.apache.maven.reporting.MavenReportException - if a maven report exception occurspublic void generate(org.apache.maven.doxia.sink.Sink sink,
Locale locale)
throws org.apache.maven.reporting.MavenReportException
sink - the sink to write the report tolocale - the locale to use when generating the reportorg.apache.maven.reporting.MavenReportException - if a maven report exception occursprotected File getCorrectOutputDirectory() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException - thrown if there is an error loading the file pathprotected File getCorrectOutputDirectory(org.apache.maven.project.MavenProject current)
current - the Maven project to get the output directory fromprotected File getDataFile(org.apache.maven.project.MavenProject current)
current - the Maven project to get the output directory fromprotected void scanArtifacts(org.apache.maven.project.MavenProject project,
Engine engine)
project - the project to scan the dependencies ofengine - the engine to use to scan the dependenciespublic abstract void runCheck()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException - thrown if there is an exception running the scanorg.apache.maven.plugin.MojoFailureException - thrown if dependency-check is configured to fail the buildpublic void setReportOutputDirectory(File directory)
setReportOutputDirectory in interface org.apache.maven.reporting.MavenReportdirectory - the output directorypublic File getReportOutputDirectory()
getReportOutputDirectory in interface org.apache.maven.reporting.MavenReportpublic File getOutputDirectory()
public final boolean isExternalReport()
isExternalReport in interface org.apache.maven.reporting.MavenReporttruepublic String getOutputName()
getOutputName in interface org.apache.maven.reporting.MavenReportpublic String getCategoryName()
getCategoryName in interface org.apache.maven.reporting.MavenReportprotected Engine initializeEngine() throws DatabaseException
Engine that can be used for scanning.EngineDatabaseException - thrown if there is a database exceptionprotected void populateSettings()
protected boolean excludeFromScan(org.apache.maven.artifact.Artifact a)
a - the Artifact to testtrue if the artifact is in an excluded scope; otherwise falseprotected org.apache.maven.project.MavenProject getProject()
@Component MavenProject project; defined
then the abstract class (i.e. this class) will not have access to the current project (just the way Maven works with the
binding).protected List<org.apache.maven.project.MavenProject> getReactorProjects()
protected String getFormat()
protected void writeReports(Engine engine, org.apache.maven.project.MavenProject p, File outputDir)
engine - a dependency-check enginep - the maven projectoutputDir - the directory path to write the report(s).protected void checkForFailure(List<Dependency> dependencies) throws org.apache.maven.plugin.MojoFailureException
dependencies - the list of dependency objectsorg.apache.maven.plugin.MojoFailureException - thrown if a CVSS score is found that is higher then the threshold setprotected void showSummary(org.apache.maven.project.MavenProject mp,
List<Dependency> dependencies)
mp - the Maven project for which the summary is showndependencies - a list of dependency objectsprotected String getDataFileContextKey()
writeDataFile(). This key is used in
the MavenProject.(set|get)ContextValue.protected String getOutputDirectoryContextKey()
executeAggregateReport() the output directory should be obtained by using this key.protected void writeDataFile(org.apache.maven.project.MavenProject mp,
File writeTo,
List<Dependency> dependencies)
mp - the mMven project for which the data file was createdwriteTo - the directory to write the data filedependencies - the list of dependencies to serializeprotected List<Dependency> readDataFile(org.apache.maven.project.MavenProject project)
project - the Maven project to read the data file fromEngine object populated with dependencies if the serialized data file exists; otherwise
null is returnedCopyright © 2013–2016 OWASP. All rights reserved.