Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#731] Comparison page Creation #741

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4dd6de1
Initial push. Minor changes that'll update the details page
cyrus-dev Mar 12, 2024
06c0766
initial push to add a new page for component comparison
cyrus-dev Mar 13, 2024
24d66e8
Merge branch 'main' into v3_issue-731-comparison-page
cyrus-dev Mar 15, 2024
04023c5
Updated some more code, commiting to merge in updates from main that are
cyrus-dev Mar 16, 2024
e0de63a
Fixed parameter for the controller
cyrus-dev Mar 18, 2024
32b1026
Updated how the platform certificate is accessed
cyrus-dev Mar 18, 2024
a0c2b22
Updated certain parameters to easily identify and pull information from
cyrus-dev Mar 19, 2024
e0ce4b2
This update fixes the passing of parameters from the validation page to
cyrus-dev Mar 19, 2024
5a4d2e9
The changes upaded the comparison page
cyrus-dev Mar 20, 2024
6308dad
Continued formating of the jsp
cyrus-dev Mar 21, 2024
d907c91
Updated the comparison page, the layout is now looking better.
cyrus-dev Mar 21, 2024
29ef08e
These changes highlight matched and unmatched
cyrus-dev Mar 21, 2024
1cdb07a
Reverted some changes after a lot of bugs
cyrus-dev Mar 21, 2024
cff5771
upated page left out of previous commit
cyrus-dev Mar 21, 2024
b4940d6
Cleaned up the errors
cyrus-dev Mar 22, 2024
ebd36f1
Updated colors and margins
cyrus-dev Mar 22, 2024
465c9de
Updated component info to save the registry id
cyrus-dev Mar 22, 2024
60d1192
Updated the method for translating the component class value
cyrus-dev Mar 22, 2024
fe570f0
Updated the colors for the comparison page
cyrus-dev Mar 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface ComponentAttributeRepository extends JpaRepository<ComponentAtt
* @param provisionSessionId unique id generated to link supply chain summary
* @return a list of attribute results
*/
List<ComponentAttributeResult> findByProvisionSessionId(UUID provisionSessionId);
List<ComponentAttributeResult> findByProvisionSessionId(String provisionSessionId);

/**
* Query to look up Attribute Results based on the component id and the session id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public interface ComponentInfoRepository extends JpaRepository<ComponentInfo, UU
* @return a list of device components
*/
List<ComponentInfo> findByDeviceName(String deviceName);
/**
* Query that retrieves device components by device name and order them
* by component class
* @param deviceName string for the host name
* @return a list of device components
*/
List<ComponentInfo> findByDeviceNameOrderByComponentClassAsc(String deviceName);

/**
* Query that retrieves device components by device name and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public interface ComponentResultRepository extends JpaRepository<ComponentResult
*/
List<ComponentResult> findByBoardSerialNumber(String boardSerialNumber);

/**
* Query based on the device serial number.
* @param boardSerialNumber variable holding the device serial number
* @return a list of component result.
*/
List<ComponentResult> findByBoardSerialNumberOrderByComponentClassValueAsc(String boardSerialNumber);

