Skip to content

Commit 42b495d

Browse files
committed
conflict
2 parents dede8b6 + 08ecbf5 commit 42b495d

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

pom.xml

+12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
<artifactId>api-audit</artifactId>
55
<packaging>jar</packaging>
66
<name>${project.groupId}:${project.artifactId}</name>
7+
<<<<<<< HEAD
78
<version>3.7.31-SNAPSHOT</version>
9+
=======
10+
<version>3.7.33-SNAPSHOT</version>
11+
>>>>>>> 08ecbf57c4b88a7120a1122ae7e42c2bfe4def05
812
<description>Hygieia Audit Rest API Layer</description>
913
<url>https://github.com/Hygieia/${repository.name}</url>
1014

@@ -42,9 +46,17 @@
4246
</parent>
4347

4448
<properties>
49+
<<<<<<< HEAD
4550
<repository.name>hygieia-auditapi-ace</repository.name>
4651
<com.capitalone.dashboard.core.version>04.06.03.54</com.capitalone.dashboard.core.version>
4752
<spring-security.version>5.5.7</spring-security.version>
53+
=======
54+
<repository.name>api-audit</repository.name>
55+
56+
<!-- Dependencies -->
57+
<com.capitalone.dashboard.core.version>3.15.45</com.capitalone.dashboard.core.version>
58+
<spring-security.version>4.2.18.RELEASE</spring-security.version>
59+
>>>>>>> 08ecbf57c4b88a7120a1122ae7e42c2bfe4def05
4860
<spring.cloud.version>1.3.1.RELEASE</spring.cloud.version>
4961
<tomcat.version>9.0.65</tomcat.version>
5062
<commons-beanutils.version>1.9.4</commons-beanutils.version>

