19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.lang.ref.WeakReference;
24 import java.util.List;
25 import java.util.logging.Level;
26 import org.openide.util.NbBundle.Messages;
45 class GetSCOTask
implements Runnable {
47 private final WeakReference<AbstractContentNode<?>> weakNodeRef;
48 private final PropertyChangeListener listener;
49 private static final Logger logger = Logger.getLogger(GetSCOTask.class.getName());
51 GetSCOTask(WeakReference<AbstractContentNode<?>> weakContentRef, PropertyChangeListener listener) {
52 this.weakNodeRef = weakContentRef;
53 this.listener = listener;
56 @Messages({
"GetSCOTask.occurrences.defaultDescription=No correlation properties found",
57 "GetSCOTask.occurrences.multipleProperties=Multiple different correlation properties exist for this result"})
60 AbstractContentNode<?> contentNode = weakNodeRef.get();
63 if (contentNode == null || UserPreferences.getHideSCOColumns()) {
67 List<Tag> tags = contentNode.getAllTagsFromDatabase();
69 SCOData scoData =
new SCOData();
70 scoData.setScoreAndDescription(contentNode.getScorePropertyAndDescription(tags));
73 CorrelationAttributeInstance fileAttribute = contentNode.getCorrelationAttributeInstance();
74 scoData.setComment(contentNode.getCommentProperty(tags, fileAttribute));
76 if (EamDb.isEnabled()) {
79 String description = Bundle.GetSCOTask_occurrences_defaultDescription();
80 if (contentNode instanceof BlackboardArtifactNode) {
81 BlackboardArtifact bbArtifact = ((BlackboardArtifactNode) contentNode).getArtifact();
83 if (bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED.getTypeID()
84 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_SUSPECTED.getTypeID()
85 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID()
86 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF.getTypeID()
87 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()
88 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_OBJECT_DETECTED.getTypeID()
89 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EXT_MISMATCH_DETECTED.getTypeID()
90 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()) {
92 if (bbArtifact.getParent() instanceof AbstractFile) {
93 type = CorrelationAttributeInstance.getDefaultCorrelationTypes().get(CorrelationAttributeInstance.FILES_TYPE_ID);
94 value = ((AbstractFile) bbArtifact.getParent()).getMd5Hash();
96 }
catch (TskCoreException | EamDbException ex) {
97 logger.log(Level.WARNING,
"Unable to get correlation type or value to determine value for O column for artifact", ex);
100 List<CorrelationAttributeInstance> listOfPossibleAttributes = EamArtifactUtil.makeInstancesFromBlackboardArtifact(bbArtifact,
false);
101 if (listOfPossibleAttributes.size() > 1) {
103 description = Bundle.GetSCOTask_occurrences_multipleProperties();
104 }
else if (!listOfPossibleAttributes.isEmpty()) {
106 type = listOfPossibleAttributes.get(0).getCorrelationType();
107 value = listOfPossibleAttributes.get(0).getCorrelationValue();
110 }
else if (contentNode.getContent() instanceof AbstractFile) {
113 type = CorrelationAttributeInstance.getDefaultCorrelationTypes().get(CorrelationAttributeInstance.FILES_TYPE_ID);
114 value = ((AbstractFile) contentNode.getContent()).getMd5Hash();
115 }
catch (EamDbException ex) {
116 logger.log(Level.WARNING,
"Unable to get correlation type to determine value for O column for file", ex);
119 scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(type, value, description));
125 listener.propertyChange(
new PropertyChangeEvent(
126 AutopsyEvent.SourceType.LOCAL.toString(),
127 AbstractAbstractFileNode.NodeSpecificEvents.SCO_AVAILABLE.toString(),