diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java index 76744b675..ade039960 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/CentralAnalyzer.java @@ -29,7 +29,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer { /** * The name of the analyzer. */ - private static final String ANALYZER_NAME = "Solr Analyzer"; + private static final String ANALYZER_NAME = "Central Analyzer"; /** * The phase in which this analyzer runs. @@ -62,19 +62,19 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer { boolean retval = false; try { - if (Settings.getBoolean(Settings.KEYS.ANALYZER_SOLR_ENABLED)) { + if (Settings.getBoolean(Settings.KEYS.ANALYZER_CENTRAL_ENABLED)) { if (!Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED) || NexusAnalyzer.DEFAULT_URL.equals(Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL))) { - LOGGER.info("Enabling the Solr analyzer"); + LOGGER.info("Enabling the Central analyzer"); retval = true; } else { - LOGGER.info("Nexus analyzer is enabled, disabling Solr"); + LOGGER.info("Nexus analyzer is enabled, disabling Central"); } } else { - LOGGER.info("Solr analyzer disabled"); + LOGGER.info("Central analyzer disabled"); } } catch (InvalidSettingException ise) { - LOGGER.warning("Invalid setting. Disabling the Solr analyzer"); + LOGGER.warning("Invalid setting. Disabling the Central analyzer"); } return retval; @@ -87,11 +87,11 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer { */ @Override public void initializeFileTypeAnalyzer() throws Exception { - LOGGER.fine("Initializing Solr analyzer"); - LOGGER.fine(String.format("Solr analyzer enabled: %s", isEnabled())); + LOGGER.fine("Initializing Central analyzer"); + LOGGER.fine(String.format("Central analyzer enabled: %s", isEnabled())); if (isEnabled()) { - final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_SOLR_URL); - LOGGER.fine(String.format("Solr Analyzer URL: %s", searchUrl)); + final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_CENTRAL_URL); + LOGGER.fine(String.format("Central Analyzer URL: %s", searchUrl)); searcher = new CentralSearch(new URL(searchUrl)); } } @@ -112,7 +112,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer { */ @Override protected String getAnalyzerEnabledSettingKey() { - return Settings.KEYS.ANALYZER_SOLR_ENABLED; + return Settings.KEYS.ANALYZER_CENTRAL_ENABLED; } /** @@ -160,7 +160,7 @@ public class CentralAnalyzer extends AbstractFileTypeAnalyzer { } catch (FileNotFoundException fnfe) { LOGGER.fine(String.format("Artifact not found in repository: '%s", dependency.getFileName())); } catch (IOException ioe) { - LOGGER.log(Level.FINE, "Could not connect to Solr search", ioe); + LOGGER.log(Level.FINE, "Could not connect to Central search", ioe); errorFlag = true; } } diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java index 2d9d608e5..22db369ad 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/analyzer/NexusAnalyzer.java @@ -52,7 +52,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; */ public class NexusAnalyzer extends AbstractFileTypeAnalyzer { /** - * The default URL - this will be used by the SolrAnalyzer to determine whether to enable this. + * The default URL - this will be used by the CentralAnalyzer to determine whether to enable this. */ public static final String DEFAULT_URL = "https://repository.sonatype.org/service/local/"; diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java index 4c55e47a1..8977d13e7 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/central/CentralSearch.java @@ -21,13 +21,13 @@ import java.util.List; import java.util.logging.Logger; /** - * Class of methods to search Maven Central via Solr. + * Class of methods to search Maven Central via Central. * * @author colezlaw */ public class CentralSearch { /** - * The URL for the Solr service + * The URL for the Central service */ private final URL rootURL; @@ -55,22 +55,17 @@ public class CentralSearch { */ public CentralSearch(URL rootURL) { this.rootURL = rootURL; - try { - if (null != Settings.getString(Settings.KEYS.PROXY_SERVER) - && Settings.getBoolean(Settings.KEYS.ANALYZER_SOLR_PROXY)) { - useProxy = true; - LOGGER.fine("Using proxy"); - } else { - useProxy = false; - LOGGER.fine("Not using proxy"); - } - } catch (InvalidSettingException ise) { + if (null != Settings.getString(Settings.KEYS.PROXY_SERVER)) { + useProxy = true; + LOGGER.fine("Using proxy"); + } else { useProxy = false; + LOGGER.fine("Not using proxy"); } } /** - * Searches the configured Solr URL for the given sha1 hash. If the artifact is found, a + * Searches the configured Central URL for the given sha1 hash. If the artifact is found, a * MavenArtifact is populated with the GAV. * * @param sha1 the SHA-1 hash string for which to search @@ -85,7 +80,7 @@ public class CentralSearch { final URL url = new URL(rootURL + String.format("?q=1:\"%s\"&wt=xml", sha1)); - LOGGER.info(String.format("Searching Solr url %s", url.toString())); + LOGGER.info(String.format("Searching Central url %s", url.toString())); // Determine if we need to use a proxy. The rules: // 1) If the proxy is set, AND the setting is set to true, use the proxy @@ -132,10 +127,10 @@ public class CentralSearch { } if (missing) { - throw new FileNotFoundException("Artifact not found in Solr"); + throw new FileNotFoundException("Artifact not found in Central"); } } else { - final String msg = String.format("Could not connect to Solr received response code: %d %s", + final String msg = String.format("Could not connect to Central received response code: %d %s", conn.getResponseCode(), conn.getResponseMessage()); LOGGER.fine(msg); throw new IOException(msg); diff --git a/dependency-check-core/src/main/resources/dependencycheck.properties b/dependency-check-core/src/main/resources/dependencycheck.properties index 65d748ed0..9f764fd0a 100644 --- a/dependency-check-core/src/main/resources/dependencycheck.properties +++ b/dependency-check-core/src/main/resources/dependencycheck.properties @@ -60,8 +60,5 @@ analyzer.nexus.url=https://repository.sonatype.org/service/local/ analyzer.nexus.proxy=true # the URL for searching search.maven.org for SHA-1 and whether it's enabled -analyzer.solr.enabled=true -analyzer.solr.url=http://search.maven.org/solrsearch/select -# If set to true, the proxy will still ONLY be used if the proxy properties (proxy.url, proxy.port) -# are configured -analyzer.solr.proxy=true \ No newline at end of file +analyzer.central.enabled=true +analyzer.central.url=http://search.maven.org/solrsearch/select diff --git a/dependency-check-core/src/test/java/org/owasp/dependencycheck/data/central/CentralSearchTest.java b/dependency-check-core/src/test/java/org/owasp/dependencycheck/data/central/CentralSearchTest.java index ffcde235e..d75ef404a 100644 --- a/dependency-check-core/src/test/java/org/owasp/dependencycheck/data/central/CentralSearchTest.java +++ b/dependency-check-core/src/test/java/org/owasp/dependencycheck/data/central/CentralSearchTest.java @@ -22,9 +22,9 @@ public class CentralSearchTest extends BaseTest { @Before public void setUp() throws Exception { - String solrUrl = Settings.getString(Settings.KEYS.ANALYZER_SOLR_URL); - LOGGER.fine(solrUrl); - searcher = new CentralSearch(new URL(solrUrl)); + String centralUrl = Settings.getString(Settings.KEYS.ANALYZER_CENTRAL_URL); + LOGGER.fine(centralUrl); + searcher = new CentralSearch(new URL(centralUrl)); } @Test(expected = IllegalArgumentException.class) @@ -54,7 +54,7 @@ public class CentralSearchTest extends BaseTest { searcher.searchSha1("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); } - // This test should give us multiple results back from Solr + // This test should give us multiple results back from Central @Test public void testMultipleReturns() throws Exception { List ma = searcher.searchSha1("94A9CE681A42D0352B3AD22659F67835E560D107"); diff --git a/dependency-check-core/src/test/resources/dependencycheck.properties b/dependency-check-core/src/test/resources/dependencycheck.properties index 07d11d566..ae48d04c2 100644 --- a/dependency-check-core/src/test/resources/dependencycheck.properties +++ b/dependency-check-core/src/test/resources/dependencycheck.properties @@ -61,7 +61,5 @@ analyzer.nexus.url=https://repository.sonatype.org/service/local/ analyzer.nexus.proxy=true # the URL for searching search.maven.org for SHA-1 and whether it's enabled -analyzer.solr.enabled=true -analyzer.solr.url=http://search.maven.org/solrsearch/select -# If set to true, the proxy will still ONLY be used if the proxy properties (proxy.url, proxy.port) -# are configured \ No newline at end of file +analyzer.central.enabled=true +analyzer.central.url=http://search.maven.org/solrsearch/select diff --git a/dependency-check-utils/src/main/java/org/owasp/dependencycheck/utils/Settings.java b/dependency-check-utils/src/main/java/org/owasp/dependencycheck/utils/Settings.java index 5306e3073..e8c413366 100644 --- a/dependency-check-utils/src/main/java/org/owasp/dependencycheck/utils/Settings.java +++ b/dependency-check-utils/src/main/java/org/owasp/dependencycheck/utils/Settings.java @@ -189,17 +189,13 @@ public final class Settings { */ public static final String ANALYZER_NEXUS_PROXY = "analyzer.nexus.proxy"; /** - * The properties key for whether the Solr analyzer is enabled. + * The properties key for whether the Central analyzer is enabled. */ - public static final String ANALYZER_SOLR_ENABLED = "analyzer.solr.enabled"; + public static final String ANALYZER_CENTRAL_ENABLED = "analyzer.central.enabled"; /** - * The properties key for the Solr search URL. + * The properties key for the Central search URL. */ - public static final String ANALYZER_SOLR_URL = "analyzer.solr.url"; - /** - * The properties key for using the proxy to reach Solr. - */ - public static final String ANALYZER_SOLR_PROXY = "analyzer.solr.proxy"; + public static final String ANALYZER_CENTRAL_URL = "analyzer.central.url"; /** * The path to mono, if available. */