Skip to content

Commit bf0a057

Browse files
authored
Merge pull request #1491 from blackducksoftware/dev/devm/IDETECT-3456
Exclude Ignored Components from Risk Reports
2 parents edad8c4 + 27fa175 commit bf0a057

File tree

1 file changed

+23
-15
lines changed
  • src/main/java/com/blackduck/integration/detect/workflow/blackduck/report/service

1 file changed

+23
-15
lines changed

src/main/java/com/blackduck/integration/detect/workflow/blackduck/report/service/ReportService.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,16 @@ public ReportData getRiskReportData(ProjectView project, ProjectVersionView vers
129129
HttpUrl originalVersionUrl = version.getHref();
130130
boolean policyFailure = false;
131131
for (ProjectVersionComponentVersionView projectVersionComponentView : bomEntries) {
132+
if(projectVersionComponentView.getIgnored()) {
133+
continue;
134+
}
132135
String policyStatus = projectVersionComponentView.getApprovalStatus().toString();
133136
if (StringUtils.isBlank(policyStatus)) {
134-
HttpUrl componentPolicyStatusURL;
135-
if (!StringUtils.isBlank(projectVersionComponentView.getComponentVersion())) {
136-
componentPolicyStatusURL = getComponentPolicyURL(originalVersionUrl, projectVersionComponentView.getComponentVersion());
137-
} else {
138-
componentPolicyStatusURL = getComponentPolicyURL(originalVersionUrl, projectVersionComponentView.getComponent());
139-
}
140-
if (!policyFailure) {
141-
// FIXME if we could check if Black Duck has the policy module we could remove a lot of the mess
142-
try {
143-
PolicyStatusView bomPolicyStatus = blackDuckApiClient.getResponse(componentPolicyStatusURL, PolicyStatusView.class);
144-
policyStatus = bomPolicyStatus.getApprovalStatus().toString();
145-
} catch (IntegrationException e) {
146-
policyFailure = true;
147-
logger.debug("Could not get the component policy status, the Black Duck policy module is not enabled");
148-
}
137+
try {
138+
policyStatus = checkPolicyStatusIfBlank(projectVersionComponentView, policyStatus, originalVersionUrl, policyFailure);
139+
} catch (IntegrationException e) {
140+
policyFailure = true;
141+
logger.debug("Could not get the component policy status, the Black Duck policy module is not enabled");
149142
}
150143
}
151144

@@ -161,6 +154,21 @@ public ReportData getRiskReportData(ProjectView project, ProjectVersionView vers
161154
return reportData;
162155
}
163156

157+
private String checkPolicyStatusIfBlank(ProjectVersionComponentVersionView projectVersionComponentView, String policyStatus, HttpUrl originalVersionUrl, boolean policyFailure) throws IntegrationException {
158+
HttpUrl componentPolicyStatusURL;
159+
if (!StringUtils.isBlank(projectVersionComponentView.getComponentVersion())) {
160+
componentPolicyStatusURL = getComponentPolicyURL(originalVersionUrl, projectVersionComponentView.getComponentVersion());
161+
} else {
162+
componentPolicyStatusURL = getComponentPolicyURL(originalVersionUrl, projectVersionComponentView.getComponent());
163+
}
164+
if (!policyFailure) {
165+
// FIXME if we could check if Black Duck has the policy module we could remove a lot of the mess
166+
PolicyStatusView bomPolicyStatus = blackDuckApiClient.getResponse(componentPolicyStatusURL, PolicyStatusView.class);
167+
policyStatus = bomPolicyStatus.getApprovalStatus().toString();
168+
}
169+
return policyStatus;
170+
}
171+
164172
private LocalDateTime getDateTimeOfLatestScanForProjectVersion(ProjectVersionView projectVersion, String projectName) throws IntegrationException {
165173
List<CodeLocationView> codeLocations = blackDuckApiClient.getAllResponses(projectVersion.metaCodelocationsLink());
166174
if (codeLocations.isEmpty()) {

0 commit comments

Comments
 (0)