LAst clean up before PR

This commit is contained in:
Kelly Kelly 2019-05-30 11:06:20 -04:00
parent 6c86618505
commit 3ea254c7ae
3 changed files with 53 additions and 11 deletions

View File

@ -50,6 +50,7 @@ class EmailMessage {
private List<String> references = null; private List<String> references = null;
private String simplifiedSubject = ""; private String simplifiedSubject = "";
private boolean isReplySubject = false; private boolean isReplySubject = false;
private String messageThreadID = "";
boolean hasAttachment() { boolean hasAttachment() {
return hasAttachment; return hasAttachment;
@ -266,6 +267,24 @@ class EmailMessage {
void setReferences(List<String> references) { void setReferences(List<String> references) {
this.references = references; this.references = references;
} }
/**
* Sets the ThreadID of this message.
*
* @param threadID - the thread ID to set
*/
void setMessageThreadID(String threadID) {
this.messageThreadID = threadID;
}
/**
* Returns the ThreadID for this message.
*
* @return - the message thread ID or "" is non is available
*/
String getMessageThreadID() {
return this.messageThreadID;
}
/** /**
* A Record to hold generic information about attachments. * A Record to hold generic information about attachments.

View File

@ -39,7 +39,7 @@ final class EmailMessageThreader {
private int bogus_id_count = 0; private int bogus_id_count = 0;
public Set<Container> threadMessages(List<EmailMessage> emailMessages) { public void threadMessages(List<EmailMessage> emailMessages, String threadIDPrefix) {
HashMap<String, Container> id_table = createIDTable(emailMessages); HashMap<String, Container> id_table = createIDTable(emailMessages);
Set<Container> rootSet = getRootSet(id_table); Set<Container> rootSet = getRootSet(id_table);
@ -47,9 +47,7 @@ final class EmailMessageThreader {
Set<Container> finalSet = groupBySubject(rootSet); Set<Container> finalSet = groupBySubject(rootSet);
printContainerSet(finalSet, ""); assignThreadIDs(finalSet, threadIDPrefix);
return finalSet;
} }
/** /**
@ -59,7 +57,7 @@ final class EmailMessageThreader {
* *
* @param emailMessages * @param emailMessages
* *
* @return * @return - HashMap of all message where the key is the message-ID of the message
*/ */
private HashMap<String, Container> createIDTable(List<EmailMessage> emailMessages) { private HashMap<String, Container> createIDTable(List<EmailMessage> emailMessages) {
HashMap<String, Container> id_table = new HashMap<>(); HashMap<String, Container> id_table = new HashMap<>();
@ -197,7 +195,6 @@ final class EmailMessageThreader {
Set<Container> containersToRemove = new HashSet<>(); Set<Container> containersToRemove = new HashSet<>();
containerSet.forEach((container) -> { containerSet.forEach((container) -> {
if (!container.hasMessage() && !container.hasChildren()) { if (!container.hasMessage() && !container.hasChildren()) {
// containerSet.remove(container);
containersToRemove.add(container); containersToRemove.add(container);
} else { } else {
pruneChildren(container); pruneChildren(container);
@ -229,8 +226,6 @@ final class EmailMessageThreader {
Set<Container> add = new HashSet<>(); Set<Container> add = new HashSet<>();
for (Container child : parent.getChildren()) { for (Container child : parent.getChildren()) {
if (pruneChildren(child)) { if (pruneChildren(child)) {
// parent.addChildren(child.getChildren());
// parent.removeChild(child);
remove.add(child); remove.add(child);
add.addAll(child.getChildren()); add.addAll(child.getChildren());
child.setParent(null); child.setParent(null);
@ -243,9 +238,9 @@ final class EmailMessageThreader {
parent.removeChildren(remove); parent.removeChildren(remove);
if (!parent.hasMessage() && grandParent != null) { if (!parent.hasMessage() && grandParent != null) {
for (Container child : children) { children.forEach((child) -> {
child.setParent(grandParent); child.setParent(grandParent);
} });
return true; return true;
} }
@ -392,6 +387,32 @@ final class EmailMessageThreader {
return subject_table; return subject_table;
} }
private void assignThreadIDs(Set<Container> containerSet, String IDPrefix) {
int threadCounter = 0;
for(Container container: containerSet) {
String threadID = String.format("%s-%d", IDPrefix, threadCounter++);
addThreadID(container, threadID);
}
}
private void addThreadID(Container container, String threadID) {
if(container == null) {
return;
}
EmailMessage message = container.getMessage();
if(message != null) {
message.setMessageThreadID(threadID);
}
if(container.hasChildren()) {
for(Container child: container.getChildren()) {
addThreadID(child, threadID);
}
}
}
/** /**
* Prints a set of containers and their children. * Prints a set of containers and their children.

View File

@ -411,7 +411,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
List<AbstractFile> derivedFiles = new ArrayList<>(); List<AbstractFile> derivedFiles = new ArrayList<>();
EmailMessageThreader threader = new EmailMessageThreader(); EmailMessageThreader threader = new EmailMessageThreader();
threader.threadMessages(emails); threader.threadMessages(emails, String.format("%d", abstractFile.getId()));
for (EmailMessage email : emails) { for (EmailMessage email : emails) {
BlackboardArtifact msgArtifact = addEmailArtifact(email, abstractFile); BlackboardArtifact msgArtifact = addEmailArtifact(email, abstractFile);
@ -511,6 +511,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
String subject = email.getSubject(); String subject = email.getSubject();
long id = email.getId(); long id = email.getId();
String localPath = email.getLocalPath(); String localPath = email.getLocalPath();
String threadID = email.getMessageThreadID();
List<String> senderAddressList = new ArrayList<>(); List<String> senderAddressList = new ArrayList<>();
String senderAddress; String senderAddress;
@ -568,6 +569,7 @@ public final class ThunderbirdMboxFileIngestModule implements FileIngestModule {
addArtifactAttribute(cc, ATTRIBUTE_TYPE.TSK_EMAIL_CC, bbattributes); addArtifactAttribute(cc, ATTRIBUTE_TYPE.TSK_EMAIL_CC, bbattributes);
addArtifactAttribute(bodyHTML, ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_HTML, bbattributes); addArtifactAttribute(bodyHTML, ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_HTML, bbattributes);
addArtifactAttribute(rtf, ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_RTF, bbattributes); addArtifactAttribute(rtf, ATTRIBUTE_TYPE.TSK_EMAIL_CONTENT_RTF, bbattributes);
addArtifactAttribute(threadID, ATTRIBUTE_TYPE.TSK_THREAD_ID, bbattributes);
try { try {