From f875a2c9819b0f0196e4abbadca3dbc5eb9d65ed Mon Sep 17 00:00:00 2001 From: chubtub <43381989+chubtub@users.noreply.github.com> Date: Thu, 25 Apr 2024 14:45:39 -0400 Subject: [PATCH] Check upload file extensions --- .../ReferenceManifestPageController.java | 31 ++++++++++++++----- .../src/main/webapp/WEB-INF/jsp/error.jsp | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java index 937bb4c9..f584bdaf 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java @@ -62,7 +62,8 @@ import java.util.zip.ZipOutputStream; @RequestMapping("/HIRS_AttestationCAPortal/portal/reference-manifests") public class ReferenceManifestPageController extends PageController { - private static final String LOG_FILE_PATTERN = "([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)"; + private static final String BASE_RIM_FILE_PATTERN = "([^\\s]+(\\.(?i)swidtag)$)"; + private static final String SUPPORT_RIM_FILE_PATTERN = "([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)"; @Autowired(required = false) private EntityManager entityManager; @@ -156,9 +157,11 @@ public class ReferenceManifestPageController extends PageController model = new HashMap<>(); PageMessages messages = new PageMessages(); String fileName; - Pattern logPattern = Pattern.compile(LOG_FILE_PATTERN); + Pattern baseRimPattern = Pattern.compile(BASE_RIM_FILE_PATTERN); + Pattern supportRimPattern = Pattern.compile(SUPPORT_RIM_FILE_PATTERN); Matcher matcher; - boolean supportRIM = false; + boolean isBaseRim = false; + boolean isSupportRim = false; List baseRims = new ArrayList<>(); List supportRims = new ArrayList<>(); log.info(String.format("Processing %s uploaded files", files.length)); @@ -166,11 +169,23 @@ public class ReferenceManifestPageController extends PageController { log.info(String.format("Storing swidtag %s", rim.getFileName())); diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp index bf06bdf4..908cca10 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp @@ -9,7 +9,7 @@ Error - 404 - \ No newline at end of file