Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing direct dependency #147

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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