use of com.blackducksoftware.integration.fortify.hub.model.Recommendation in project hub-fortify-ssc-integration-service by blackducksoftware.
the class VulnerabilityUtil method transformMapping.
/**
* It will convert Hub Component view to CSV Vulnerability view
*
* @param vulnerabilityComponentViews
* @param hubProjectName
* @param hubProjectVersion
* @return List<Vulnerability>
*/
public static List<Vulnerability> transformMapping(final HubServices hubServices, final List<VulnerableComponentView> vulnerabilityComponentViews, final String hubProjectName, final String hubProjectVersion, final Date maxBomUpdatedDate, final PropertyConstants propertyConstants) throws IntegrationException {
final List<Vulnerability> vulnerabilities = new ArrayList<>();
final Map<String, Recommendation> recommendations = new HashMap<>();
for (final VulnerableComponentView vulnerableComponentView : vulnerabilityComponentViews) {
final String remediatingUrl = vulnerableComponentView.componentVersion + "/remediating";
Recommendation recommendation = null;
if (recommendations.containsKey(remediatingUrl)) {
recommendation = recommendations.get(remediatingUrl);
} else {
recommendation = hubServices.getComponentVersionRecommendations(remediatingUrl);
recommendations.put(remediatingUrl, recommendation);
}
final String[] componentVersionLinkArr = vulnerableComponentView.componentVersion.split("/");
final Vulnerability vulnerability = new Vulnerability(String.valueOf(hubProjectName), String.valueOf(hubProjectVersion), String.valueOf(componentVersionLinkArr[5]), String.valueOf(componentVersionLinkArr[7]), "", String.valueOf(vulnerableComponentView.componentName), String.valueOf(vulnerableComponentView.componentVersionName), String.valueOf(vulnerableComponentView.componentVersionOriginName), String.valueOf(vulnerableComponentView.componentVersionOriginId), String.valueOf(vulnerableComponentView.componentVersionName), String.valueOf(vulnerableComponentView.vulnerabilityWithRemediation.vulnerabilityName), String.valueOf(vulnerableComponentView.vulnerabilityWithRemediation.description.replaceAll("\\r\\n", "")), vulnerableComponentView.vulnerabilityWithRemediation.vulnerabilityPublishedDate, vulnerableComponentView.vulnerabilityWithRemediation.vulnerabilityUpdatedDate, vulnerableComponentView.vulnerabilityWithRemediation.baseScore, vulnerableComponentView.vulnerabilityWithRemediation.exploitabilitySubscore, vulnerableComponentView.vulnerabilityWithRemediation.impactSubscore, String.valueOf(vulnerableComponentView.vulnerabilityWithRemediation.source.toString()), propertyConstants.getHubServerUrl() + "/api/vulnerabilities/" + String.valueOf(vulnerableComponentView.vulnerabilityWithRemediation.vulnerabilityName), String.valueOf(vulnerableComponentView.vulnerabilityWithRemediation.remediationStatus.toString()), vulnerableComponentView.vulnerabilityWithRemediation.remediationTargetAt, vulnerableComponentView.vulnerabilityWithRemediation.remediationActualAt, String.valueOf(""), VulnerabilityWithRemediationSourceType.NVD.equals(vulnerableComponentView.vulnerabilityWithRemediation.source) ? "http://web.nvd.nist.gov/view/vuln/detail?vulnId=" + vulnerableComponentView.vulnerabilityWithRemediation.vulnerabilityName : "", vulnerableComponentView.vulnerabilityWithRemediation.severity != null ? String.valueOf(vulnerableComponentView.vulnerabilityWithRemediation.severity.toString()) : "CRITICAL", recommendation != null && recommendation.getNoVulnerabilities() != null ? recommendation.getNoVulnerabilities().getName() : null, recommendation != null && recommendation.getNoVulnerabilities() != null ? recommendation.getNoVulnerabilities().getReleasedOn() : null, recommendation != null && recommendation.getLatestAfterCurrent() != null ? recommendation.getLatestAfterCurrent().getName() : null, recommendation != null && recommendation.getLatestAfterCurrent() != null ? recommendation.getLatestAfterCurrent().getReleasedOn() : null, maxBomUpdatedDate);
vulnerabilities.add(vulnerability);
}
return vulnerabilities;
}
use of com.blackducksoftware.integration.fortify.hub.model.Recommendation in project hub-fortify-ssc-integration-service by blackducksoftware.
the class HubServices method getComponentVersionRecommendations.
/**
* Get the Black Duck component version recommendations for the given component version
*
* @param componentVersionRemediatingUrl
* @return
* @throws IntegrationException
*/
public Recommendation getComponentVersionRecommendations(final String componentVersionRemediatingUrl) throws IntegrationException {
logger.debug("Getting Black Duck component version remediating");
Recommendation recommendation = null;
if (componentVersionRemediatingUrl != null) {
final HubService hubResponseService = hubServicesFactory.createHubService();
try {
recommendation = hubResponseService.getResponse(componentVersionRemediatingUrl, Recommendation.class);
} catch (final IntegrationException e) {
if (!e.getMessage().contains("Error: 404 : 404")) {
throw new IntegrationException(e);
}
}
}
return recommendation;
}
Aggregations