diff --git a/src/main/java/com/redhat/exhort/integration/backend/BackendUtils.java b/src/main/java/com/redhat/exhort/integration/backend/BackendUtils.java index 07ee844a..bedfa7b0 100644 --- a/src/main/java/com/redhat/exhort/integration/backend/BackendUtils.java +++ b/src/main/java/com/redhat/exhort/integration/backend/BackendUtils.java @@ -24,6 +24,8 @@ import org.apache.camel.Header; import org.apache.camel.http.base.HttpOperationFailedException; import org.jboss.resteasy.reactive.common.util.MediaTypeHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.redhat.exhort.api.ProviderStatus; import com.redhat.exhort.integration.Constants; @@ -38,6 +40,8 @@ @RegisterForReflection public class BackendUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(BackendUtils.class); + public String getResponseMediaType(@Header(Constants.ACCEPT_HEADER) String acceptHeader) { if (acceptHeader == null || acceptHeader.isBlank()) { return Constants.DEFAULT_ACCEPT_MEDIA_TYPE; @@ -61,10 +65,10 @@ public static void processResponseError(Exchange exchange, String provider) { Throwable cause = exception.getCause(); if (cause != null) { + LOGGER.warn("Unable to process request to: {}", provider, cause); if (cause instanceof HttpOperationFailedException) { HttpOperationFailedException httpException = (HttpOperationFailedException) cause; status.message(prettifyHttpError(httpException)).status(httpException.getStatusCode()); - } else { status .message(cause.getMessage()) @@ -74,6 +78,7 @@ public static void processResponseError(Exchange exchange, String provider) { status .message(exception.getMessage()) .status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + LOGGER.warn("Unable to process request to: {}", provider, exception); } exchange.getMessage().setBody(status); } @@ -108,6 +113,8 @@ private static String prettifyHttpError(HttpOperationFailedException httpExcepti return text + ": The provided credentials don't have the required permissions."; case 429: return text + ": The rate limit has been exceeded."; + case 500: + return text + ": " + httpException.getResponseBody(); default: return text; } diff --git a/src/main/java/com/redhat/exhort/integration/report/ReportTransformer.java b/src/main/java/com/redhat/exhort/integration/report/ReportTransformer.java index 2e8b3e9f..3ed8770e 100644 --- a/src/main/java/com/redhat/exhort/integration/report/ReportTransformer.java +++ b/src/main/java/com/redhat/exhort/integration/report/ReportTransformer.java @@ -68,17 +68,16 @@ public AnalysisReport transform(@Body GraphRequest request) { direct.forEach( d -> { - if (uniqueDeps.contains(d.ref())) { - return; - } - uniqueDeps.add(d.ref()); List issues = request.issues().get(d.ref().name()); if (issues == null) { issues = Collections.emptyList(); } List transitiveReport = getTransitiveDependenciesReport(d, request); - updateVulnerabilitySummary(issues, transitiveReport, counter, uniqueDeps); + if (!uniqueDeps.contains(d.ref())) { + uniqueDeps.add(d.ref()); + updateVulnerabilitySummary(issues, transitiveReport, counter, uniqueDeps); + } Optional highestVulnerability = issues.stream().max(Comparator.comparing(Issue::getCvssScore)); Optional highestTransitive =