use of com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder in project hub-alert by blackducksoftware.
the class BlackDuckMessageBomComponentDetailsCreator method retrieveComponentVulnerabilities.
private ComponentVulnerabilities retrieveComponentVulnerabilities(ProjectVersionComponentVersionView bomComponent) throws IntegrationException {
if (!vulnerabilityDetailsCreator.hasSecurityRisk(bomComponent)) {
return ComponentVulnerabilities.none();
}
if (StringUtils.isBlank(bomComponent.getComponentVersion())) {
return ComponentVulnerabilities.none();
}
List<HttpUrl> vulnerabilitiesUrls = createVulnerabilitiesLinks(bomComponent.getHref(), bomComponent.getOrigins());
List<BlackDuckProjectVersionComponentVulnerabilitiesView> allVulnerabilitiesViews = new ArrayList<>();
for (HttpUrl vulnerabilitiesUrl : vulnerabilitiesUrls) {
UrlMultipleResponses<BlackDuckProjectVersionComponentVulnerabilitiesView> urlMultipleResponses = new UrlMultipleResponses<>(vulnerabilitiesUrl, VULNERABILITIES_LINK.getResponseClass());
BlackDuckMultipleRequest<BlackDuckProjectVersionComponentVulnerabilitiesView> spec = new BlackDuckRequestBuilder().commonGet().addHeader(HttpHeaders.ACCEPT, VULNERABILITIES_MEDIA_TYPE).buildBlackDuckRequest(urlMultipleResponses);
allVulnerabilitiesViews.addAll(blackDuckApiClient.getAllResponses(spec));
}
return vulnerabilityDetailsCreator.toComponentVulnerabilities(allVulnerabilitiesViews);
}
use of com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method getProjectVersionNamesByHref.
@Override
public AlertPagedModel<String> getProjectVersionNamesByHref(Long providerConfigId, String projectHref, int pageNumber) {
Optional<ConfigurationModel> providerConfigOptional = configurationModelConfigurationAccessor.getConfigurationById(providerConfigId);
if (providerConfigOptional.isPresent()) {
try {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(providerConfigOptional.get());
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
ProjectView foundProject = blackDuckApiClient.getResponse(new HttpUrl(projectHref), ProjectView.class);
BlackDuckPageDefinition blackDuckPageDefinition = new BlackDuckPageDefinition(BlackDuckRequestBuilder.DEFAULT_LIMIT, pageNumber * BlackDuckRequestBuilder.DEFAULT_LIMIT);
BlackDuckMultipleRequest<ProjectVersionView> projectVersionSpec = new BlackDuckRequestBuilder().commonGet().setBlackDuckPageDefinition(blackDuckPageDefinition).buildBlackDuckRequest(foundProject.metaVersionsLink());
BlackDuckPageResponse<ProjectVersionView> pageResponse = blackDuckApiClient.getPageResponse(projectVersionSpec);
return new AlertPagedModel<>(pageResponse.getTotalCount(), pageNumber, BlackDuckRequestBuilder.DEFAULT_LIMIT, pageResponse.getItems()).transformContent(ProjectVersionView::getVersionName);
} catch (IntegrationException e) {
logger.errorAndDebug(createProjectNotFoundString(providerConfigId, e.getMessage()), e);
}
}
return AlertPagedModel.empty(pageNumber, BlackDuckRequestBuilder.DEFAULT_LIMIT);
}
use of com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder in project hub-alert by blackducksoftware.
the class BlackDuckProviderIssueHandler method performRequest.
private void performRequest(HttpUrl httpUrl, HttpMethod httpMethod, IssueRequest issueRequest) throws IntegrationException {
BlackDuckResponseRequest request = new BlackDuckRequestBuilder().method(httpMethod).bodyContent(new StringBodyContent(gson.toJson(issueRequest), BodyContentConverter.DEFAULT)).buildBlackDuckResponseRequest(httpUrl);
blackDuckApiClient.execute(request);
}
use of com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder in project hub-alert by blackducksoftware.
the class BlackDuckSSOConfigRetriever method retrieve.
public BlackDuckSSOConfigView retrieve() throws AlertException {
BlackDuckRequestBuilder requestBuilder = new BlackDuckRequestBuilder().acceptMimeType(SSO_CONFIGURATION_MIME_TYPE);
UrlSingleResponse<BlackDuckSSOConfigView> ssoConfigurationSingleResponse = apiDiscovery.metaSingleResponse(SSO_CONFIGURATION_PATH);
BlackDuckRequest<BlackDuckSSOConfigView, UrlSingleResponse<BlackDuckSSOConfigView>> ssoConfigurationRequest = new BlackDuckRequest<>(requestBuilder, ssoConfigurationSingleResponse);
try {
return blackDuckApiClient.getResponse(ssoConfigurationRequest);
} catch (IntegrationException e) {
String errorMessage = String.format("Unable to retrieve SSO configuration from Black Duck: %s", e.getMessage());
throw new AlertException(errorMessage, e);
}
}
use of com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method retrieveBlackDuckPageResponse.
private <T extends BlackDuckResponse> BlackDuckPageResponse<T> retrieveBlackDuckPageResponse(BlackDuckServicesFactory blackDuckServicesFactory, UrlMultipleResponses<T> urlMultipleResponses, int pageNumber, int pageSize, Predicate<T> searchFilter) throws IntegrationException {
BlackDuckResponsesTransformer blackDuckResponsesTransformer = blackDuckServicesFactory.getBlackDuckResponsesTransformer();
int offset = pageNumber * pageSize;
BlackDuckMultipleRequest<T> spec = new BlackDuckRequestBuilder().commonGet().setLimitAndOffset(pageSize, offset).buildBlackDuckRequest(urlMultipleResponses);
return blackDuckResponsesTransformer.getSomeMatchingResponses(spec, searchFilter, pageSize);
}
Aggregations