From bdb32d13ad1c7255e28eb1ed48885acd6d41e3e4 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Mon, 9 Nov 2020 12:45:36 -0500 Subject: [PATCH 1/4] initial commit --- .../portal/util/CertificateStringMapBuilder.java | 14 +++++++------- .../validation/SupplyChainCredentialValidator.java | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/util/CertificateStringMapBuilder.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/util/CertificateStringMapBuilder.java index fa41c058..073eb34a 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/util/CertificateStringMapBuilder.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/util/CertificateStringMapBuilder.java @@ -31,7 +31,7 @@ public final class CertificateStringMapBuilder { private static final Logger LOGGER = LogManager.getLogger(CertificateStringMapBuilder.class); - private static final int SERIAL_INDEX = 1; + private static final int VALUE_INDEX = 1; private CertificateStringMapBuilder() { @@ -343,13 +343,13 @@ public final class CertificateStringMapBuilder { //component failure StringBuilder savedFailures = new StringBuilder(); 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]); + for (String str : certificate.getComponentFailures().split(",")) { + if (str.contains("Model")) { + serialSplit = str.split("="); + if (serialSplit.length > VALUE_INDEX) { + savedFailures.append(serialSplit[VALUE_INDEX]); } else { - savedFailures.append(s); + savedFailures.append(str); } } } diff --git a/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java b/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java index addf6d15..08cc3134 100644 --- a/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java +++ b/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java @@ -852,9 +852,9 @@ public final class SupplyChainCredentialValidator implements CredentialValidator LOGGER.error(String.format("Platform Credential contained %d unmatched components:", pcUnmatchedComponents.size())); - int umatchedComponentCounter = 1; + int unmatchedComponentCounter = 1; for (ComponentIdentifier unmatchedComponent : pcUnmatchedComponents) { - LOGGER.error("Unmatched component " + umatchedComponentCounter++ + ": " + LOGGER.error("Unmatched component " + unmatchedComponentCounter++ + ": " + unmatchedComponent); sb.append(String.format("Manufacturer=%s, Model=%s, Serial=%s, Revision=%s%n", unmatchedComponent.getComponentManufacturer(), From e8f5107137ffb82b5bd9870c7bb920b945bce897 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Mon, 9 Nov 2020 13:59:19 -0500 Subject: [PATCH 2/4] Updating code to use a different format for identifying failed components. --- .../SupplyChainValidationServiceImpl.java | 24 +++++++++++++++++++ .../SupplyChainCredentialValidator.java | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java index be430c30..13612706 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java @@ -84,6 +84,7 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe private static final Logger LOGGER = LogManager.getLogger(SupplyChainValidationServiceImpl.class); + private static final int VALUE_INDEX = 1; /** * Constructor. @@ -270,6 +271,29 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe 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 * on the specific multibase validation check for a delta chain. This method diff --git a/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java b/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java index 08cc3134..b449e2de 100644 --- a/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java +++ b/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java @@ -856,7 +856,7 @@ public final class SupplyChainCredentialValidator implements CredentialValidator for (ComponentIdentifier unmatchedComponent : pcUnmatchedComponents) { LOGGER.error("Unmatched component " + unmatchedComponentCounter++ + ": " + 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.getComponentModel(), unmatchedComponent.getComponentSerial(), From 67b70a386d9a2c074f72bb16dad733bc36598ce7 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 10 Nov 2020 10:04:46 -0500 Subject: [PATCH 3/4] Added method to combine the manufacturer and the model as an identifier for the component. --- .../service/SupplyChainValidationServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java index 13612706..06c8be9f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java @@ -239,7 +239,8 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe String.format("%s%n%s", platformScv.getMessage(), attributeScv.getMessage()))); } - componentFailures = attributeScv.getMessage(); + componentFailures = updateUnmatchedComponents( + attributeScv.getMessage()); } pc.setDevice(device); From f7912908e03753be20843f0f9fb7ef1e1aa0a96c Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 12 Nov 2020 09:58:18 -0500 Subject: [PATCH 4/4] Final changes to be tested against component failures --- .../portal/util/CertificateStringMapBuilder.java | 15 +-------------- .../webapp/WEB-INF/jsp/certificate-details.jsp | 3 ++- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/util/CertificateStringMapBuilder.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/util/CertificateStringMapBuilder.java index 073eb34a..60c7a734 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/util/CertificateStringMapBuilder.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/util/CertificateStringMapBuilder.java @@ -31,7 +31,6 @@ public final class CertificateStringMapBuilder { private static final Logger LOGGER = LogManager.getLogger(CertificateStringMapBuilder.class); - private static final int VALUE_INDEX = 1; private CertificateStringMapBuilder() { @@ -341,19 +340,7 @@ public final class CertificateStringMapBuilder { //CPSuri data.put("CPSuri", certificate.getCPSuri()); //component failure - StringBuilder savedFailures = new StringBuilder(); - String[] serialSplit; - for (String str : certificate.getComponentFailures().split(",")) { - if (str.contains("Model")) { - serialSplit = str.split("="); - if (serialSplit.length > VALUE_INDEX) { - savedFailures.append(serialSplit[VALUE_INDEX]); - } else { - savedFailures.append(str); - } - } - } - data.put("failures", savedFailures.toString()); + data.put("failures", certificate.getComponentFailures()); //Get platform Configuration values and set map with it PlatformConfiguration platformConfiguration = certificate.getPlatformConfiguration(); diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp index 7b0c1c7e..e6158a3b 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp @@ -614,10 +614,11 @@