Merge pull request #6055 from kellykelly3/1489-cleanup-cvt-messagenode

6527: Cleaned up MessageNode createSheet to remove dup values
This commit is contained in:
Richard Cordovano 2020-07-08 13:05:08 -04:00 committed by GitHub
commit acf6bc634d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 42 deletions

View File

@ -17,7 +17,7 @@ ContactsViewer_columnHeader_Phone=Phone
ContactsViewer_noContacts_message=<No contacts found for selected account> ContactsViewer_noContacts_message=<No contacts found for selected account>
ContactsViewer_tabTitle=Contacts ContactsViewer_tabTitle=Contacts
MediaViewer_Name=Media Attachments MediaViewer_Name=Media Attachments
MessageNode_Node_Property_Attms=Attachments MessageNode_Node_Property_Attms=Attachment Count
MessageNode_Node_Property_Date=Date MessageNode_Node_Property_Date=Date
MessageNode_Node_Property_From=From MessageNode_Node_Property_From=From
MessageNode_Node_Property_Subject=Subject MessageNode_Node_Property_Subject=Subject

View File

@ -73,12 +73,12 @@ class MessageNode extends BlackboardArtifactNode {
"MessageNode_Node_Property_To=To", "MessageNode_Node_Property_To=To",
"MessageNode_Node_Property_Date=Date", "MessageNode_Node_Property_Date=Date",
"MessageNode_Node_Property_Subject=Subject", "MessageNode_Node_Property_Subject=Subject",
"MessageNode_Node_Property_Attms=Attachments" "MessageNode_Node_Property_Attms=Attachment Count"
}) })
@Override @Override
protected Sheet createSheet() { protected Sheet createSheet() {
Sheet sheet = super.createSheet(); Sheet sheet = Sheet.createDefault();
Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES); Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
if (sheetSet == null) { if (sheetSet == null) {
sheetSet = Sheet.createPropertiesSet(); sheetSet = Sheet.createPropertiesSet();
@ -90,13 +90,14 @@ class MessageNode extends BlackboardArtifactNode {
final BlackboardArtifact artifact = getArtifact(); final BlackboardArtifact artifact = getArtifact();
BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID()); BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
if(fromID == null || if (fromID == null
(fromID != TSK_EMAIL_MSG && || (fromID != TSK_EMAIL_MSG
fromID != TSK_MESSAGE)) { && fromID != TSK_MESSAGE)) {
return sheet; return sheet;
} }
if (threadID != null) {
sheetSet.put(new NodeProperty<>("ThreadID", "ThreadID","",threadID == null ? UNTHREADED_ID : threadID)); //NON-NLS sheetSet.put(new NodeProperty<>("ThreadID", "ThreadID", "", threadID)); //NON-NLS
}
sheetSet.put(new NodeProperty<>("Subject", Bundle.MessageNode_Node_Property_Subject(), "", sheetSet.put(new NodeProperty<>("Subject", Bundle.MessageNode_Node_Property_Subject(), "",
getAttributeDisplayString(artifact, TSK_SUBJECT))); //NON-NLS getAttributeDisplayString(artifact, TSK_SUBJECT))); //NON-NLS
try { try {
@ -105,26 +106,28 @@ class MessageNode extends BlackboardArtifactNode {
logger.log(Level.WARNING, "Error loading attachment count for " + artifact, ex); //NON-NLS logger.log(Level.WARNING, "Error loading attachment count for " + artifact, ex); //NON-NLS
} }
switch (fromID) { String msg_from = getAttributeDisplayString(artifact, TSK_EMAIL_FROM);
case TSK_EMAIL_MSG: String msg_to = getAttributeDisplayString(artifact, TSK_EMAIL_TO);
sheetSet.put(new NodeProperty<>("From", Bundle.MessageNode_Node_Property_From(), "", String date = getAttributeDisplayString(artifact, TSK_DATETIME_SENT);
StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM), " \t\n;"))); //NON-NLS
sheetSet.put(new NodeProperty<>("To", Bundle.MessageNode_Node_Property_To(), "", if (msg_from.isEmpty()) {
StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO), " \t\n;"))); //NON-NLS msg_from = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM);
sheetSet.put(new NodeProperty<>("Date", Bundle.MessageNode_Node_Property_Date(), "",
getAttributeDisplayString(artifact, TSK_DATETIME_SENT))); //NON-NLS
break;
case TSK_MESSAGE:
sheetSet.put(new NodeProperty<>("From", Bundle.MessageNode_Node_Property_From(), "",
getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM))); //NON-NLS
sheetSet.put(new NodeProperty<>("To", Bundle.MessageNode_Node_Property_To(), "",
getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO))); //NON-NLS
sheetSet.put(new NodeProperty<>("Date", Bundle.MessageNode_Node_Property_Date(), "",
getAttributeDisplayString(artifact, TSK_DATETIME))); //NON-NLS
break;
default:
break;
} }
if (msg_to.isEmpty()) {
msg_to = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO);
}
if (date.isEmpty()) {
date = getAttributeDisplayString(artifact, TSK_DATETIME);
}
sheetSet.put(new NodeProperty<>("From", Bundle.MessageNode_Node_Property_From(), "",
msg_from)); //NON-NLS
sheetSet.put(new NodeProperty<>("To", Bundle.MessageNode_Node_Property_To(), "",
msg_to)); //NON-NLS
sheetSet.put(new NodeProperty<>("Date", Bundle.MessageNode_Node_Property_Date(), "",
date)); //NON-NLS
return sheet; return sheet;
} }
@ -158,8 +161,7 @@ class MessageNode extends BlackboardArtifactNode {
try { try {
MessageAttachments msgAttachments = BlackboardJsonAttrUtil.fromAttribute(attachmentsAttr, MessageAttachments.class); MessageAttachments msgAttachments = BlackboardJsonAttrUtil.fromAttribute(attachmentsAttr, MessageAttachments.class);
return msgAttachments.getAttachmentsCount(); return msgAttachments.getAttachmentsCount();
} } catch (BlackboardJsonAttrUtil.InvalidJsonException ex) {
catch (BlackboardJsonAttrUtil.InvalidJsonException ex) {
logger.log(Level.WARNING, String.format("Unable to parse json for MessageAttachments object in artifact: %s", artifact.getName()), ex); logger.log(Level.WARNING, String.format("Unable to parse json for MessageAttachments object in artifact: %s", artifact.getName()), ex);
return 0; return 0;
} }