Autopsy  4.11.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
GetSCOTask.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datamodel;
20 
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;
35 import org.sleuthkit.datamodel.AbstractFile;
36 import org.sleuthkit.datamodel.BlackboardArtifact;
37 import org.sleuthkit.datamodel.Tag;
38 import org.sleuthkit.datamodel.TskCoreException;
39 
45 class GetSCOTask implements Runnable {
46 
47  private final WeakReference<AbstractContentNode<?>> weakNodeRef;
48  private final PropertyChangeListener listener;
49  private static final Logger logger = Logger.getLogger(GetSCOTask.class.getName());
50 
51  GetSCOTask(WeakReference<AbstractContentNode<?>> weakContentRef, PropertyChangeListener listener) {
52  this.weakNodeRef = weakContentRef;
53  this.listener = listener;
54  }
55 
56  @Messages({"GetSCOTask.occurrences.defaultDescription=No correlation properties found",
57  "GetSCOTask.occurrences.multipleProperties=Multiple different correlation properties exist for this result"})
58  @Override
59  public void run() {
60  AbstractContentNode<?> contentNode = weakNodeRef.get();
61 
62  //Check for stale reference
63  if (contentNode == null) {
64  return;
65  }
66 
67  // get the SCO column values
68  List<Tag> tags = contentNode.getAllTagsFromDatabase();
69  CorrelationAttributeInstance fileAttribute = contentNode.getCorrelationAttributeInstance();
70 
71  SCOData scoData = new SCOData();
72  scoData.setScoreAndDescription(contentNode.getScorePropertyAndDescription(tags));
73  scoData.setComment(contentNode.getCommentProperty(tags, fileAttribute));
74 
75  if (EamDb.isEnabled() && !UserPreferences.hideCentralRepoCommentsAndOccurrences()) {
76  Type type = null;
77  String value = null;
78  String description = Bundle.GetSCOTask_occurrences_defaultDescription();
79  if (contentNode instanceof BlackboardArtifactNode) {
80  BlackboardArtifact bbArtifact = ((BlackboardArtifactNode) contentNode).getArtifact();
81  //for specific artifact types we still want to display information for the file instance correlation attribute
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()) {
90  try {
91  if (bbArtifact.getParent() instanceof AbstractFile) {
92  type = CorrelationAttributeInstance.getDefaultCorrelationTypes().get(CorrelationAttributeInstance.FILES_TYPE_ID);
93  value = ((AbstractFile) bbArtifact.getParent()).getMd5Hash();
94  }
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);
97  }
98  } else {
99  List<CorrelationAttributeInstance> listOfPossibleAttributes = EamArtifactUtil.makeInstancesFromBlackboardArtifact(bbArtifact, false);
100  if (listOfPossibleAttributes.size() > 1) {
101  //Don't display anything if there is more than 1 correlation property for an artifact but let the user know
102  description = Bundle.GetSCOTask_occurrences_multipleProperties();
103  } else if (!listOfPossibleAttributes.isEmpty()) {
104  //there should only be one item in the list
105  type = listOfPossibleAttributes.get(0).getCorrelationType();
106  value = listOfPossibleAttributes.get(0).getCorrelationValue();
107  }
108  }
109  } else if (contentNode.getContent() instanceof AbstractFile) {
110  //use the file instance correlation attribute if the node is not a BlackboardArtifactNode
111  try {
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);
116  }
117  }
118  scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(type, value, description));
119  }
120 
121  // signal SCO data is available.
122  if (listener
123  != null) {
124  listener.propertyChange(new PropertyChangeEvent(
125  AutopsyEvent.SourceType.LOCAL.toString(),
126  AbstractAbstractFileNode.NodeSpecificEvents.SCO_AVAILABLE.toString(),
127  null, scoData));
128  }
129  }
130 }

Copyright © 2012-2018 Basis Technology. Generated on: Fri Jun 21 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.