mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-26 02:51:27 +01:00
added Identifier confidence for issue #35, added @Override annotations, and updated javadoc a bit
Former-commit-id: b4374d55a0e5cb0bfbf424d9465e1376eec198fa
This commit is contained in:
@@ -67,7 +67,7 @@ public class NexusAnalyzer extends AbstractAnalyzer {
|
|||||||
private static final Set<String> SUPPORTED_EXTENSIONS = newHashSet("jar");
|
private static final Set<String> SUPPORTED_EXTENSIONS = newHashSet("jar");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this is actually enabled. Will get set during initialization
|
* Whether this is actually enabled. Will get set during initialization.
|
||||||
*/
|
*/
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
@@ -79,21 +79,21 @@ public class NexusAnalyzer extends AbstractAnalyzer {
|
|||||||
/**
|
/**
|
||||||
* Initializes the analyzer once before any analysis is performed.
|
* Initializes the analyzer once before any analysis is performed.
|
||||||
*
|
*
|
||||||
* @throws Exception if there's an error during initialization.
|
* @throws Exception if there's an error during initialization
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
enabled = Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED);
|
enabled = Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_ENABLED);
|
||||||
|
|
||||||
final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL);
|
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
final String searchUrl = Settings.getString(Settings.KEYS.ANALYZER_NEXUS_URL);
|
||||||
try {
|
try {
|
||||||
searcher = new NexusSearch(new URL(searchUrl));
|
searcher = new NexusSearch(new URL(searchUrl));
|
||||||
} catch (MalformedURLException mue) {
|
} catch (MalformedURLException mue) {
|
||||||
// I know that initialize can throw an exception, but we'll
|
// I know that initialize can throw an exception, but we'll
|
||||||
// just disable the analyzer if the URL isn't valid
|
// just disable the analyzer if the URL isn't valid
|
||||||
LOGGER.warning(String.format("Property %s not a valid URL. Nexus searching disabled",
|
LOGGER.warning(String.format("Property %s not a valid URL. Nexus searching disabled", searchUrl));
|
||||||
searchUrl));
|
enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,6 +103,7 @@ public class NexusAnalyzer extends AbstractAnalyzer {
|
|||||||
*
|
*
|
||||||
* @return the name of the analyzer
|
* @return the name of the analyzer
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return ANALYZER_NAME;
|
return ANALYZER_NAME;
|
||||||
}
|
}
|
||||||
@@ -112,6 +113,7 @@ public class NexusAnalyzer extends AbstractAnalyzer {
|
|||||||
*
|
*
|
||||||
* @return the phase under which this analyzer runs
|
* @return the phase under which this analyzer runs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public AnalysisPhase getAnalysisPhase() {
|
public AnalysisPhase getAnalysisPhase() {
|
||||||
return ANALYSIS_PHASE;
|
return ANALYSIS_PHASE;
|
||||||
}
|
}
|
||||||
@@ -121,6 +123,7 @@ public class NexusAnalyzer extends AbstractAnalyzer {
|
|||||||
*
|
*
|
||||||
* @return the extensions for which this Analyzer runs
|
* @return the extensions for which this Analyzer runs
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Set<String> getSupportedExtensions() {
|
public Set<String> getSupportedExtensions() {
|
||||||
return SUPPORTED_EXTENSIONS;
|
return SUPPORTED_EXTENSIONS;
|
||||||
}
|
}
|
||||||
@@ -131,6 +134,7 @@ public class NexusAnalyzer extends AbstractAnalyzer {
|
|||||||
* @param extension the extension to check for support
|
* @param extension the extension to check for support
|
||||||
* @return whether the extension is supported
|
* @return whether the extension is supported
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean supportsExtension(String extension) {
|
public boolean supportsExtension(String extension) {
|
||||||
return SUPPORTED_EXTENSIONS.contains(extension);
|
return SUPPORTED_EXTENSIONS.contains(extension);
|
||||||
}
|
}
|
||||||
@@ -142,6 +146,7 @@ public class NexusAnalyzer extends AbstractAnalyzer {
|
|||||||
* @param engine the engine
|
* @param engine the engine
|
||||||
* @throws AnalysisException when there's an exception during analysis
|
* @throws AnalysisException when there's an exception during analysis
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void analyze(Dependency dependency, Engine engine) throws AnalysisException {
|
public void analyze(Dependency dependency, Engine engine) throws AnalysisException {
|
||||||
// Make a quick exit if this analyzer is disabled
|
// Make a quick exit if this analyzer is disabled
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
@@ -160,7 +165,7 @@ public class NexusAnalyzer extends AbstractAnalyzer {
|
|||||||
dependency.getVersionEvidence().addEvidence("nexus", "version", ma.getVersion(), Confidence.HIGH);
|
dependency.getVersionEvidence().addEvidence("nexus", "version", ma.getVersion(), Confidence.HIGH);
|
||||||
}
|
}
|
||||||
if (ma.getArtifactUrl() != null && !"".equals(ma.getArtifactUrl())) {
|
if (ma.getArtifactUrl() != null && !"".equals(ma.getArtifactUrl())) {
|
||||||
dependency.addIdentifier("maven", ma.toString(), ma.getArtifactUrl());
|
dependency.addIdentifier("maven", ma.toString(), ma.getArtifactUrl(), Confidence.HIGHEST);
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
dependency.addAnalysisException(new AnalysisException("Invalid SHA-1"));
|
dependency.addAnalysisException(new AnalysisException("Invalid SHA-1"));
|
||||||
|
|||||||
Reference in New Issue
Block a user