src/main/java/com/capitalone/dashboard/evaluator/InfrastructureEvaluator.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,22 @@ private InfrastructureAuditResponse getInfrastructureScanResponse(CollectorItem
7373

7474

7575
List<InfrastructureScan> infrastructureScans = infrastructureScanRepository.findByCollectorItemIdAndTimestampIsBetweenOrderByTimestampDesc(collectorItem.getId(), beginDate - 1, endDate + 1);
76+
7677
List<InfrastructureScan> filteredForBAP = StringUtils.isEmpty(businessComponent) ? Collections.EMPTY_LIST :
77-
infrastructureScans.stream().filter(infrastructureScan -> infrastructureScan.getBusinessApplication().equalsIgnoreCase(businessComponent)).collect(Collectors.toList());
78+
infrastructureScans.stream().filter(infrastructureScan ->
79+
businessComponent.equalsIgnoreCase(infrastructureScan.getBusinessApplication())).collect(Collectors.toList()
80+
);
7881

7982
if (CollectionUtils.isNotEmpty(filteredForBAP)) {
8083
List<InfrastructureScan> sortedDistinctForBAP = getSortedAndDistinctByInstanceId(filteredForBAP);
8184
setInfraAudit(infrastructureAuditResponse, sortedDistinctForBAP, InfrastructureAuditStatus.INFRA_SCAN_BUSS_COMP_CRITICAL, InfrastructureAuditStatus.INFRA_SCAN_BUSS_COMP_HIGH, InfrastructureAuditStatus.INFRA_SCAN_BUSS_COMP_OK);
8285
infrastructureAuditResponse.setInfrastructureScans(sortedDistinctForBAP);
8386
} else {
8487
infrastructureAuditResponse.addAuditStatus(InfrastructureAuditStatus.INFRA_SEC_SCAN_BUSS_COMP_NOT_FOUND);
88+
8589
List<InfrastructureScan> filteredForASV = StringUtils.isEmpty(businessService) ? Collections.EMPTY_LIST :
86-
infrastructureScans.stream().filter(infrastructureScan -> infrastructureScan.getBusinessService().equalsIgnoreCase(businessService)).collect(Collectors.toList());
90+
infrastructureScans.stream().filter(infrastructureScan -> businessService.equalsIgnoreCase(infrastructureScan.getBusinessService())).collect(Collectors.toList());
91+
8792
if (CollectionUtils.isNotEmpty(filteredForASV)) {
8893
List<InfrastructureScan> sortedDistinctForASV = getSortedAndDistinctByInstanceId(filteredForASV);
8994
setInfraAudit(infrastructureAuditResponse, sortedDistinctForASV, InfrastructureAuditStatus.INFRA_SEC_SCAN_BUSS_APP_CRITICAL, InfrastructureAuditStatus.INFRA_SEC_SCAN_BUSS_APP_HIGH, InfrastructureAuditStatus.INFRA_SEC_SCAN_BUSS_APP_OK);

src/main/java/com/capitalone/dashboard/service/DashboardAuditServiceImpl.java

+44-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.google.common.collect.Sets;
2828
import org.apache.commons.collections.CollectionUtils;
2929
import org.apache.commons.collections4.IterableUtils;
30+
import org.apache.commons.lang3.ObjectUtils;
3031
import org.apache.commons.lang3.StringUtils;
3132
import org.json.simple.JSONObject;
3233
import org.springframework.beans.factory.annotation.Autowired;
@@ -296,10 +297,51 @@ public JSONObject getAuditReport(DashboardAuditRequest dashboardAuditRequest) {
296297

297298
AuditReport auditReport = auditReportRepository.findTop1ByBusinessApplicationAndBusinessServiceAndAuditTypeAndIdentifierNameAndIdentifierVersionAndIdentifierUrlOrderByTimestampDesc(
298299
businessApplication, businessService, auditType, identifierName, identifierVersion, identifierUrl);
299-
if (Objects.nonNull(auditReport) && Objects.nonNull(auditReport.getAuditResponse())) {
300+
if (Objects.nonNull(auditReport) && !ObjectUtils.isEmpty(auditReport.getAuditResponse())) {
300301
return (JSONObject) auditReport.getAuditResponse();
302+
}else{
303+
Cmdb busServItem = cmdbRepository.findByConfigurationItemAndItemType(businessService, "app");
304+
Cmdb busAppItem = cmdbRepository.findByConfigurationItemAndItemType(businessApplication, "component");
305+
306+
if(busServItem == null){
307+
JSONObject invalidBAResponse = createLookupResponseWhenEmpty(DashboardAuditStatus.DASHBOARD_INVALID_BA, businessApplication, businessService);
308+
return invalidBAResponse;
309+
}else if(busAppItem == null){
310+
JSONObject invalidComponentResponse = createLookupResponseWhenEmpty(DashboardAuditStatus.DASHBOARD_INVALID_COMPONENT, businessApplication, businessService);
311+
return invalidComponentResponse;
312+
}else if(!componentInfoMatch(busServItem, businessApplication)){
313+
JSONObject componentBAMismatchResponse = createLookupResponseWhenEmpty(DashboardAuditStatus.DASHBOARD_COMPONENT_BA_MISMATCH, businessApplication, businessService);
314+
return componentBAMismatchResponse;
315+
}else{
316+
JSONObject noDataResponse = createLookupResponseWhenEmpty(DashboardAuditStatus.DASHBOARD_AUDIT_NO_DATA, businessApplication, businessService);
317+
return noDataResponse;
318+
}
319+
}
320+
321+
322+
}
323+
324+
private JSONObject createLookupResponseWhenEmpty(DashboardAuditStatus dashboardAuditStatus, String businessApplication, String businessService){
325+
JSONObject auditResponse = new JSONObject();
326+
auditResponse.put("businessApplication", businessApplication);
327+
auditResponse.put("businessService", businessService);
328+
auditResponse.put("auditStatuses", Collections.singleton(dashboardAuditStatus));
329+
auditResponse.put("lastUpdated", 0);
330+
auditResponse.put("auditEntity", new JSONObject());
331+
auditResponse.put("review", new JSONObject());
332+
return auditResponse;
333+
}
334+
335+
private boolean componentInfoMatch(Cmdb businessApplication, String businessService){
336+
if(businessApplication.getComponents() == null){
337+
return false;
301338
}
302-
return new JSONObject();
339+
340+
if(businessApplication.getComponents().contains(businessService)){
341+
return true;
342+
}
343+
344+
return false;
303345
}
304346

305347
private void validateParameters(String dashboardTitle, DashboardType dashboardType, String businessService, String businessApp, long beginDate, long endDate) throws AuditException{

0 commit comments

Comments
 (0)