mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-22 04:18:20 +00:00
These changes highlight matched and unmatched
This commit is contained in:
parent
d907c910c7
commit
29ef08e5e9
@ -21,6 +21,7 @@ import java.util.UUID;
|
||||
public class ComponentAttributeResult extends ArchivableEntity {
|
||||
|
||||
private UUID componentId;
|
||||
private UUID deviceComponentId;
|
||||
@Setter
|
||||
private String provisionSessionId;
|
||||
private String expectedValue;
|
||||
@ -29,13 +30,16 @@ public class ComponentAttributeResult extends ArchivableEntity {
|
||||
/**
|
||||
* Default constructor that populates the expected and actual values.
|
||||
* @param componentId id associated with component result
|
||||
* @param deviceComponentId id associated with the device component
|
||||
* @param expectedValue platform certificate value
|
||||
* @param actualValue paccor value from the device
|
||||
*/
|
||||
public ComponentAttributeResult(final UUID componentId,
|
||||
final UUID deviceComponentId,
|
||||
final String expectedValue,
|
||||
final String actualValue) {
|
||||
this.componentId = componentId;
|
||||
this.deviceComponentId = deviceComponentId;
|
||||
this.expectedValue = expectedValue;
|
||||
this.actualValue = actualValue;
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ public class ComponentInfo extends ArchivableEntity {
|
||||
@XmlElement
|
||||
@Column
|
||||
private String componentClass;
|
||||
@Column
|
||||
private String componentClassStr;
|
||||
|
||||
/**
|
||||
* Base constructor for children.
|
||||
|
@ -337,6 +337,7 @@ public class CertificateAttributeScvValidator extends SupplyChainCredentialValid
|
||||
remainingComponentResults.add(componentResult);
|
||||
}
|
||||
}
|
||||
List<UUID> failedComponents = new ArrayList<>();
|
||||
if (!remainingComponentResults.isEmpty()) {
|
||||
// continue down the options, move to a different method.
|
||||
// create component class mapping to component info
|
||||
@ -369,23 +370,23 @@ public class CertificateAttributeScvValidator extends SupplyChainCredentialValid
|
||||
componentAttributeResult.setProvisionSessionId(provisionSessionId);
|
||||
componentAttributeRepository.save(componentAttributeResult);
|
||||
fieldValidation &= componentAttributeResult.checkMatchedStatus();
|
||||
if (!componentAttributeResult.checkMatchedStatus()) {
|
||||
numOfAttributes++;
|
||||
failedComponents.add(componentAttributeResult.getComponentId());
|
||||
}
|
||||
}
|
||||
numOfAttributes = attributeResults.size();
|
||||
}
|
||||
|
||||
StringBuilder additionalInfo = new StringBuilder();
|
||||
if (!remainingComponentResults.isEmpty()) {
|
||||
resultMessage.append(String.format("There are %d components not matched%n",
|
||||
remainingComponentResults.size()));
|
||||
resultMessage.append(String.format("\twith %d total attributes mismatched.",
|
||||
numOfAttributes));
|
||||
}
|
||||
|
||||
passesValidation &= fieldValidation;
|
||||
|
||||
if (passesValidation) {
|
||||
return new AppraisalStatus(PASS, PLATFORM_ATTRIBUTES_VALID);
|
||||
} else {
|
||||
resultMessage.append(String.format("There are %d components not matched%n",
|
||||
failedComponents.size()));
|
||||
resultMessage.append(String.format("\twith %d total attributes mismatched.",
|
||||
numOfAttributes));
|
||||
return new AppraisalStatus(FAIL, resultMessage.toString(), additionalInfo.toString());
|
||||
}
|
||||
}
|
||||
@ -402,25 +403,17 @@ public class CertificateAttributeScvValidator extends SupplyChainCredentialValid
|
||||
final ComponentResult componentResult) {
|
||||
// there are instances of components with the same class (ie hard disks, memory)
|
||||
List<ComponentAttributeResult> attributeResults = new ArrayList<>();
|
||||
if (!componentInfo.getComponentManufacturer().equals(componentResult.getManufacturer())) {
|
||||
attributeResults.add(new ComponentAttributeResult(componentResult.getId(),
|
||||
componentResult.getManufacturer(), componentInfo.getComponentManufacturer()));
|
||||
}
|
||||
attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(),
|
||||
componentResult.getManufacturer(), componentInfo.getComponentManufacturer()));
|
||||
|
||||
if (!componentInfo.getComponentModel().equals(componentResult.getModel())) {
|
||||
attributeResults.add(new ComponentAttributeResult(componentResult.getId(),
|
||||
componentResult.getModel(), componentInfo.getComponentModel()));
|
||||
}
|
||||
attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(),
|
||||
componentResult.getModel(), componentInfo.getComponentModel()));
|
||||
|
||||
if (!componentInfo.getComponentSerial().equals(componentResult.getSerialNumber())) {
|
||||
attributeResults.add(new ComponentAttributeResult(componentResult.getId(),
|
||||
componentResult.getSerialNumber(), componentInfo.getComponentSerial()));
|
||||
}
|
||||
attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(),
|
||||
componentResult.getSerialNumber(), componentInfo.getComponentSerial()));
|
||||
|
||||
if (!componentInfo.getComponentRevision().equals(componentResult.getRevisionNumber())) {
|
||||
attributeResults.add(new ComponentAttributeResult(componentResult.getId(),
|
||||
componentResult.getRevisionNumber(), componentInfo.getComponentRevision()));
|
||||
}
|
||||
attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(),
|
||||
componentResult.getRevisionNumber(), componentInfo.getComponentRevision()));
|
||||
|
||||
return attributeResults;
|
||||
}
|
||||
|
@ -7,12 +7,14 @@ import hirs.attestationca.persist.entity.manager.PlatformCertificateRepository;
|
||||
import hirs.attestationca.persist.entity.userdefined.certificate.ComponentResult;
|
||||
import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential;
|
||||
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentAttributeResult;
|
||||
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentClass;
|
||||
import hirs.attestationca.persist.entity.userdefined.info.ComponentInfo;
|
||||
import hirs.attestationca.persist.util.PciIds;
|
||||
import hirs.attestationca.portal.page.Page;
|
||||
import hirs.attestationca.portal.page.PageController;
|
||||
import hirs.attestationca.portal.page.PageMessages;
|
||||
import hirs.attestationca.portal.page.params.CertificateDetailsPageParams;
|
||||
import hirs.utils.xjc.Link;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@ -24,6 +26,7 @@ import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -143,25 +146,52 @@ public class ComponentComparisonPageController extends PageController<Certificat
|
||||
+ componentResults.get(0).getBoardSerialNumber());
|
||||
return data;
|
||||
}
|
||||
List<UUID> tempIdList = new ArrayList<>();
|
||||
attributeResults.stream().forEach((dbObject) -> {
|
||||
if (!tempIdList.contains(dbObject.getComponentId())) {
|
||||
tempIdList.add(dbObject.getComponentId());
|
||||
|
||||
List<ComponentResult> matchedResults = new LinkedList<>();
|
||||
List<ComponentInfo> matchedDeviceComps = new LinkedList<>();
|
||||
List<ComponentResult> mismatchedResults = new LinkedList<>();
|
||||
List<ComponentInfo> mismatchedDeviceComps = new LinkedList<>();
|
||||
for(ComponentAttributeResult dbObject : attributeResults) {
|
||||
if (dbObject.checkMatchedStatus()) {
|
||||
matchedResults.add(componentResultRepository.getReferenceById(dbObject.getComponentId()));
|
||||
matchedDeviceComps.add(componentInfoRepository.getReferenceById(dbObject.getDeviceComponentId()));
|
||||
} else {
|
||||
mismatchedResults.add(componentResultRepository.getReferenceById(dbObject.getComponentId()));
|
||||
mismatchedDeviceComps.add(componentInfoRepository.getReferenceById(dbObject.getDeviceComponentId()));
|
||||
}
|
||||
});
|
||||
componentResults = componentResultRepository
|
||||
.findByBoardSerialNumberOrderByComponentClassValueAsc(
|
||||
platformCredential.getPlatformSerial());
|
||||
List<ComponentInfo> componentInfos = componentInfoRepository
|
||||
.findByDeviceNameOrderByComponentClassAsc(deviceName);
|
||||
if (PciIds.DB.isReady()) {
|
||||
componentResults = PciIds.translateResults(componentResults);
|
||||
componentInfos = PciIds.translateDeviceComponentInfo(componentInfos);
|
||||
}
|
||||
|
||||
data.put("componentResults", componentResults);
|
||||
data.put("componentInfos", componentInfos);
|
||||
data.put("totalSize", Math.max(componentResults.size(), componentInfos.size()));
|
||||
// componentResults.clear();
|
||||
// List<ComponentInfo> componentInfos = componentInfoRepository
|
||||
// .findByDeviceNameOrderByComponentClassAsc(deviceName);
|
||||
// // find the ones that aren't matched or unmatched
|
||||
// for (ComponentResult dbResult : componentResultRepository
|
||||
// .findByBoardSerialNumberOrderByComponentClassValueAsc(
|
||||
// platformCredential.getPlatformSerial())) {
|
||||
// for (ComponentResult matched : matchedResults) {
|
||||
// if (dbResult.getId().equals(matched.getId())) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (PciIds.DB.isReady()) {
|
||||
// componentResults = PciIds.translateResults(componentResults);
|
||||
// componentInfos = PciIds.translateDeviceComponentInfo(componentInfos);
|
||||
matchedResults = PciIds.translateResults(matchedResults);
|
||||
matchedDeviceComps = PciIds.translateDeviceComponentInfo(matchedDeviceComps);
|
||||
mismatchedResults = PciIds.translateResults(mismatchedResults);
|
||||
mismatchedDeviceComps = PciIds.translateDeviceComponentInfo(mismatchedDeviceComps);
|
||||
}
|
||||
|
||||
matchedDeviceComps = translateComponentClass(matchedDeviceComps);
|
||||
mismatchedDeviceComps = translateComponentClass(mismatchedDeviceComps);
|
||||
|
||||
data.put("componentResults", matchedResults);
|
||||
data.put("componentInfos", matchedDeviceComps);
|
||||
data.put("misMatchedComponentResults", mismatchedResults);
|
||||
data.put("misMatchedComponentInfos", mismatchedDeviceComps);
|
||||
// data.put("notFoundResults", );
|
||||
// data.put("notFoundComponentInfs", );
|
||||
} else {
|
||||
String notFoundMessage = "No components attribute comparison found "
|
||||
+ "with ID: " + sessionId;
|
||||
@ -169,6 +199,20 @@ public class ComponentComparisonPageController extends PageController<Certificat
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private static List<ComponentInfo> translateComponentClass(final List<ComponentInfo> componentInfos) {
|
||||
List<ComponentInfo> tempList = new ArrayList<>();
|
||||
ComponentInfo componentInfo;
|
||||
ComponentClass componentClass;
|
||||
for (ComponentInfo info : componentInfos) {
|
||||
componentInfo = info;
|
||||
componentClass = new ComponentClass("TCG", info.getComponentClass());
|
||||
componentInfo.setComponentClassStr(componentClass.toString());
|
||||
tempList.add(componentInfo);
|
||||
}
|
||||
|
||||
return tempList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,7 +54,17 @@
|
||||
|
||||
<div style="display: flex 1; margin: 2px auto 2px 25px">
|
||||
<c:forEach items="${initialData.componentResults}" var="componentResult">
|
||||
<div class="panel-body">
|
||||
<div class="panel-body" style="background-color: greenyellow">
|
||||
<span class="fieldHeader">Component Class: </span> ${componentResult.getComponentClassStr()}<br />
|
||||
<span class="fieldHeader">Manufacturer:</span> ${componentResult.getManufacturer()}<br />
|
||||
<span class="fieldHeader">Model:</span> ${componentResult.getModel()}<br />
|
||||
<span class="fieldHeader">Serial Number:</span> ${componentResult.getSerialNumber()}<br />
|
||||
<span class="fieldHeader">Revision:</span> ${componentResult.getRevisionNumber()}<br />
|
||||
</div>
|
||||
</c:forEach>
|
||||
<c:forEach items="${initialData.misMatchedCmponentResults}" var="componentResult">
|
||||
<div class="panel-body" style="background-color: greenyellow">
|
||||
<span class="fieldHeader">Component Class: </span> ${componentResult.getComponentClassStr()}<br />
|
||||
<span class="fieldHeader">Manufacturer:</span> ${componentResult.getManufacturer()}<br />
|
||||
<span class="fieldHeader">Model:</span> ${componentResult.getModel()}<br />
|
||||
<span class="fieldHeader">Serial Number:</span> ${componentResult.getSerialNumber()}<br />
|
||||
@ -68,7 +78,17 @@
|
||||
|
||||
<div style="display: flex 2; margin: 2px auto 2px 25px">
|
||||
<c:forEach items="${initialData.componentInfos}" var="componentInfo">
|
||||
<div class="panel-body">
|
||||
<div class="panel-body" style="background-color: lightcoral">
|
||||
<span class="fieldHeader">Component Class: </span> ${componentInfo.getComponentClassStr()}<br />
|
||||
<span class="fieldHeader">Manufacturer:</span> ${componentInfo.getComponentManufacturer()}<br />
|
||||
<span class="fieldHeader">Model:</span> ${componentInfo.getComponentModel()}<br />
|
||||
<span class="fieldHeader">Serial Number:</span> ${componentInfo.getComponentSerial()}<br />
|
||||
<span class="fieldHeader">Revision:</span> ${componentInfo.getComponentRevision()}<br />
|
||||
</div>
|
||||
</c:forEach>
|
||||
<c:forEach items="${initialData.misMatchedComponentInfos}" var="componentInfo">
|
||||
<div class="panel-body" style="background-color: lightcoral">
|
||||
<span class="fieldHeader">Component Class: </span> ${componentInfo.getComponentClassStr()}<br />
|
||||
<span class="fieldHeader">Manufacturer:</span> ${componentInfo.getComponentManufacturer()}<br />
|
||||
<span class="fieldHeader">Model:</span> ${componentInfo.getComponentModel()}<br />
|
||||
<span class="fieldHeader">Serial Number:</span> ${componentInfo.getComponentSerial()}<br />
|
||||
|
Loading…
Reference in New Issue
Block a user