mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-18 20:47:58 +00:00
issue_847: Took another look over the PR for this issue and found nothing alarming. Made some minor tweaks to four files. Should be good to go for PR
This commit is contained in:
parent
18efb25d41
commit
963086fc0e
@ -147,7 +147,7 @@ public abstract class ReferenceManifestSelector<T extends ReferenceManifest> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the criterion that can be used to query for rims matching the
|
* Construct the criterion that can be used to query for rims matching the
|
||||||
* + * configuration of this {@link ReferenceManifestSelector}.
|
* configuration of this {@link ReferenceManifestSelector}.
|
||||||
*
|
*
|
||||||
* @param criteriaBuilder criteria builder
|
* @param criteriaBuilder criteria builder
|
||||||
* @return a Criterion that can be used to query for rims matching the
|
* @return a Criterion that can be used to query for rims matching the
|
||||||
|
@ -3,10 +3,10 @@ package hirs.attestationca.portal.datatables;
|
|||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
@ -18,10 +18,22 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Represents a data table input in a jQuery DataTable.
|
* Represents a data table input in a jQuery DataTable.
|
||||||
*/
|
*/
|
||||||
@NoArgsConstructor(access = AccessLevel.PUBLIC)
|
@Getter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ToString
|
||||||
public class DataTableInput {
|
public class DataTableInput {
|
||||||
|
|
||||||
private static final int DEFAULT_LENGTH = 10;
|
private static final int DEFAULT_LENGTH = 10;
|
||||||
|
/**
|
||||||
|
* Order parameter.
|
||||||
|
*/
|
||||||
|
@NotEmpty
|
||||||
|
private final List<Order> order = new ArrayList<>();
|
||||||
|
/**
|
||||||
|
* Per-column search parameter.
|
||||||
|
*/
|
||||||
|
@NotEmpty
|
||||||
|
private final List<Column> columns = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* Draw counter. This is used by DataTables to ensure that the Ajax returns from server-side
|
* Draw counter. This is used by DataTables to ensure that the Ajax returns from server-side
|
||||||
* processing requests are drawn in sequence by DataTables (Ajax requests are asynchronous and
|
* processing requests are drawn in sequence by DataTables (Ajax requests are asynchronous and
|
||||||
@ -30,7 +42,6 @@ public class DataTableInput {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(0)
|
@Min(0)
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private int draw = 1;
|
private int draw = 1;
|
||||||
/**
|
/**
|
||||||
@ -39,7 +50,6 @@ public class DataTableInput {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(0)
|
@Min(0)
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private int start = 0;
|
private int start = 0;
|
||||||
/**
|
/**
|
||||||
@ -51,28 +61,14 @@ public class DataTableInput {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
@Min(-1)
|
@Min(-1)
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private int length = DEFAULT_LENGTH;
|
private int length = DEFAULT_LENGTH;
|
||||||
/**
|
/**
|
||||||
* Global search parameter.
|
* Global search parameter.
|
||||||
*/
|
*/
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
@NotNull
|
@NotNull
|
||||||
private Search search = new Search();
|
private Search search = new Search();
|
||||||
/**
|
|
||||||
* Order parameter.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@NotEmpty
|
|
||||||
private List<Order> order = new ArrayList<>();
|
|
||||||
/**
|
|
||||||
* Per-column search parameter.
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@NotEmpty
|
|
||||||
private List<Column> columns = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -200,23 +196,4 @@ public class DataTableInput {
|
|||||||
}
|
}
|
||||||
return orderColumnName;
|
return orderColumnName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a string for this object.
|
|
||||||
*
|
|
||||||
* @return the string
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "DataTableInput{"
|
|
||||||
+ "draw=" + draw
|
|
||||||
+ ", start=" + start
|
|
||||||
+ ", length=" + length
|
|
||||||
+ ", search=" + search
|
|
||||||
+ ", order=" + order
|
|
||||||
+ ", columns=" + columns
|
|
||||||
+ '}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,16 +141,14 @@ public class ReferenceManifestDetailsPageController
|
|||||||
* @param certificateRepository the certificate manager.
|
* @param certificateRepository the certificate manager.
|
||||||
* @param caCertificateRepository the certificate manager.
|
* @param caCertificateRepository the certificate manager.
|
||||||
* @return mapping of the RIM information from the database.
|
* @return mapping of the RIM information from the database.
|
||||||
* @throws java.io.IOException error for reading file bytes.
|
* @throws java.io.IOException error for reading file bytes.
|
||||||
* @throws NoSuchAlgorithmException If an unknown Algorithm is encountered.
|
|
||||||
* @throws CertificateException if a certificate doesn't parse.
|
|
||||||
*/
|
*/
|
||||||
private static HashMap<String, Object> getBaseRimInfo(
|
private static HashMap<String, Object> getBaseRimInfo(
|
||||||
final BaseReferenceManifest baseRim,
|
final BaseReferenceManifest baseRim,
|
||||||
final ReferenceManifestRepository referenceManifestRepository,
|
final ReferenceManifestRepository referenceManifestRepository,
|
||||||
final CertificateRepository certificateRepository,
|
final CertificateRepository certificateRepository,
|
||||||
final CACredentialRepository caCertificateRepository)
|
final CACredentialRepository caCertificateRepository)
|
||||||
throws IOException, CertificateException, NoSuchAlgorithmException {
|
throws IOException {
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
|
|
||||||
// Software Identity
|
// Software Identity
|
||||||
@ -260,8 +258,8 @@ public class ReferenceManifestDetailsPageController
|
|||||||
caCertificateRepository));
|
caCertificateRepository));
|
||||||
RIM_VALIDATOR.setTrustStore(truststore);
|
RIM_VALIDATOR.setTrustStore(truststore);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error building CA chain for " + caCert.getSubjectKeyIdentifier() + ": "
|
log.error("Error building CA chain for {}: {}", caCert.getSubjectKeyIdentifier(),
|
||||||
+ e.getMessage());
|
e.getMessage());
|
||||||
}
|
}
|
||||||
if (RIM_VALIDATOR.validateXmlSignature(caCert.getX509Certificate().getPublicKey(),
|
if (RIM_VALIDATOR.validateXmlSignature(caCert.getX509Certificate().getPublicKey(),
|
||||||
caCert.getSubjectKeyIdString(), caCert.getEncodedPublicKey())) {
|
caCert.getSubjectKeyIdString(), caCert.getEncodedPublicKey())) {
|
||||||
@ -272,7 +270,7 @@ public class ReferenceManifestDetailsPageController
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (SupplyChainValidatorException scvEx) {
|
} catch (SupplyChainValidatorException scvEx) {
|
||||||
log.error("Error verifying cert chain: " + scvEx.getMessage());
|
log.error("Error verifying cert chain: {}", scvEx.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,7 +286,7 @@ public class ReferenceManifestDetailsPageController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NullPointerException npEx) {
|
} catch (NullPointerException npEx) {
|
||||||
log.warn("Unable to link signing certificate: " + npEx.getMessage());
|
log.warn("Unable to link signing certificate: {}", npEx.getMessage());
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -610,12 +608,6 @@ public class ReferenceManifestDetailsPageController
|
|||||||
String uuidError = "Failed to parse ID from: " + params.getId();
|
String uuidError = "Failed to parse ID from: " + params.getId();
|
||||||
messages.addError(uuidError);
|
messages.addError(uuidError);
|
||||||
log.error(uuidError, iaEx);
|
log.error(uuidError, iaEx);
|
||||||
} catch (CertificateException cEx) {
|
|
||||||
log.error(cEx);
|
|
||||||
} catch (NoSuchAlgorithmException nsEx) {
|
|
||||||
log.error(nsEx);
|
|
||||||
} catch (IOException ioEx) {
|
|
||||||
log.error(ioEx);
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error(ex);
|
log.error(ex);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import org.springframework.data.domain.Sort;
|
|||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@ -115,10 +116,10 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
|||||||
public DataTableResponse<SupplyChainValidationSummary> getTableData(
|
public DataTableResponse<SupplyChainValidationSummary> getTableData(
|
||||||
final DataTableInput input) {
|
final DataTableInput input) {
|
||||||
|
|
||||||
log.debug("Handling request for summary list: " + input);
|
log.debug("Handling request for summary list: {}", input);
|
||||||
// attempt to get the column property based on the order index.
|
// attempt to get the column property based on the order index.
|
||||||
String orderColumnName = input.getOrderColumnName();
|
String orderColumnName = input.getOrderColumnName();
|
||||||
log.debug("Ordering on column: " + orderColumnName);
|
log.debug("Ordering on column: {}", orderColumnName);
|
||||||
|
|
||||||
FilteredRecordsList<SupplyChainValidationSummary> records = new FilteredRecordsList<>();
|
FilteredRecordsList<SupplyChainValidationSummary> records = new FilteredRecordsList<>();
|
||||||
int currentPage = input.getStart() / input.getLength();
|
int currentPage = input.getStart() / input.getLength();
|
||||||
@ -145,8 +146,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
|||||||
* @param response object
|
* @param response object
|
||||||
* @throws IOException thrown by BufferedWriter object
|
* @throws IOException thrown by BufferedWriter object
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"checkstyle:magicnumber", "checkstyle:methodlength"})
|
@PostMapping(value = "download")
|
||||||
@RequestMapping(value = "download", method = RequestMethod.POST)
|
|
||||||
public void download(final HttpServletRequest request,
|
public void download(final HttpServletRequest request,
|
||||||
final HttpServletResponse response) throws IOException {
|
final HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
|||||||
DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss");
|
DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss");
|
||||||
LocalDate startDate = null;
|
LocalDate startDate = null;
|
||||||
LocalDate endDate = null;
|
LocalDate endDate = null;
|
||||||
ArrayList<LocalDate> createTimes = new ArrayList<LocalDate>();
|
ArrayList<LocalDate> createTimes = new ArrayList<>();
|
||||||
String[] deviceNames = new String[] {};
|
String[] deviceNames = new String[] {};
|
||||||
String columnHeaders = "";
|
String columnHeaders = "";
|
||||||
boolean systemOnly = false;
|
boolean systemOnly = false;
|
||||||
@ -171,7 +171,7 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
|||||||
while (parameters.hasMoreElements()) {
|
while (parameters.hasMoreElements()) {
|
||||||
String parameter = (String) parameters.nextElement();
|
String parameter = (String) parameters.nextElement();
|
||||||
String parameterValue = request.getParameter(parameter);
|
String parameterValue = request.getParameter(parameter);
|
||||||
log.info(parameter + ": " + parameterValue);
|
log.info("{}: {}", parameter, parameterValue);
|
||||||
switch (parameter) {
|
switch (parameter) {
|
||||||
case "company":
|
case "company":
|
||||||
Matcher companyMatcher = pattern.matcher(parameterValue);
|
Matcher companyMatcher = pattern.matcher(parameterValue);
|
||||||
@ -335,7 +335,6 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
|||||||
* @param contractNumber contract number.
|
* @param contractNumber contract number.
|
||||||
* @return the JSON object in String format.
|
* @return the JSON object in String format.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"checkstyle:magicnumber"})
|
|
||||||
private JsonObject assembleJsonContent(final PlatformCredential pc,
|
private JsonObject assembleJsonContent(final PlatformCredential pc,
|
||||||
final ArrayList<ArrayList<String>> parsedComponents,
|
final ArrayList<ArrayList<String>> parsedComponents,
|
||||||
final String company,
|
final String company,
|
||||||
@ -384,19 +383,19 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
|||||||
* @return the ArrayList of ArrayLists containing the parsed component data.
|
* @return the ArrayList of ArrayLists containing the parsed component data.
|
||||||
*/
|
*/
|
||||||
private ArrayList<ArrayList<String>> parseComponents(final PlatformCredential pc) {
|
private ArrayList<ArrayList<String>> parseComponents(final PlatformCredential pc) {
|
||||||
ArrayList<ArrayList<String>> parsedComponents = new ArrayList<ArrayList<String>>();
|
ArrayList<ArrayList<String>> parsedComponents = new ArrayList<>();
|
||||||
ArrayList<ArrayList<Object>> chainComponents = new ArrayList<>();
|
ArrayList<ArrayList<Object>> chainComponents = new ArrayList<>();
|
||||||
|
|
||||||
StringBuilder componentFailureString = new StringBuilder();
|
StringBuilder componentFailureString = new StringBuilder();
|
||||||
if (pc.getComponentIdentifiers() != null
|
if (pc.getComponentIdentifiers() != null
|
||||||
&& pc.getComponentIdentifiers().size() > 0) {
|
&& !pc.getComponentIdentifiers().isEmpty()) {
|
||||||
componentFailureString.append(pc.getComponentFailures());
|
componentFailureString.append(pc.getComponentFailures());
|
||||||
// get all the certificates associated with the platform serial
|
// get all the certificates associated with the platform serial
|
||||||
List<PlatformCredential> chainCertificates =
|
List<PlatformCredential> chainCertificates =
|
||||||
certificateRepository.byBoardSerialNumber(pc.getPlatformSerial());
|
certificateRepository.byBoardSerialNumber(pc.getPlatformSerial());
|
||||||
// combine all components in each certificate
|
// combine all components in each certificate
|
||||||
for (ComponentIdentifier ci : pc.getComponentIdentifiers()) {
|
for (ComponentIdentifier ci : pc.getComponentIdentifiers()) {
|
||||||
ArrayList<Object> issuerAndComponent = new ArrayList<Object>();
|
ArrayList<Object> issuerAndComponent = new ArrayList<>();
|
||||||
issuerAndComponent.add(pc.getHolderIssuer());
|
issuerAndComponent.add(pc.getHolderIssuer());
|
||||||
issuerAndComponent.add(ci);
|
issuerAndComponent.add(ci);
|
||||||
chainComponents.add(issuerAndComponent);
|
chainComponents.add(issuerAndComponent);
|
||||||
@ -406,16 +405,16 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
|||||||
componentFailureString.append(cert.getComponentFailures());
|
componentFailureString.append(cert.getComponentFailures());
|
||||||
if (!cert.isPlatformBase()) {
|
if (!cert.isPlatformBase()) {
|
||||||
for (ComponentIdentifier ci : cert.getComponentIdentifiers()) {
|
for (ComponentIdentifier ci : cert.getComponentIdentifiers()) {
|
||||||
ArrayList<Object> issuerAndComponent = new ArrayList<Object>();
|
ArrayList<Object> issuerAndComponent = new ArrayList<>();
|
||||||
issuerAndComponent.add(cert.getHolderIssuer());
|
issuerAndComponent.add(cert.getHolderIssuer());
|
||||||
issuerAndComponent.add(ci);
|
issuerAndComponent.add(ci);
|
||||||
chainComponents.add(issuerAndComponent);
|
chainComponents.add(issuerAndComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("Component failures: " + componentFailureString);
|
log.info("Component failures: {}", componentFailureString);
|
||||||
for (ArrayList<Object> issuerAndComponent : chainComponents) {
|
for (ArrayList<Object> issuerAndComponent : chainComponents) {
|
||||||
ArrayList<String> componentData = new ArrayList<String>();
|
ArrayList<String> componentData = new ArrayList<>();
|
||||||
String issuer = (String) issuerAndComponent.get(0);
|
String issuer = (String) issuerAndComponent.get(0);
|
||||||
issuer = issuer.replaceAll(",", " ");
|
issuer = issuer.replaceAll(",", " ");
|
||||||
ComponentIdentifier ci = (ComponentIdentifier) issuerAndComponent.get(1);
|
ComponentIdentifier ci = (ComponentIdentifier) issuerAndComponent.get(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user