/**
* Query based on certificate serial number and device serial number.
* @param certificateSerialNumber certificate specific serial number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;
import java.util.UUID;

Expand All @@ -15,4 +16,5 @@ public interface PlatformCertificateRepository extends JpaRepository<PlatformCre
List<PlatformCredential> findByArchiveFlag(boolean archiveFlag);
Page<PlatformCredential> findByArchiveFlag(boolean archiveFlag, Pageable pageable);
List<PlatformCredential> findByDeviceId(UUID deviceId);
PlatformCredential findByPlatformSerialAndSerialNumber(String platformSerial, BigInteger serialNumber);
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ public class SupplyChainValidationSummary extends ArchivableEntity {
targetEntity = SupplyChainValidation.class, orphanRemoval = true)
private final Set<SupplyChainValidation> validations;

@Getter
@Column
private String provisionSessionId;
@Getter
@Column
private UUID provisionSessionId;
private String deviceName;

/**
* Default constructor necessary for Hibernate.
Expand All @@ -70,6 +74,7 @@ protected SupplyChainValidationSummary() {
overallValidationResult = AppraisalStatus.Status.FAIL;
validations = Collections.emptySet();
this.message = Strings.EMPTY;
this.deviceName = Strings.EMPTY;
}

/**
Expand Down Expand Up @@ -190,9 +195,10 @@ public static SupplyChainValidationSummary.Selector select(
*/
public SupplyChainValidationSummary(final Device device,
final Collection<SupplyChainValidation> validations,
final UUID provisionSessionId) {
final String provisionSessionId) {
this(device, validations);
this.provisionSessionId = provisionSessionId;
this.deviceName = this.device.getName();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

/**
* A component result is a DO to hold the status of a component validation status. This will
Expand Down Expand Up @@ -45,7 +46,8 @@ public class ComponentResult extends ArchivableEntity {
@Setter
private boolean failedValidation;
private String certificateType;

@Setter
private UUID deviceInfo;
private String issuerDN;
private String certificateSerialNumber;
private String boardSerialNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.JdbcTypeCode;

import java.util.UUID;

Expand All @@ -20,21 +21,25 @@
public class ComponentAttributeResult extends ArchivableEntity {

private UUID componentId;
private UUID deviceComponentId;
@Setter
private UUID provisionSessionId;
private String provisionSessionId;
private String expectedValue;
private String actualValue;

/**
* 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.xml.bind.annotation.XmlElement;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -23,6 +24,7 @@
@Log4j2
@Entity
@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@DiscriminatorColumn(name = "componentTypeEnum", discriminatorType = DiscriminatorType.STRING)
public class ComponentInfo extends ArchivableEntity {
Expand Down Expand Up @@ -53,13 +55,18 @@ public class ComponentInfo extends ArchivableEntity {
@XmlElement
@Column
private String componentClass;
@Column
private String componentClassRegistry;
@Column
private String componentClassStr;

/**
* Base constructor for children.
*
* @param componentManufacturer Component Manufacturer (must not be null)
* @param componentModel Component Model (must not be null)
* @param componentSerial Component Serial Number (can be null)
* @param componentRevision Component Revision or Version (can be null)
* @param componentModel Component Model (must not be null)
* @param componentSerial Component Serial Number (can be null)
* @param componentRevision Component Revision or Version (can be null)
*/
public ComponentInfo(final String componentManufacturer,
final String componentModel,
Expand All @@ -68,13 +75,15 @@ public ComponentInfo(final String componentManufacturer,
this(DeviceInfoEnums.NOT_SPECIFIED, componentManufacturer, componentModel,
componentSerial, componentRevision);
}

/**
* Constructor.
* @param deviceName the host machine associated with this component. (must not be null)
*
* @param deviceName the host machine associated with this component. (must not be null)
* @param componentManufacturer Component Manufacturer (must not be null)
* @param componentModel Component Model (must not be null)
* @param componentSerial Component Serial Number (can be null)
* @param componentRevision Component Revision or Version (can be null)
* @param componentModel Component Model (must not be null)
* @param componentSerial Component Serial Number (can be null)
* @param componentRevision Component Revision or Version (can be null)
*/
public ComponentInfo(final String deviceName,
final String componentManufacturer,
Expand Down Expand Up @@ -108,23 +117,39 @@ public ComponentInfo(final String deviceName,

/**
* Constructor.
* @param deviceName the host machine associated with this component.
*
* @param deviceName the host machine associated with this component.
* @param componentManufacturer Component Manufacturer (must not be null)
* @param componentModel Component Model (must not be null)
* @param componentSerial Component Serial Number (can be null)
* @param componentRevision Component Revision or Version (can be null)
* @param componentClass Component Class (can be null)
* @param componentModel Component Model (must not be null)
* @param componentSerial Component Serial Number (can be null)
* @param componentRevision Component Revision or Version (can be null)
* @param componentClass Component Class (can be null)
* @param componentClassRegistry The id that indicates TCG or SMBIOS
*/
public ComponentInfo(final String deviceName,
final String componentManufacturer,
final String componentModel,
final String componentSerial,
final String componentRevision,
final String componentClass) {
final String componentClass,
final String componentClassRegistry) {
this(deviceName, componentManufacturer, componentModel,
componentSerial, componentRevision);

this.componentClass = Objects.requireNonNullElse(componentClass, StringUtils.EMPTY);
this.componentClassRegistry = Objects.requireNonNullElse(componentClassRegistry, StringUtils.EMPTY);
}

/**
* Blank object to display on comparision page.
* @param empty nothing
*/
public ComponentInfo(final String empty) {
this.deviceName = StringUtils.EMPTY;
this.componentManufacturer = StringUtils.EMPTY;
this.componentModel = StringUtils.EMPTY;
this.componentSerial = StringUtils.EMPTY;
this.componentRevision = StringUtils.EMPTY;
}

/**
Expand All @@ -134,9 +159,9 @@ public ComponentInfo(final String deviceName,
* manufacturer and model are considered valid.
*
* @param componentManufacturer a String containing a component's manufacturer
* @param componentModel a String representing a component's model
* @param componentSerial a String representing a component's serial number
* @param componentRevision a String representing a component's revision
* @param componentModel a String representing a component's model
* @param componentSerial a String representing a component's serial number
* @param componentRevision a String representing a component's revision
* @return true if the component is valid, false if not
*/
public static boolean isComplete(final String componentManufacturer,
Expand All @@ -149,6 +174,7 @@ public static boolean isComplete(final String componentManufacturer,

/**
* Equals for the component info that just uses this classes attributes.
*
* @param object the object to compare
* @return the boolean result
*/
Expand All @@ -169,6 +195,7 @@ public boolean equals(Object object) {

/**
* Returns a hash code that is associated with common fields for components.
*
* @return int value of the elements
*/
public int hashCommonElements() {
Expand All @@ -178,6 +205,7 @@ public int hashCommonElements() {

/**
* Hash method for the attributes of this class.
*
* @return int value that represents this class
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class SupplyChainValidationService {
private CertificateRepository certificateRepository;
private SupplyChainValidationRepository supplyChainValidationRepository;
private SupplyChainValidationSummaryRepository supplyChainValidationSummaryRepository;
private UUID provisionSessionId;
private String provisionSessionId;

/**
* Constructor.
Expand Down Expand Up @@ -109,7 +109,7 @@ public SupplyChainValidationSummary validateSupplyChain(final EndorsementCredent
final Device device,
final List<ComponentInfo> componentInfos) {
boolean acceptExpiredCerts = getPolicySettings().isExpiredCertificateValidationEnabled();
provisionSessionId = UUID.randomUUID();
provisionSessionId = UUID.randomUUID().toString();
PlatformCredential baseCredential = null;
SupplyChainValidation platformScv = null;
SupplyChainValidation basePlatformScv = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static SupplyChainValidation evaluatePCAttributesStatus(
final ComponentResultRepository componentResultRepository,
final ComponentAttributeRepository componentAttributeRepository,
final List<ComponentInfo> componentInfos,
final UUID provisionSessionId) {
final String provisionSessionId) {
final SupplyChainValidation.ValidationType validationType
= SupplyChainValidation.ValidationType.PLATFORM_CREDENTIAL_ATTRIBUTES;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentClass;
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentIdentifier;
import hirs.attestationca.persist.entity.userdefined.certificate.attributes.V2.ComponentIdentifierV2;
import hirs.attestationca.persist.entity.userdefined.info.ComponentInfo;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

Expand Down Expand Up @@ -135,6 +136,28 @@ public static List<ComponentResult> translateResults(final List<ComponentResult>
return newList;
}

/**
* Iterate through all components and translate PCI hardware IDs as necessary. It will only
* translate ComponentInfo objects as it relies on Component Class information.
* @param componentInfos List of ComponentInfos.
* @return the translated list of ComponentInfos.
*/
public static List<ComponentInfo> translateDeviceComponentInfo(final List<ComponentInfo> componentInfos) {
List<ComponentInfo> newList = new ArrayList<>();
if (componentInfos != null && !componentInfos.isEmpty()) {
for (final ComponentInfo componentInfo : componentInfos) {
if (!componentInfo.getDeviceName().isEmpty()) {
newList.add(translateDeviceComponentInfo(componentInfo));
} else {
// if the object is all StringUtils.empty()
newList.add(componentInfo);
}
}
}

return newList;
}

/**
* Translate Vendor and Device IDs, if found, in ComponentIdentifierV2 objects.
* It will only translate ID values, any other value will pass through.
Expand Down Expand Up @@ -188,6 +211,23 @@ public static ComponentResult translateResult(final ComponentResult componentRes
return newComponent;
}

/**
* Translate Vendor and Device IDs, if found, in ComponentInfo objects.
* It will only translate ID values, any other value will pass through.
* @param componentInfo ComponentInfo object.
* @return the translated ComponentInfo object.
*/
public static ComponentInfo translateDeviceComponentInfo(final ComponentInfo componentInfo) {
ComponentInfo newComponent = null;
if (componentInfo != null) {
newComponent = componentInfo;
newComponent.setComponentManufacturer(translateVendor(componentInfo.getComponentManufacturer()));
newComponent.setComponentModel(translateDevice(componentInfo.getComponentManufacturer(),
componentInfo.getComponentModel()));
}
return newComponent;
}

/**
* Look up the vendor name from the PCI IDs list, if the input string contains an ID.
* If any part of this fails, return the original manufacturer value.
Expand Down
Loading
Loading