@@ -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,12 @@ 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+ if (lastException != null ) {
293+ setEnabled (false );
294+ LOGGER .warn ("Disabling the Central Analyzer due to repeated download failures; Central Search " +
295+ "may be down see https://status.maven.org/\n Note that this could result in both false " +
296+ "positives and false negatives" , lastException );
297+ }
290298 }
291299
292300 } catch (AnalysisException ex ) {
@@ -303,21 +311,25 @@ public void analyzeDependency(Dependency dependency, Engine engine) throws Analy
303311 }
304312 } catch (TooManyRequestsException tre ) {
305313 this .setEnabled (false );
306- final String message = "Connections to Central search refused. Analysis failed." ;
314+ final String message = "Connections to Central search refused. Analysis failed. Disabling Central analyzer - this " +
315+ "could lead to both false positives and false negatives." ;
307316 LOGGER .error (message , tre );
308317 throw new AnalysisException (message , tre );
309318 } catch (IllegalArgumentException iae ) {
310319 LOGGER .info ("invalid sha1-hash on {}" , dependency .getFileName ());
311320 } catch (FileNotFoundException fnfe ) {
312321 LOGGER .debug ("Artifact not found in repository: '{}" , dependency .getFileName ());
313322 } catch (ForbiddenException e ) {
323+ this .setEnabled (false );
314324 final String message = "Connection to Central search refused. This is most likely not a problem with " +
315325 "Dependency-Check itself and is related to network connectivity. Please check " +
316326 "https://central.sonatype.org/faq/403-error-central/." ;
317327 LOGGER .error (message );
318328 throw new AnalysisException (message , e );
319329 } catch (IOException ioe ) {
320- final String message = "Could not connect to Central search. Analysis failed." ;
330+ this .setEnabled (false );
331+ final String message = "Could not connect to Central search. Analysis failed; disabling Central analyzer - this " +
332+ "could lead to both false positives and false negatives." ;
321333 LOGGER .error (message , ioe );
322334 throw new AnalysisException (message , ioe );
323335 }
0 commit comments