Additional changes to correct component class string display

This commit is contained in:
Cyrus 2024-03-01 09:28:44 -05:00
parent 21525fc882
commit ca354043cd
7 changed files with 14 additions and 20 deletions

View File

@ -37,6 +37,7 @@ public class ComponentResult extends ArchivableEntity {
// this is a string because component class doesn't inherit serializable. // this is a string because component class doesn't inherit serializable.
@Setter @Setter
private String componentClassValue; private String componentClassValue;
private String componentClassStr;
private String componentClassType; private String componentClassType;
private AttributeStatus attributeStatus; private AttributeStatus attributeStatus;
private String componentAddress; private String componentAddress;
@ -86,6 +87,7 @@ public class ComponentResult extends ArchivableEntity {
// but find bugs is throwing a flag because instanceof isn't being used. // but find bugs is throwing a flag because instanceof isn't being used.
ComponentIdentifierV2 ciV2 = (ComponentIdentifierV2) componentIdentifier; ComponentIdentifierV2 ciV2 = (ComponentIdentifierV2) componentIdentifier;
this.componentClassValue = ciV2.getComponentClass().getComponentIdentifier(); this.componentClassValue = ciV2.getComponentClass().getComponentIdentifier();
this.componentClassStr = ciV2.getComponentClass().toString();
this.componentClassType = ciV2.getComponentClass().getRegistryType(); this.componentClassType = ciV2.getComponentClass().getRegistryType();
this.attributeStatus = ciV2.getAttributeStatus(); this.attributeStatus = ciV2.getAttributeStatus();
this.version2 = true; this.version2 = true;

View File

@ -36,10 +36,6 @@ import java.util.stream.Collectors;
@EqualsAndHashCode @EqualsAndHashCode
public class ComponentIdentifier { public class ComponentIdentifier {
/**
* Variable for components that aren't set.
*/
public static final String EMPTY_COMPONENT = "[Empty]";
/** /**
* Variable for components that aren't set. * Variable for components that aren't set.
*/ */
@ -87,8 +83,8 @@ public class ComponentIdentifier {
public ComponentIdentifier() { public ComponentIdentifier() {
componentManufacturer = new DERUTF8String(NOT_SPECIFIED_COMPONENT); componentManufacturer = new DERUTF8String(NOT_SPECIFIED_COMPONENT);
componentModel = new DERUTF8String(NOT_SPECIFIED_COMPONENT); componentModel = new DERUTF8String(NOT_SPECIFIED_COMPONENT);
componentSerial = new DERUTF8String(EMPTY_COMPONENT); componentSerial = new DERUTF8String(NOT_SPECIFIED_COMPONENT);
componentRevision = new DERUTF8String(EMPTY_COMPONENT); componentRevision = new DERUTF8String(NOT_SPECIFIED_COMPONENT);
componentManufacturerId = null; componentManufacturerId = null;
fieldReplaceable = null; fieldReplaceable = null;
componentAddress = new ArrayList<>(); componentAddress = new ArrayList<>();

View File

@ -97,12 +97,12 @@ public class ComponentInfo extends ArchivableEntity {
if (componentSerial != null) { if (componentSerial != null) {
this.componentSerial = componentSerial.trim(); this.componentSerial = componentSerial.trim();
} else { } else {
this.componentSerial = ComponentIdentifier.EMPTY_COMPONENT; this.componentSerial = ComponentIdentifier.NOT_SPECIFIED_COMPONENT;
} }
if (componentRevision != null) { if (componentRevision != null) {
this.componentRevision = componentRevision.trim(); this.componentRevision = componentRevision.trim();
} else { } else {
this.componentRevision = ComponentIdentifier.EMPTY_COMPONENT; this.componentRevision = ComponentIdentifier.NOT_SPECIFIED_COMPONENT;
} }
} }

View File

@ -179,11 +179,8 @@ public final class PciIds {
*/ */
public static ComponentResult translateResult(final ComponentResult componentResult) { public static ComponentResult translateResult(final ComponentResult componentResult) {
ComponentResult newComponent = null; ComponentResult newComponent = null;
ComponentClass updateComponentClass;
if (componentResult != null) { if (componentResult != null) {
newComponent = componentResult; newComponent = componentResult;
updateComponentClass = new ComponentClass(componentResult.getComponentClassType(), componentResult.getComponentClassValue());
newComponent.setComponentClassValue(updateComponentClass.toString());
newComponent.setManufacturer(translateVendor(componentResult.getManufacturer())); newComponent.setManufacturer(translateVendor(componentResult.getManufacturer()));
newComponent.setModel(translateDevice(componentResult.getManufacturer(), newComponent.setModel(translateDevice(componentResult.getManufacturer(),
componentResult.getModel())); componentResult.getModel()));
@ -260,13 +257,12 @@ public final class PciIds {
*/ */
public static String translateDevice(final String refManufacturer, public static String translateDevice(final String refManufacturer,
final String refModel) { final String refModel) {
String manufacturer = refManufacturer;
String model = refModel; String model = refModel;
if (manufacturer != null if (refManufacturer != null
&& model != null && model != null
&& manufacturer.trim().matches("^[0-9A-Fa-f]{4}$") && refManufacturer.trim().matches("^[0-9A-Fa-f]{4}$")
&& model.trim().matches("^[0-9A-Fa-f]{4}$")) { && model.trim().matches("^[0-9A-Fa-f]{4}$")) {
Device dev = DB.findDevice(manufacturer.toLowerCase(), Device dev = DB.findDevice(refManufacturer.toLowerCase(),
model.toLowerCase()); model.toLowerCase());
if (dev != null && !Strings.isNullOrEmpty(dev.getName())) { if (dev != null && !Strings.isNullOrEmpty(dev.getName())) {
model = dev.getName(); model = dev.getName();

View File

@ -368,7 +368,7 @@ public class CertificateAttributeScvValidator extends SupplyChainCredentialValid
StringBuilder additionalInfo = new StringBuilder(); StringBuilder additionalInfo = new StringBuilder();
if (!remainingComponentResults.isEmpty()) { if (!remainingComponentResults.isEmpty()) {
resultMessage.append(String.format("There are %d components not matched\n", resultMessage.append(String.format("There are %d components not matched%n",
remainingComponentResults.size())); remainingComponentResults.size()));
resultMessage.append(String.format("\twith %d total attributes mismatched.", resultMessage.append(String.format("\twith %d total attributes mismatched.",
numOfAttributes)); numOfAttributes));

View File

@ -573,7 +573,7 @@ public class PlatformCredentialTest {
.equals("BIOS")); .equals("BIOS"));
Assertions.assertTrue(component.getComponentSerial() Assertions.assertTrue(component.getComponentSerial()
.getString() .getString()
.equals(ComponentIdentifier.EMPTY_COMPONENT)); .equals(ComponentIdentifier.NOT_SPECIFIED_COMPONENT));
Assertions.assertTrue(component.getComponentRevision() Assertions.assertTrue(component.getComponentRevision()
.getString() .getString()
.equals("DNKBLi5v.86A.0019.2017.0804.1146")); .equals("DNKBLi5v.86A.0019.2017.0804.1146"));

View File

@ -601,7 +601,7 @@
<div class="row"> <div class="row">
<div class="col-md-1 col-md-offset-1"><span class="colHeader">TCG Platform Configuration</span></div> <div class="col-md-1 col-md-offset-1"><span class="colHeader">TCG Platform Configuration</span></div>
<div id="platformConfiguration" class="col col-md-8"> <div id="platformConfiguration" class="col col-md-8">
<c:if test="${not empty initialData.componentsIdentifier}"> <c:if test="${not empty initialData.componentResults}">
<!-- Component Identifier --> <!-- Component Identifier -->
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne"> <div class="panel-heading" role="tab" id="headingOne">
@ -619,7 +619,7 @@
<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="${component.isFailedValidation()=='TRUE'}"> <c:when test="${component.isFailedValidation() =='TRUE'}">
<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>
@ -628,7 +628,7 @@
</c:choose> </c:choose>
<c:choose> <c:choose>
<c:when test="${component.isVersion2()=='TRUE'}"> <c:when test="${component.isVersion2()=='TRUE'}">
<span data-toggle="tooltip" data-placement="top" title="Component Class">${component.getComponentClassValue()}</span> <span data-toggle="tooltip" data-placement="top" title="Component Class">${component.getComponentClassStr()}</span>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<span data-toggle="tooltip" data-placement="top" title="Component Class">Platform Components</span> <span data-toggle="tooltip" data-placement="top" title="Component Class">Platform Components</span>