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

Update lambdas to not index files with metadata security classification #100

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -175,24 +175,41 @@ public String handleRequest(Map<String, Object> event, Context context) {
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);

OpenSearchRESTClient restClient = new OpenSearchRESTClient();
restClient.addIndex(content, fileName, fileDetailsJson, scanStatus);
// Push ID onto SQS for clamAV
logger.log("\nInfo: File parsing complete. Schedule ClamAV scan.");

// update metadata
boolean metaAdded = GetFileFromWFDMAPI.setIndexedMetadata(wfdmToken, fileId, versionNumber, fileDetailsJson);
if (!metaAdded) {
// We failed to apply the metadata regarding the virus scan status...
// Should we continue to process the data from this point, or just choke?
logger.log("\nERROR: Failed to add metadata to file resource");

// We are disabling indexing of files with a security classification of Protected B or Protected C
JSONArray metaArray = fileDetailsJson.getJSONArray("metadata");
boolean skipIndexing = false;
for (int i = 0; i < metaArray.length(); i++) {
String metadataName = metaArray.getJSONObject(i).getString("metadataName");
String metadataValue = metaArray.getJSONObject(i).getString("metadataValue");

if (metadataName.equals("SecurityClassification")
&& (metadataValue.equals("Protected B") || metadataValue.equals("Protected C"))) {
skipIndexing = true;
}
}

// after updating metadata, get file info again and update index
fileInfo = GetFileFromWFDMAPI.getFileInformation(wfdmToken, fileId);
fileDetailsJson = new JSONObject(fileInfo);
if (!skipIndexing) {

restClient.addIndex(content, fileName, fileDetailsJson, scanStatus);
restClient.addIndex(content, fileName, fileDetailsJson, scanStatus);
// Push ID onto SQS for clamAV
logger.log("\nInfo: File parsing complete. Schedule ClamAV scan.");

// update metadata
boolean metaAdded = GetFileFromWFDMAPI.setIndexedMetadata(wfdmToken, fileId, versionNumber, fileDetailsJson);
if (!metaAdded) {
// We failed to apply the metadata regarding the virus scan status...
// Should we continue to process the data from this point, or just choke?
logger.log("\nERROR: Failed to add metadata to file resource");
}

// after updating metadata, get file info again and update index
fileInfo = GetFileFromWFDMAPI.getFileInformation(wfdmToken, fileId);
fileDetailsJson = new JSONObject(fileInfo);

restClient.addIndex(content, fileName, fileDetailsJson, scanStatus);

}
}
} catch (UnirestException | TransformerConfigurationException | SAXException e) {
logger.log("\nError: Failure to recieve file from WFDM" + e.getLocalizedMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static String parseStream(InputStream stream, String mimeType)
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
case "application/vnd.ms-excel.sheet.macroEnabled.12":
case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
parser = new OOXMLParser();
break;
case "application/pdf":
Expand Down
Loading