mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-21 13:57:56 +00:00
Merge pull request #317 from nsacyber/update-component-failure-highlight
[#316] Update component failure highlight
This commit is contained in:
commit
d99bb1039c
@ -84,6 +84,7 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
|||||||
|
|
||||||
private static final Logger LOGGER
|
private static final Logger LOGGER
|
||||||
= LogManager.getLogger(SupplyChainValidationServiceImpl.class);
|
= LogManager.getLogger(SupplyChainValidationServiceImpl.class);
|
||||||
|
private static final int VALUE_INDEX = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -238,7 +239,8 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
|||||||
String.format("%s%n%s", platformScv.getMessage(),
|
String.format("%s%n%s", platformScv.getMessage(),
|
||||||
attributeScv.getMessage())));
|
attributeScv.getMessage())));
|
||||||
}
|
}
|
||||||
componentFailures = attributeScv.getMessage();
|
componentFailures = updateUnmatchedComponents(
|
||||||
|
attributeScv.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.setDevice(device);
|
pc.setDevice(device);
|
||||||
@ -270,6 +272,29 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
|||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String updateUnmatchedComponents(final String unmatchedString) {
|
||||||
|
StringBuilder updatedFailures = new StringBuilder();
|
||||||
|
String manufacturer = "";
|
||||||
|
String model = "";
|
||||||
|
for (String rows : unmatchedString.split(";")) {
|
||||||
|
for (String str : rows.split(",")) {
|
||||||
|
String[] manufacturerSplit;
|
||||||
|
String[] modelSplit;
|
||||||
|
if (str.contains("Manufacturer")) {
|
||||||
|
manufacturerSplit = str.split("=");
|
||||||
|
manufacturer = manufacturerSplit[VALUE_INDEX];
|
||||||
|
}
|
||||||
|
if (str.contains("Model")) {
|
||||||
|
modelSplit = str.split("=");
|
||||||
|
model = modelSplit[VALUE_INDEX];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatedFailures.append(String.format("%s%s;", manufacturer, model));
|
||||||
|
}
|
||||||
|
|
||||||
|
return updatedFailures.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is a sub set of the validate supply chain method and focuses
|
* This method is a sub set of the validate supply chain method and focuses
|
||||||
* on the specific multibase validation check for a delta chain. This method
|
* on the specific multibase validation check for a delta chain. This method
|
||||||
|
@ -31,7 +31,6 @@ public final class CertificateStringMapBuilder {
|
|||||||
|
|
||||||
private static final Logger LOGGER =
|
private static final Logger LOGGER =
|
||||||
LogManager.getLogger(CertificateStringMapBuilder.class);
|
LogManager.getLogger(CertificateStringMapBuilder.class);
|
||||||
private static final int SERIAL_INDEX = 1;
|
|
||||||
|
|
||||||
private CertificateStringMapBuilder() {
|
private CertificateStringMapBuilder() {
|
||||||
|
|
||||||
@ -341,19 +340,7 @@ public final class CertificateStringMapBuilder {
|
|||||||
//CPSuri
|
//CPSuri
|
||||||
data.put("CPSuri", certificate.getCPSuri());
|
data.put("CPSuri", certificate.getCPSuri());
|
||||||
//component failure
|
//component failure
|
||||||
StringBuilder savedFailures = new StringBuilder();
|
data.put("failures", certificate.getComponentFailures());
|
||||||
String[] serialSplit;
|
|
||||||
for (String s : certificate.getComponentFailures().split(",")) {
|
|
||||||
if (s.contains("Serial")) {
|
|
||||||
serialSplit = s.split("=");
|
|
||||||
if (serialSplit.length > SERIAL_INDEX) {
|
|
||||||
savedFailures.append(serialSplit[SERIAL_INDEX]);
|
|
||||||
} else {
|
|
||||||
savedFailures.append(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.put("failures", savedFailures.toString());
|
|
||||||
|
|
||||||
//Get platform Configuration values and set map with it
|
//Get platform Configuration values and set map with it
|
||||||
PlatformConfiguration platformConfiguration = certificate.getPlatformConfiguration();
|
PlatformConfiguration platformConfiguration = certificate.getPlatformConfiguration();
|
||||||
|
@ -614,10 +614,11 @@
|
|||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div id="componentIdentifier" class="row">
|
<div id="componentIdentifier" class="row">
|
||||||
<c:forEach items="${initialData.componentsIdentifier}" var="component">
|
<c:forEach items="${initialData.componentsIdentifier}" var="component">
|
||||||
|
<c:set var="combined" value="${component.getComponentManufacturer()}${component.getComponentModel()}" scope="page"/>
|
||||||
<div class="component col col-md-4">
|
<div class="component col col-md-4">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${fn:contains(initialData.failures, component.getComponentSerial()) && not empty fn:trim(component.getComponentSerial())}">
|
<c:when test="${fn:contains(initialData.failures, combined)}">
|
||||||
<div class="panel-heading" style="background-color: red; color: white">
|
<div class="panel-heading" style="background-color: red; color: white">
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
|
@ -852,11 +852,11 @@ public final class SupplyChainCredentialValidator implements CredentialValidator
|
|||||||
LOGGER.error(String.format("Platform Credential contained %d unmatched components:",
|
LOGGER.error(String.format("Platform Credential contained %d unmatched components:",
|
||||||
pcUnmatchedComponents.size()));
|
pcUnmatchedComponents.size()));
|
||||||
|
|
||||||
int umatchedComponentCounter = 1;
|
int unmatchedComponentCounter = 1;
|
||||||
for (ComponentIdentifier unmatchedComponent : pcUnmatchedComponents) {
|
for (ComponentIdentifier unmatchedComponent : pcUnmatchedComponents) {
|
||||||
LOGGER.error("Unmatched component " + umatchedComponentCounter++ + ": "
|
LOGGER.error("Unmatched component " + unmatchedComponentCounter++ + ": "
|
||||||
+ unmatchedComponent);
|
+ unmatchedComponent);
|
||||||
sb.append(String.format("Manufacturer=%s, Model=%s, Serial=%s, Revision=%s%n",
|
sb.append(String.format("Manufacturer=%s, Model=%s, Serial=%s, Revision=%s;%n",
|
||||||
unmatchedComponent.getComponentManufacturer(),
|
unmatchedComponent.getComponentManufacturer(),
|
||||||
unmatchedComponent.getComponentModel(),
|
unmatchedComponent.getComponentModel(),
|
||||||
unmatchedComponent.getComponentSerial(),
|
unmatchedComponent.getComponentSerial(),
|
||||||
|
Loading…
Reference in New Issue
Block a user