mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-19 15:54:52 +01:00
Former-commit-id: 0741248ece9a4df1b1a7595b74aef31c6f74652d
This commit is contained in:
@@ -275,6 +275,11 @@ Copyright (c) 2013 Jeremy Long. All Rights Reserved.
|
|||||||
<artifactId>maven-plugin-api</artifactId>
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-settings</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-core</artifactId>
|
<artifactId>maven-core</artifactId>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.util.Locale;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.doxia.sink.Sink;
|
import org.apache.maven.doxia.sink.Sink;
|
||||||
import org.apache.maven.doxia.sink.SinkFactory;
|
import org.apache.maven.doxia.sink.SinkFactory;
|
||||||
@@ -44,6 +45,7 @@ import org.apache.maven.project.MavenProject;
|
|||||||
import org.apache.maven.reporting.MavenMultiPageReport;
|
import org.apache.maven.reporting.MavenMultiPageReport;
|
||||||
import org.apache.maven.reporting.MavenReport;
|
import org.apache.maven.reporting.MavenReport;
|
||||||
import org.apache.maven.reporting.MavenReportException;
|
import org.apache.maven.reporting.MavenReportException;
|
||||||
|
import org.apache.maven.settings.Proxy;
|
||||||
import org.owasp.dependencycheck.Engine;
|
import org.owasp.dependencycheck.Engine;
|
||||||
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
import org.owasp.dependencycheck.data.nvdcve.CveDB;
|
||||||
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
|
import org.owasp.dependencycheck.data.nvdcve.DatabaseException;
|
||||||
@@ -147,27 +149,45 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
|
|||||||
private boolean externalReport = false;
|
private boolean externalReport = false;
|
||||||
/**
|
/**
|
||||||
* The Proxy URL.
|
* The Proxy URL.
|
||||||
|
* @deprecated Please use mavenSettings instead
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
||||||
@Parameter(property = "proxyUrl", defaultValue = "", required = false)
|
@Parameter(property = "proxyUrl", defaultValue = "", required = false)
|
||||||
|
@Deprecated
|
||||||
private String proxyUrl = null;
|
private String proxyUrl = null;
|
||||||
|
|
||||||
|
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
||||||
|
@Parameter(property = "mavenSettings", defaultValue = "${settings}", required = false)
|
||||||
|
private org.apache.maven.settings.Settings mavenSettings;
|
||||||
|
|
||||||
|
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
||||||
|
@Parameter(property = "mavenSettingsProxyId", required = false)
|
||||||
|
private String mavenSettingsProxyId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Proxy Port.
|
* The Proxy Port.
|
||||||
|
* @deprecated Please use mavenSettings instead
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
||||||
@Parameter(property = "proxyPort", defaultValue = "", required = false)
|
@Parameter(property = "proxyPort", defaultValue = "", required = false)
|
||||||
|
@Deprecated
|
||||||
private String proxyPort = null;
|
private String proxyPort = null;
|
||||||
/**
|
/**
|
||||||
* The Proxy username.
|
* The Proxy username.
|
||||||
|
* @deprecated Please use mavenSettings instead
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
||||||
@Parameter(property = "proxyUsername", defaultValue = "", required = false)
|
@Parameter(property = "proxyUsername", defaultValue = "", required = false)
|
||||||
|
@Deprecated
|
||||||
private String proxyUsername = null;
|
private String proxyUsername = null;
|
||||||
/**
|
/**
|
||||||
* The Proxy password.
|
* The Proxy password.
|
||||||
|
* @deprecated Please use mavenSettings instead
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal"})
|
||||||
@Parameter(property = "proxyPassword", defaultValue = "", required = false)
|
@Parameter(property = "proxyPassword", defaultValue = "", required = false)
|
||||||
|
@Deprecated
|
||||||
private String proxyPassword = null;
|
private String proxyPassword = null;
|
||||||
/**
|
/**
|
||||||
* The Connection Timeout.
|
* The Connection Timeout.
|
||||||
@@ -721,6 +741,34 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
|
|||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
|
private String getMavenSettingsProxyUrl(Proxy proxy) {
|
||||||
|
return new StringBuilder(proxy.getProtocol()).append( "://" ).append(proxy.getHost()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Proxy getMavenProxy(){
|
||||||
|
if (mavenSettings!=null) {
|
||||||
|
List<Proxy> proxies = mavenSettings.getProxies();
|
||||||
|
if ( proxies != null && proxies.size() > 0) {
|
||||||
|
if (mavenSettingsProxyId!=null) {
|
||||||
|
for ( Proxy proxy : proxies )
|
||||||
|
{
|
||||||
|
if ( mavenSettingsProxyId.equalsIgnoreCase( proxy.getId() )) {
|
||||||
|
return proxy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (proxies.size() == 1) {
|
||||||
|
return proxies.get(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalStateException( "Ambigous proxy definition" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system
|
* Takes the properties supplied and updates the dependency-check settings. Additionally, this sets the system
|
||||||
* properties required to change the proxy url, port, and connection timeout.
|
* properties required to change the proxy url, port, and connection timeout.
|
||||||
@@ -745,6 +793,19 @@ public class DependencyCheckMojo extends AbstractMojo implements MavenMultiPageR
|
|||||||
|
|
||||||
Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate);
|
Settings.setBoolean(Settings.KEYS.AUTO_UPDATE, autoUpdate);
|
||||||
|
|
||||||
|
|
||||||
|
Proxy proxy = getMavenProxy();
|
||||||
|
if (proxy != null) {
|
||||||
|
Settings.setString(Settings.KEYS.PROXY_URL,getMavenSettingsProxyUrl(proxy));
|
||||||
|
Settings.setString(Settings.KEYS.PROXY_PORT,Integer.toString(proxy.getPort()));
|
||||||
|
String userName = proxy.getUsername();
|
||||||
|
String password = proxy.getPassword();
|
||||||
|
if ( userName != null && password != null){
|
||||||
|
Settings.setString(Settings.KEYS.PROXY_USERNAME, userName);
|
||||||
|
Settings.setString(Settings.KEYS.PROXY_PASSWORD, password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (proxyUrl != null && !proxyUrl.isEmpty()) {
|
if (proxyUrl != null && !proxyUrl.isEmpty()) {
|
||||||
Settings.setString(Settings.KEYS.PROXY_URL, proxyUrl);
|
Settings.setString(Settings.KEYS.PROXY_URL, proxyUrl);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user