use of com.blackducksoftware.integration.hub.api.generated.view.VulnerableComponentView in project hub-fortify-ssc-integration-service by blackducksoftware.
the class BlackDuckFortifyPushThread method mergeVulnerabilities.
/**
* Iterate the hub project versions and find the vulnerabilities for Hub project version and transform the
* vulnerability component view to CSV vulnerability view and merge all the vulnerabilities
*
* @param hubProjectVersions
* @param projectVersionItems
* @return
* @throws IntegrationException
* @throws IllegalArgumentException
*/
private List<Vulnerability> mergeVulnerabilities(final List<HubProjectVersion> hubProjectVersions, final List<ProjectVersionView> projectVersionItems) throws IllegalArgumentException, IntegrationException {
int index = 0;
List<Vulnerability> mergedVulnerabilities = new ArrayList<>();
for (HubProjectVersion hubProjectVersion : hubProjectVersions) {
// Get the Vulnerability information
final List<VulnerableComponentView> vulnerableComponentViews = hubServices.getVulnerabilityComponentViews(projectVersionItems.get(index));
index++;
// Convert the Hub Vulnerability component view to CSV Vulnerability object
List<Vulnerability> vulnerabilities = VulnerabilityUtil.transformMapping(vulnerableComponentViews, hubProjectVersion.getHubProject(), hubProjectVersion.getHubProjectVersion(), maxBomUpdatedDate, propertyConstants);
// Add the vulnerabilities to the main list
mergedVulnerabilities.addAll(vulnerabilities);
}
return mergedVulnerabilities;
}
use of com.blackducksoftware.integration.hub.api.generated.view.VulnerableComponentView in project hub-fortify-ssc-integration-service by blackducksoftware.
the class CSVUtilsTest method testWriteToCSV.
@Test
public void testWriteToCSV() {
System.out.println("Executing testWriteToCSV");
ProjectVersionView projectVersionItem = null;
List<VulnerableComponentView> vulnerableComponentViews;
try {
projectVersionItem = hubServices.getProjectVersion(PROJECT_NAME, VERSION_NAME);
vulnerableComponentViews = hubServices.getVulnerabilityComponentViews(projectVersionItem);
bomUpdatedValueAt = hubServices.getBomLastUpdatedAt(projectVersionItem);
} catch (final IllegalArgumentException e1) {
e1.printStackTrace();
throw new RuntimeException(e1);
} catch (final IntegrationException e1) {
e1.printStackTrace();
throw new RuntimeException(e1);
}
System.out.println("vulnerableComponentViews size::" + vulnerableComponentViews.size());
assertNotNull(vulnerableComponentViews);
assertNotNull(bomUpdatedValueAt);
final List<Vulnerability> vulnerabilities = VulnerabilityUtil.transformMapping(vulnerableComponentViews, PROJECT_NAME, VERSION_NAME, bomUpdatedValueAt, propertyConstants);
System.out.println("vulnerabilities size::" + vulnerabilities.size());
assertEquals(vulnerableComponentViews.size(), vulnerabilities.size());
try {
// csvUtils.writeToCSV(vulnerabilities, PROJECT_NAME + "_" + VERSION_NAME + new Date(), ',');
CSVUtils.writeToCSV(vulnerabilities, "sample.csv", ',');
} catch (final Exception e) {
e.printStackTrace();
}
}
use of com.blackducksoftware.integration.hub.api.generated.view.VulnerableComponentView in project hub-fortify-ssc-integration-service by blackducksoftware.
the class HubServicesTest method getVulnerability.
@Test
public void getVulnerability() throws Exception {
System.out.println("Executing getVulnerability");
ProjectVersionView projectVersionItem = null;
try {
projectVersionItem = hubServices.getProjectVersion(PROJECT_NAME, VERSION_NAME);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IntegrationException e) {
e.printStackTrace();
}
List<VulnerableComponentView> vulnerableComponentViews = hubServices.getVulnerabilityComponentViews(projectVersionItem);
System.out.println("vulnerableComponentViews size::" + vulnerableComponentViews.size() + ", vulnerableComponentViews::" + vulnerableComponentViews);
assertNotNull(vulnerableComponentViews);
}
Aggregations