mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-30 09:49:00 +00:00
Initial commit, that adds an additional check to the file being uploaded to the rim page to ensure that it is a valid file.
This commit is contained in:
parent
85be3c2fc8
commit
91fbc7cfd2
@ -60,6 +60,7 @@ public class ReferenceManifestPageController
|
|||||||
|
|
||||||
private static final String BIOS_RELEASE_DATE_FORMAT = "yyyy-MM-dd";
|
private static final String BIOS_RELEASE_DATE_FORMAT = "yyyy-MM-dd";
|
||||||
private static final String LOG_FILE_PATTERN = "([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)";
|
private static final String LOG_FILE_PATTERN = "([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)";
|
||||||
|
private static final String SWID_FILE_PATTERN = "([^\\s]+(\\.(?i)(swidtag))$)";
|
||||||
|
|
||||||
private final BiosDateValidator biosValidator;
|
private final BiosDateValidator biosValidator;
|
||||||
private final ReferenceManifestManager referenceManifestManager;
|
private final ReferenceManifestManager referenceManifestManager;
|
||||||
@ -188,18 +189,21 @@ public class ReferenceManifestPageController
|
|||||||
Map<String, Object> model = new HashMap<>();
|
Map<String, Object> model = new HashMap<>();
|
||||||
PageMessages messages = new PageMessages();
|
PageMessages messages = new PageMessages();
|
||||||
String fileName;
|
String fileName;
|
||||||
Pattern pattern;
|
Pattern logPattern = Pattern.compile(LOG_FILE_PATTERN);
|
||||||
|
Pattern swidPattern = Pattern.compile(SWID_FILE_PATTERN);
|
||||||
Matcher matcher;
|
Matcher matcher;
|
||||||
boolean supportRIM = false;
|
boolean supportRIM = false;
|
||||||
|
boolean swidtag = false;
|
||||||
BaseReferenceManifest base;
|
BaseReferenceManifest base;
|
||||||
SupportReferenceManifest support;
|
SupportReferenceManifest support;
|
||||||
|
|
||||||
// loop through the files
|
// loop through the files
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
fileName = file.getOriginalFilename();
|
fileName = file.getOriginalFilename();
|
||||||
pattern = Pattern.compile(LOG_FILE_PATTERN);
|
matcher = logPattern.matcher(fileName);
|
||||||
matcher = pattern.matcher(fileName);
|
|
||||||
supportRIM = matcher.matches();
|
supportRIM = matcher.matches();
|
||||||
|
matcher = swidPattern.matcher(fileName);
|
||||||
|
swidtag = matcher.matches();
|
||||||
|
|
||||||
//Parse reference manifests
|
//Parse reference manifests
|
||||||
ReferenceManifest rim = parseRIM(file, supportRIM, messages);
|
ReferenceManifest rim = parseRIM(file, supportRIM, messages);
|
||||||
@ -223,7 +227,7 @@ public class ReferenceManifestPageController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (swidtag) {
|
||||||
base = (BaseReferenceManifest) rim;
|
base = (BaseReferenceManifest) rim;
|
||||||
|
|
||||||
for (SwidResource swid : base.parseResource()) {
|
for (SwidResource swid : base.parseResource()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user