Merge pull request #5233 from kellykelly3/1335-vcard-dups

1335 & 1354 vcard dups
This commit is contained in:
Richard Cordovano 2019-09-24 11:30:45 -04:00 committed by GitHub
commit 0954245106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 77 additions and 74 deletions

View File

@ -18,9 +18,8 @@
*/ */
package org.sleuthkit.autopsy.communications.relationships; package org.sleuthkit.autopsy.communications.relationships;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.logging.Level; import java.util.logging.Level;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
@ -89,30 +88,30 @@ final class ContactNode extends BlackboardArtifactNode {
// are used so that all attributed of that type are found, including // are used so that all attributed of that type are found, including
// ones that are not predefined as part of BlackboardAttributes // ones that are not predefined as part of BlackboardAttributes
try { try {
HashMap<String, BlackboardAttribute> phoneNumMap = new HashMap<>(); List<BlackboardAttribute> phoneNumList = new ArrayList<>();
HashMap<String, BlackboardAttribute> emailMap = new HashMap<>(); List<BlackboardAttribute> emailList = new ArrayList<>();
HashMap<String, BlackboardAttribute> nameMap = new HashMap<>(); List<BlackboardAttribute> nameList = new ArrayList<>();
HashMap<String, BlackboardAttribute> otherMap = new HashMap<>(); List<BlackboardAttribute> otherList = new ArrayList<>();
for (BlackboardAttribute bba : artifact.getAttributes()) { for (BlackboardAttribute bba : artifact.getAttributes()) {
if (bba.getAttributeType().getTypeName().startsWith("TSK_PHONE")) { if (bba.getAttributeType().getTypeName().startsWith("TSK_PHONE")) {
phoneNumMap.put(bba.getDisplayString(), bba); phoneNumList.add(bba);
} else if (bba.getAttributeType().getTypeName().startsWith("TSK_EMAIL")) { } else if (bba.getAttributeType().getTypeName().startsWith("TSK_EMAIL")) {
emailMap.put(bba.getDisplayString(), bba); emailList.add(bba);
} else if (bba.getAttributeType().getTypeName().startsWith("TSK_NAME")) { } else if (bba.getAttributeType().getTypeName().startsWith("TSK_NAME")) {
nameMap.put(bba.getDisplayString(), bba); nameList.add(bba);
} else { } else {
otherMap.put(bba.getDisplayString(), bba); otherList.add(bba);
} }
} }
addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getLabel(), addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getLabel(),
sheetSet, nameMap); sheetSet, nameList);
addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getLabel(), addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getLabel(),
sheetSet, phoneNumMap); sheetSet, phoneNumList);
addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getLabel(), addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getLabel(),
sheetSet, emailMap); sheetSet, emailList);
for (BlackboardAttribute bba : otherMap.values()) { for (BlackboardAttribute bba : otherList) {
sheetSet.put(new NodeProperty<>(bba.getAttributeType().getTypeName(), bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); sheetSet.put(new NodeProperty<>(bba.getAttributeType().getTypeName(), bba.getAttributeType().getDisplayName(), "", bba.getDisplayString()));
} }
@ -138,9 +137,9 @@ final class ContactNode extends BlackboardArtifactNode {
return sheet; return sheet;
} }
private void addPropertiesToSheet(String propertyID, Sheet.Set sheetSet, Map<String, BlackboardAttribute> attributeMap) { private void addPropertiesToSheet(String propertyID, Sheet.Set sheetSet, List<BlackboardAttribute> attributeList) {
int count = 0; int count = 0;
for (BlackboardAttribute bba : attributeMap.values()) { for (BlackboardAttribute bba : attributeList) {
if (count++ > 0) { if (count++ > 0) {
sheetSet.put(new NodeProperty<>(propertyID + "_" + count, bba.getAttributeType().getDisplayName(), "", bba.getDisplayString())); sheetSet.put(new NodeProperty<>(propertyID + "_" + count, bba.getAttributeType().getDisplayName(), "", bba.getDisplayString()));
} else { } else {

View File

@ -1,3 +1,4 @@
MboxParser.handleAttch.noOpenCase.errMsg=Exception while getting open case.
MimeJ4MessageParser.handleAttch.noOpenCase.errMsg=Exception while getting open case. MimeJ4MessageParser.handleAttch.noOpenCase.errMsg=Exception while getting open case.
OpenIDE-Module-Display-Category=Ingest Module OpenIDE-Module-Display-Category=Ingest Module
OpenIDE-Module-Long-Description=Email Parser ingest module.\n\nThe module extracts MBOX and PST e-mail files and posts the results to the blackboard.\nIt knows about the Thunderbird folder structure for MBOX files. OpenIDE-Module-Long-Description=Email Parser ingest module.\n\nThe module extracts MBOX and PST e-mail files and posts the results to the blackboard.\nIt knows about the Thunderbird folder structure for MBOX files.

View File

@ -399,7 +399,7 @@ final class VcardParser {
if (telephoneTypes.isEmpty()) { if (telephoneTypes.isEmpty()) {
ThunderbirdMboxFileIngestModule.addArtifactAttribute(telephone.getText(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, attributes); ThunderbirdMboxFileIngestModule.addArtifactAttribute(telephone.getText(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER, attributes);
} else { } else {
for (TelephoneType type : telephoneTypes) { TelephoneType type = telephoneTypes.get(0);
/* /*
* Unfortunately, if the types are lower-case, they don't * Unfortunately, if the types are lower-case, they don't
* get separated correctly into individual TelephoneTypes by * get separated correctly into individual TelephoneTypes by
@ -409,27 +409,28 @@ final class VcardParser {
List<String> splitTelephoneTypes = Arrays.asList( List<String> splitTelephoneTypes = Arrays.asList(
type.getValue().toUpperCase().replaceAll("\\s+","").split(",")); type.getValue().toUpperCase().replaceAll("\\s+","").split(","));
for (String splitType : splitTelephoneTypes) { if (splitTelephoneTypes.size() > 0) {
String splitType = splitTelephoneTypes.get(0);
String attributeTypeName = "TSK_PHONE_NUMBER"; String attributeTypeName = "TSK_PHONE_NUMBER";
if(splitType != null && !splitType.isEmpty()) { if (splitType != null && !splitType.isEmpty()) {
attributeTypeName = "TSK_PHONE_NUMBER_" + splitType; attributeTypeName = "TSK_PHONE_NUMBER_" + splitType;
} }
try { try {
BlackboardAttribute.Type attributeType = tskCase.getAttributeType(attributeTypeName); BlackboardAttribute.Type attributeType = tskCase.getAttributeType(attributeTypeName);
if (attributeType == null) { if (attributeType == null) {
try{
// Add this attribute type to the case database. // Add this attribute type to the case database.
attributeType = tskCase.addArtifactAttributeType(attributeTypeName, attributeType = tskCase.addArtifactAttributeType(attributeTypeName,
BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.STRING, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.STRING,
String.format("Phone Number (%s)", StringUtils.capitalize(splitType.toLowerCase()))); String.format("Phone Number (%s)", StringUtils.capitalize(splitType.toLowerCase())));
}catch (TskDataException ex) {
attributeType = tskCase.getAttributeType(attributeTypeName);
}
} }
ThunderbirdMboxFileIngestModule.addArtifactAttribute(telephoneText, attributeType, attributes); ThunderbirdMboxFileIngestModule.addArtifactAttribute(telephoneText, attributeType, attributes);
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.WARNING, String.format("Unable to retrieve attribute type '%s' for file '%s' (id=%d).", attributeTypeName, abstractFile.getName(), abstractFile.getId()), ex); logger.log(Level.WARNING, String.format("Unable to retrieve attribute type '%s' for file '%s' (id=%d).", attributeTypeName, abstractFile.getName(), abstractFile.getId()), ex);
} catch (TskDataException ex) {
logger.log(Level.WARNING, String.format("Unable to add custom attribute type '%s' for file '%s' (id=%d).", attributeTypeName, abstractFile.getName(), abstractFile.getId()), ex);
}
} }
} }
} }
@ -454,8 +455,7 @@ final class VcardParser {
if (emailTypes.isEmpty()) { if (emailTypes.isEmpty()) {
ThunderbirdMboxFileIngestModule.addArtifactAttribute(email.getValue(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL, attributes); ThunderbirdMboxFileIngestModule.addArtifactAttribute(email.getValue(), BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL, attributes);
} else { } else {
for (EmailType type : emailTypes) { EmailType type = emailTypes.get(0); /*
/*
* Unfortunately, if the types are lower-case, they don't * Unfortunately, if the types are lower-case, they don't
* get separated correctly into individual EmailTypes by * get separated correctly into individual EmailTypes by
* ez-vcard. Therefore, we must read them manually * ez-vcard. Therefore, we must read them manually
@ -464,8 +464,12 @@ final class VcardParser {
List<String> splitEmailTypes = Arrays.asList( List<String> splitEmailTypes = Arrays.asList(
type.getValue().toUpperCase().replaceAll("\\s+","").split(",")); type.getValue().toUpperCase().replaceAll("\\s+","").split(","));
for (String splitType : splitEmailTypes) { if (splitEmailTypes.size() > 0) {
String splitType = splitEmailTypes.get(0);
String attributeTypeName = "TSK_EMAIL_" + splitType; String attributeTypeName = "TSK_EMAIL_" + splitType;
if(splitType.isEmpty()) {
attributeTypeName = "TSK_EMAIL";
}
try { try {
BlackboardAttribute.Type attributeType = tskCase.getAttributeType(attributeTypeName); BlackboardAttribute.Type attributeType = tskCase.getAttributeType(attributeTypeName);
if (attributeType == null) { if (attributeType == null) {
@ -483,7 +487,6 @@ final class VcardParser {
} }
} }
} }
}
/** /**
* Generate account instances for a given VCard Telephone object. * Generate account instances for a given VCard Telephone object.