Skip to content

Commit

Permalink
Merge pull request #147 from ruromero/missing-dep
Browse files Browse the repository at this point in the history
fix: missing direct dependency
  • Loading branch information
ruromero authored Sep 8, 2023
2 parents 952f735 + 017f414 commit 88acfbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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())
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,16 @@ public AnalysisReport transform(@Body GraphRequest request) {

direct.forEach(
d -> {
if (uniqueDeps.contains(d.ref())) {
return;
}
uniqueDeps.add(d.ref());
List<Issue> issues = request.issues().get(d.ref().name());
if (issues == null) {
issues = Collections.emptyList();
}
List<TransitiveDependencyReport> transitiveReport =
getTransitiveDependenciesReport(d, request);
updateVulnerabilitySummary(issues, transitiveReport, counter, uniqueDeps);
if (!uniqueDeps.contains(d.ref())) {
uniqueDeps.add(d.ref());
updateVulnerabilitySummary(issues, transitiveReport, counter, uniqueDeps);
}
Optional<Issue> highestVulnerability =
issues.stream().max(Comparator.comparing(Issue::getCvssScore));
Optional<Issue> highestTransitive =
Expand Down

0 comments on commit 88acfbc

Please sign in to comment.