mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-02-20 17:52:47 +00:00
Add column in csv file for platform cert issuer for each component identifier
This commit is contained in:
parent
c0a056b987
commit
3d13b8b72f
@ -42,9 +42,11 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Controller for the Validation Reports page.
|
||||
@ -60,7 +62,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
||||
private static String columnHeaders = "Verified Manufacturer,"
|
||||
+ "Model,SN,Verification Date,Device Status,"
|
||||
+ "Component name,Component manufacturer,Component model,"
|
||||
+ "Component SN,Component status";
|
||||
+ "Component SN,Issuer,Component status";
|
||||
private static final String DEFAULT_COMPANY = "AllDevices";
|
||||
private static final String UNDEFINED = "undefined";
|
||||
private static final Logger LOGGER = getLogger(ValidationReportsPageController.class);
|
||||
@ -261,13 +263,40 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
||||
*/
|
||||
private ArrayList<ArrayList<String>> parseComponents(final PlatformCredential pc) {
|
||||
ArrayList<ArrayList<String>> parsedComponents = new ArrayList<ArrayList<String>>();
|
||||
ArrayList<ArrayList<Object>> chainComponents = new ArrayList<>();
|
||||
if (pc.getComponentIdentifiers() != null
|
||||
&& pc.getComponentIdentifiers().size() > 0) {
|
||||
LOGGER.info("Component failures: " + pc.getComponentFailures());
|
||||
// get all the certificates associated with the platform serial
|
||||
List<PlatformCredential> chainCertificates = PlatformCredential
|
||||
.select(certificateManager)
|
||||
.byBoardSerialNumber(pc.getPlatformSerial())
|
||||
.getCertificates().stream().collect(Collectors.toList());
|
||||
// combine all components in each certificate
|
||||
for (ComponentIdentifier ci : pc.getComponentIdentifiers()) {
|
||||
ArrayList<Object> issuerAndComponent = new ArrayList<Object>();
|
||||
issuerAndComponent.add(pc.getIssuer());
|
||||
issuerAndComponent.add(ci);
|
||||
chainComponents.add(issuerAndComponent);
|
||||
}
|
||||
|
||||
for (PlatformCredential delta : chainCertificates) {
|
||||
if (!delta.isBase()) {
|
||||
for (ComponentIdentifier ci : delta.getComponentIdentifiers()) {
|
||||
ArrayList<Object> issuerAndComponent = new ArrayList<Object>();
|
||||
issuerAndComponent.add(delta.getIssuer());
|
||||
issuerAndComponent.add(ci);
|
||||
chainComponents.add(issuerAndComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<String> componentFailures =
|
||||
new ArrayList<String>(Arrays.asList(pc.getComponentFailures().split(";")));
|
||||
for (ComponentIdentifier ci : pc.getComponentIdentifiers()) {
|
||||
for (ArrayList<Object> issuerAndComponent : chainComponents) {
|
||||
ArrayList<String> componentData = new ArrayList<String>();
|
||||
String issuer = (String) issuerAndComponent.get(0);
|
||||
issuer = issuer.replaceAll(",", " ");
|
||||
ComponentIdentifier ci = (ComponentIdentifier) issuerAndComponent.get(1);
|
||||
if (ci instanceof ComponentIdentifierV2) {
|
||||
componentData.add(((ComponentIdentifierV2) ci).getComponentClass().toString());
|
||||
} else {
|
||||
@ -276,6 +305,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
||||
componentData.add(ci.getComponentManufacturer().getString());
|
||||
componentData.add(ci.getComponentModel().getString());
|
||||
componentData.add(ci.getComponentSerial().getString());
|
||||
componentData.add(issuer);
|
||||
//Failing components are identified by manufacturer + model
|
||||
if (componentFailures.contains(componentData.get(1) + componentData.get(2))) {
|
||||
componentData.add("Fail");
|
||||
|
Loading…
x
Reference in New Issue
Block a user