Return a list of correlation artifacts when converting a blackboard artifact to capture more attributes

This commit is contained in:
Maxwell Koo 2017-06-29 12:22:26 -04:00
parent 1e4a790d00
commit d152d7a008
4 changed files with 33 additions and 31 deletions

View File

@ -358,8 +358,7 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
/** /**
* Scan a Node for blackboard artifacts / content that we can correlate on * Scan a Node for blackboard artifacts / content that we can correlate on
* and create the corresponding Central Repository artifacts for * and create the corresponding Central Repository artifacts for display
* display
* *
* @param node The node to view * @param node The node to view
* *
@ -380,10 +379,7 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
EamDb dbManager = EamDb.getInstance(); EamDb dbManager = EamDb.getInstance();
artifactTypes = dbManager.getCorrelationTypes(); artifactTypes = dbManager.getCorrelationTypes();
if (bbArtifact != null) { if (bbArtifact != null) {
EamArtifact eamArtifact = EamArtifactUtil.fromBlackboardArtifact(bbArtifact, false, artifactTypes, false); ret.addAll(EamArtifactUtil.fromBlackboardArtifact(bbArtifact, false, artifactTypes, false));
if (eamArtifact != null) {
ret.add(eamArtifact);
}
} }
} catch (EamDbException ex) { } catch (EamDbException ex) {
LOGGER.log(Level.SEVERE, "Error retrieving correlation types", ex); // NON-NLS LOGGER.log(Level.SEVERE, "Error retrieving correlation types", ex); // NON-NLS
@ -475,8 +471,8 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
* *
* @param eamArtifact Artifact to use for ArtifactTypeEnum matching * @param eamArtifact Artifact to use for ArtifactTypeEnum matching
* *
* @return List of Central Repository Artifact Instances, empty * @return List of Central Repository Artifact Instances, empty list if none
* list if none found * found
*/ */
public Collection<EamArtifactInstance> getReferenceInstancesAsArtifactInstances(EamArtifact eamArtifact) { public Collection<EamArtifactInstance> getReferenceInstancesAsArtifactInstances(EamArtifact eamArtifact) {
Collection<EamArtifactInstance> eamArtifactInstances = new ArrayList<>(); Collection<EamArtifactInstance> eamArtifactInstances = new ArrayList<>();

View File

@ -18,6 +18,7 @@
*/ */
package org.sleuthkit.autopsy.centralrepository.datamodel; package org.sleuthkit.autopsy.centralrepository.datamodel;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
@ -46,31 +47,32 @@ public class EamArtifactUtil {
return Bundle.EamArtifactUtil_emailaddresses_text(); return Bundle.EamArtifactUtil_emailaddresses_text();
} }
/* /**
* Static factory method to examine a BlackboardArtifact to determine if it * Static factory method to examine a BlackboardArtifact to determine if it
* has contents that can be used for Correlation. If so, return a * has contents that can be used for Correlation. If so, return a
* EamArtifact with a single EamArtifactInstance within. If not, return * EamArtifact with a single EamArtifactInstance within. If not, return
* null. * null.
* *
* @param bbArtifact BlackboardArtifact to examine @return EamArtifact or * @param bbArtifact BlackboardArtifact to examine
* null * @return List of EamArtifacts
*/ */
public static EamArtifact fromBlackboardArtifact(BlackboardArtifact bbArtifact, public static List<EamArtifact> fromBlackboardArtifact(BlackboardArtifact bbArtifact,
boolean includeInstances, boolean includeInstances,
List<EamArtifact.Type> artifactTypes, List<EamArtifact.Type> artifactTypes,
boolean checkEnabled) { boolean checkEnabled) {
EamArtifact eamArtifact = null; List<EamArtifact> eamArtifacts = new ArrayList<>();
for (EamArtifact.Type aType : artifactTypes) { for (EamArtifact.Type aType : artifactTypes) {
if ((checkEnabled && aType.isEnabled()) || !checkEnabled) { if ((checkEnabled && aType.isEnabled()) || !checkEnabled) {
eamArtifact = getTypeFromBlackboardArtifact(aType, bbArtifact); EamArtifact eamArtifact = getTypeFromBlackboardArtifact(aType, bbArtifact);
if (eamArtifact != null) {
eamArtifacts.add(eamArtifact);
} }
if (null != eamArtifact) {
break;
} }
} }
if (null != eamArtifact && includeInstances) { if (!eamArtifacts.isEmpty() && includeInstances) {
try { try {
AbstractFile af = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(bbArtifact.getObjectID()); AbstractFile af = Case.getCurrentCase().getSleuthkitCase().getAbstractFileById(bbArtifact.getObjectID());
if (null == af) { if (null == af) {
@ -92,14 +94,17 @@ public class EamArtifactUtil {
TskData.FileKnown.UNKNOWN, TskData.FileKnown.UNKNOWN,
EamArtifactInstance.GlobalStatus.LOCAL EamArtifactInstance.GlobalStatus.LOCAL
); );
for (EamArtifact eamArtifact : eamArtifacts) {
eamArtifact.addInstance(eamInstance); eamArtifact.addInstance(eamInstance);
}
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
LOGGER.log(Level.SEVERE, "Error creating artifact instance.", ex); // NON-NLS LOGGER.log(Level.SEVERE, "Error creating artifact instance.", ex); // NON-NLS
return null; return null;
} }
} }
return eamArtifact; return eamArtifacts;
} }
/** /**

View File

@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.centralrepository.eventlisteners;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
@ -142,8 +143,8 @@ public class CaseEventListener implements PropertyChangeListener {
if (dbManager.getBadTags().contains(tagName.getDisplayName())) { if (dbManager.getBadTags().contains(tagName.getDisplayName())) {
try { try {
EamArtifact eamArtifact = EamArtifactUtil.fromBlackboardArtifact(bbArtifact, true, dbManager.getCorrelationTypes(), true); List<EamArtifact> convertedArtifacts = EamArtifactUtil.fromBlackboardArtifact(bbArtifact, true, dbManager.getCorrelationTypes(), true);
if (null != eamArtifact) { for (EamArtifact eamArtifact : convertedArtifacts) {
eamArtifact.getInstances().get(0).setComment(bbTagAdded.getComment()); eamArtifact.getInstances().get(0).setComment(bbTagAdded.getComment());
Runnable r = new BadFileTagRunner(eamArtifact); Runnable r = new BadFileTagRunner(eamArtifact);
// TODO: send r into a thread pool instead // TODO: send r into a thread pool instead

View File

@ -44,7 +44,8 @@ import org.sleuthkit.datamodel.TskCoreException;
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb; import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
/** /**
* Listen for ingest events and update entries in the Central Repository database accordingly * Listen for ingest events and update entries in the Central Repository
* database accordingly
*/ */
public class IngestEventsListener { public class IngestEventsListener {
@ -92,9 +93,8 @@ public class IngestEventsListener {
try { try {
for (BlackboardArtifact bbArtifact : bbArtifacts) { for (BlackboardArtifact bbArtifact : bbArtifacts) {
// eamArtifact will be null OR a EamArtifact containing one EamArtifactInstance. // eamArtifact will be null OR a EamArtifact containing one EamArtifactInstance.
EamArtifact eamArtifact = EamArtifactUtil.fromBlackboardArtifact(bbArtifact, true, dbManager.getCorrelationTypes(), true); List<EamArtifact> convertedArtifacts = EamArtifactUtil.fromBlackboardArtifact(bbArtifact, true, dbManager.getCorrelationTypes(), true);
if (null != eamArtifact) { for (EamArtifact eamArtifact : convertedArtifacts) {
try { try {
// Only do something with this artifact if it's unique within the job // Only do something with this artifact if it's unique within the job
if (addedCeArtifactTrackerSet.add(eamArtifact.toString())) { if (addedCeArtifactTrackerSet.add(eamArtifact.toString())) {