@Override
    public void analyzeDependency(Dependency dependency, Engine engine) throws AnalysisException {
        if (!isEnabled()) {
            return;
        }
        try {
            final MavenArtifact ma = searcher.searchSha1(dependency.getSha1sum());
            dependency.addAsEvidence("nexus", ma, Confidence.HIGH);
            boolean pomAnalyzed = false;
            LOGGER.debug("POM URL {}", ma.getPomUrl());
            for (Evidence e : dependency.getEvidence(EvidenceType.VENDOR)) {
                if ("pom".equals(e.getSource())) {
                    pomAnalyzed = true;
                    break;
                }
            }
            if (!pomAnalyzed && ma.getPomUrl() != null) {
                File pomFile = null;
                try {
                    final File baseDir = getSettings().getTempDirectory();
                    pomFile = File.createTempFile("pom", ".xml", baseDir);
                    if (!pomFile.delete()) {
                        LOGGER.warn("Unable to fetch pom.xml for {} from Nexus repository; "
                                + "this could result in undetected CPE/CVEs.", dependency.getFileName());
                        LOGGER.debug("Unable to delete temp file");
                    }
                    LOGGER.debug("Downloading {}", ma.getPomUrl());
                    final Downloader downloader = new Downloader(getSettings());
                    downloader.fetchFile(new URL(ma.getPomUrl()), pomFile);
                    PomUtils.analyzePOM(dependency, pomFile);
                } catch (DownloadFailedException ex) {
                    LOGGER.warn("Unable to download pom.xml for {} from Nexus repository; "
                            + "this could result in undetected CPE/CVEs.", dependency.getFileName());
                } finally {
                    if (pomFile != null && pomFile.exists() && !FileUtils.deleteQuietly(pomFile)) {
                        LOGGER.debug("Failed to delete temporary pom file {}", pomFile.toString());
                        pomFile.deleteOnExit();
                    }
                }
            }
        } catch (IllegalArgumentException iae) {
            //dependency.addAnalysisException(new AnalysisException("Invalid SHA-1"));
            LOGGER.info("invalid sha-1 hash on {}", dependency.getFileName());
        } catch (FileNotFoundException fnfe) {
            //dependency.addAnalysisException(new AnalysisException("Artifact not found on repository"));
            LOGGER.debug("Artifact not found in repository '{}'", dependency.getFileName());
            LOGGER.debug(fnfe.getMessage(), fnfe);
        } catch (IOException ioe) {
            //dependency.addAnalysisException(new AnalysisException("Could not connect to repository", ioe));
            LOGGER.debug("Could not connect to nexus repository", ioe);
        }
    }
@ Override public void analyzeDependency ( Dependency dependency , Engine engine ) throws AnalysisException { if ( ! isEnabled ( ) ) { return ; } try { final MavenArtifact ma = searcher . searchSha1 ( dependency . getSha1sum ( ) ) ; dependency . addAsEvidence ( "nexus" , ma , Confidence . HIGH ) ; boolean pomAnalyzed = false ; LOGGER . debug ( "POM URL {}" , ma . getPomUrl ( ) ) ; for ( Evidence e : dependency . getEvidence ( EvidenceType . VENDOR ) ) { if ( "pom" . equals ( e . getSource ( ) ) ) { pomAnalyzed = true ; break ; } } if ( ! pomAnalyzed && ma . getPomUrl ( ) != null ) { File pomFile = null ; try { final File baseDir = getSettings ( ) . getTempDirectory ( ) ; pomFile = File . createTempFile ( "pom" , ".xml" , baseDir ) ; if ( ! pomFile . delete ( ) ) { LOGGER . warn ( "Unable to fetch pom.xml for {} from Nexus repository; " + "this could result in undetected CPE/CVEs." , dependency . getFileName ( ) ) ; LOGGER . debug ( "Unable to delete temp file" ) ; } LOGGER . debug ( "Downloading {}" , ma . getPomUrl ( ) ) ; final Downloader downloader = new Downloader ( getSettings ( ) ) ; downloader . fetchFile ( new URL ( ma . getPomUrl ( ) ) , pomFile ) ; PomUtils . analyzePOM ( dependency , pomFile ) ; } catch ( DownloadFailedException ex ) { LOGGER . warn ( "Unable to download pom.xml for {} from Nexus repository; " + "this could result in undetected CPE/CVEs." , dependency . getFileName ( ) ) ; } finally { if ( pomFile != null && pomFile . exists ( ) && ! FileUtils . deleteQuietly ( pomFile ) ) { LOGGER . debug ( "Failed to delete temporary pom file {}" , pomFile . toString ( ) ) ; pomFile . deleteOnExit ( ) ; } } } } catch ( IllegalArgumentException iae ) { LOGGER . info ( "invalid sha-1 hash on {}" , dependency . getFileName ( ) ) ; } catch ( FileNotFoundException fnfe ) { LOGGER . debug ( "Artifact not found in repository '{}'" , dependency . getFileName ( ) ) ; LOGGER . debug ( fnfe . getMessage ( ) , fnfe ) ; } catch ( IOException ioe ) { LOGGER . debug ( "Could not connect to nexus repository" , ioe ) ; } }
Performs the analysis.

@param dependency the dependency to analyze
@param engine the engine
@throws AnalysisException when there's an exception during analysis