@@ -247,6 +247,7 @@ public void analyzeDependency(Dependency dependency, Engine engine) throws Analy
247247 long sleepingTimeBetweenRetriesInMillis = BASE_RETRY_WAIT ;
248248 boolean success = false ;
249249 Model model = null ;
250+ DownloadFailedException lastException = null ;
250251 if (cache != null ) {
251252 model = cache .get (ma .getPomUrl ());
252253 }
@@ -261,6 +262,7 @@ public void analyzeDependency(Dependency dependency, Engine engine) throws Analy
261262 Downloader .getInstance ().fetchFile (new URL (ma .getPomUrl ()), pomFile );
262263 success = true ;
263264 } catch (DownloadFailedException ex ) {
265+ lastException = ex ;
264266 try {
265267 Thread .sleep (sleepingTimeBetweenRetriesInMillis );
266268 } catch (InterruptedException ex1 ) {
@@ -287,6 +289,10 @@ public void analyzeDependency(Dependency dependency, Engine engine) throws Analy
287289 } else {
288290 LOGGER .warn ("Unable to download pom.xml for {} from Central; "
289291 + "this could result in undetected CPE/CVEs." , dependency .getFileName ());
292+ setEnabled (false );
293+ LOGGER .warn ("Disabling the Central Analyzer due to repeated download failures; Central Search "
294+ + "may be down see https://status.maven.org/\n Note that this could result in both false "
295+ + "positives and false negatives" , lastException );
290296 }
291297
292298 } catch (AnalysisException ex ) {
@@ -303,21 +309,25 @@ public void analyzeDependency(Dependency dependency, Engine engine) throws Analy
303309 }
304310 } catch (TooManyRequestsException tre ) {
305311 this .setEnabled (false );
306- final String message = "Connections to Central search refused. Analysis failed." ;
312+ final String message = "Connections to Central search refused. Analysis failed. Disabling Central analyzer - this " +
313+ "could lead to both false positives and false negatives." ;
307314 LOGGER .error (message , tre );
308315 throw new AnalysisException (message , tre );
309316 } catch (IllegalArgumentException iae ) {
310317 LOGGER .info ("invalid sha1-hash on {}" , dependency .getFileName ());
311318 } catch (FileNotFoundException fnfe ) {
312319 LOGGER .debug ("Artifact not found in repository: '{}" , dependency .getFileName ());
313320 } catch (ForbiddenException e ) {
321+ this .setEnabled (false );
314322 final String message = "Connection to Central search refused. This is most likely not a problem with " +
315323 "Dependency-Check itself and is related to network connectivity. Please check " +
316324 "https://central.sonatype.org/faq/403-error-central/." ;
317325 LOGGER .error (message );
318326 throw new AnalysisException (message , e );
319327 } catch (IOException ioe ) {
320- final String message = "Could not connect to Central search. Analysis failed." ;
328+ this .setEnabled (false );
329+ final String message = "Could not connect to Central search. Analysis failed; disabling Central analyzer - this " +
330+ "could lead to both false positives and false negatives." ;
321331 LOGGER .error (message , ioe );
322332 throw new AnalysisException (message , ioe );
323333 }
0 commit comments