All components were failing on tests specifically set up to match components and pass. This happened because the int value of the component class value was being translated with SHORT.size. This is odd because it worked before but stopped.

This commit is contained in:
Cyrus 2021-06-29 12:04:22 -04:00
parent 0f8d41e78f
commit 3269e81783
2 changed files with 8 additions and 12 deletions

View File

@ -102,11 +102,6 @@ public class ComponentClass {
*/
public ComponentClass(final Path componentClassPath, final String componentIdentifier) {
this(TCG_COMPONENT_REGISTRY, componentClassPath, getComponentIntValue(componentIdentifier));
if (componentIdentifier != null && componentIdentifier.contains("#")) {
this.classValueString = componentIdentifier.replaceAll("#", "");
} else {
this.classValueString = componentIdentifier;
}
}
/**
@ -152,6 +147,8 @@ public class ComponentClass {
getCategory(JsonUtils.getSpecificJsonObject(componentClassPath, registryType));
break;
}
this.classValueString = String.valueOf(componentIdentifier);
}
/**
@ -276,12 +273,11 @@ public class ComponentClass {
componentValue = Integer.decode(component);
} else {
if (component.contains("#")) {
componentValue = Integer.valueOf(
component.replace("#", ""),
Short.SIZE);
componentValue = Integer.parseInt(
component.replace("#", ""));
} else {
componentValue = Integer.valueOf(
component, Short.SIZE);
componentValue = Integer.parseInt(
component);
}
}
} catch (NumberFormatException nfEx) {

View File

@ -750,8 +750,8 @@ public final class SupplyChainCredentialValidator implements CredentialValidator
for (ComponentInfo cInfo : allDeviceInfoComponents) {
for (ComponentIdentifier cId : fullDeltaChainComponents) {
ciV2 = (ComponentIdentifierV2) cId;
if (ciV2.getComponentClass().getClassValueString()
.contains(cInfo.getComponentClass())
if (cInfo.getComponentClass().contains(
ciV2.getComponentClass().getClassValueString())
&& isMatch(cId, cInfo)) {
subCompIdList.remove(cId);
subCompInfoList.remove(cInfo);