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) {
68 List<Tag> tags = contentNode.getAllTagsFromDatabase();
69 CorrelationAttributeInstance fileAttribute = contentNode.getCorrelationAttributeInstance();
71 SCOData scoData =
new SCOData();
72 scoData.setScoreAndDescription(contentNode.getScorePropertyAndDescription(tags));
73 scoData.setComment(contentNode.getCommentProperty(tags, fileAttribute));
75 if (EamDb.isEnabled() && !UserPreferences.hideCentralRepoCommentsAndOccurrences()) {
78 String description = Bundle.GetSCOTask_occurrences_defaultDescription();
79 if (contentNode instanceof BlackboardArtifactNode) {
80 BlackboardArtifact bbArtifact = ((BlackboardArtifactNode) contentNode).getArtifact();
82 if (bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_DETECTED.getTypeID()
83 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_ENCRYPTION_SUSPECTED.getTypeID()
84 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID()
85 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF.getTypeID()
86 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()
87 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_OBJECT_DETECTED.getTypeID()
88 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_EXT_MISMATCH_DETECTED.getTypeID()
89 || bbArtifact.getArtifactTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID()) {
91 if (bbArtifact.getParent() instanceof AbstractFile) {
92 type = CorrelationAttributeInstance.getDefaultCorrelationTypes().get(CorrelationAttributeInstance.FILES_TYPE_ID);
93 value = ((AbstractFile) bbArtifact.getParent()).getMd5Hash();
95 }
catch (TskCoreException | EamDbException ex) {
96 logger.log(Level.WARNING,
"Unable to get correlation type or value to determine value for O column for artifact", ex);
99 List<CorrelationAttributeInstance> listOfPossibleAttributes = EamArtifactUtil.makeInstancesFromBlackboardArtifact(bbArtifact,
false);
100 if (listOfPossibleAttributes.size() > 1) {
102 description = Bundle.GetSCOTask_occurrences_multipleProperties();
103 }
else if (!listOfPossibleAttributes.isEmpty()) {
105 type = listOfPossibleAttributes.get(0).getCorrelationType();
106 value = listOfPossibleAttributes.get(0).getCorrelationValue();
109 }
else if (contentNode.getContent() instanceof AbstractFile) {
112 type = CorrelationAttributeInstance.getDefaultCorrelationTypes().get(CorrelationAttributeInstance.FILES_TYPE_ID);
113 value = ((AbstractFile) contentNode.getContent()).getMd5Hash();
114 }
catch (EamDbException ex) {
115 logger.log(Level.WARNING,
"Unable to get correlation type to determine value for O column for file", ex);
118 scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(type, value, description));
124 listener.propertyChange(
new PropertyChangeEvent(
125 AutopsyEvent.SourceType.LOCAL.toString(),
126 AbstractAbstractFileNode.NodeSpecificEvents.SCO_AVAILABLE.toString(),