Autopsy  4.19.1
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-2021 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.ArrayList;
25 import java.util.List;
26 import org.apache.commons.lang3.tuple.Pair;
27 import org.openide.util.NbBundle.Messages;
31 import org.sleuthkit.datamodel.Tag;
35 import org.sleuthkit.datamodel.Score;
36 import org.sleuthkit.datamodel.AbstractFile;
37 import org.sleuthkit.datamodel.AnalysisResult;
38 import org.sleuthkit.datamodel.Content;
39 import org.sleuthkit.datamodel.DataArtifact;
40 
46 class GetSCOTask implements Runnable {
47 
48  private final WeakReference<AbstractContentNode<?>> weakNodeRef;
49  private final PropertyChangeListener listener;
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 or if columns are disabled
63  if (contentNode == null || UserPreferences.getHideSCOColumns()) {
64  return;
65  }
66  // get the SCO column values
67  List<Tag> tags = contentNode.getAllTagsFromDatabase();
68  Pair<Score, String> scoreAndDescription;
69  DataResultViewerTable.HasCommentStatus comment;
70  Pair<Long, String> countAndDescription = null;
71 
72  scoreAndDescription = contentNode.getScorePropertyAndDescription(tags);
73  //getting the correlation attribute and setting the comment column is done before the eamdb isEnabled check
74  //because the Comment column will reflect the presence of comments in the CR when the CR is enabled, but reflect tag comments regardless
75  String description = Bundle.GetSCOTask_occurrences_defaultDescription();
76  List<CorrelationAttributeInstance> listOfPossibleAttributes = new ArrayList<>();
77  Content contentFromNode = contentNode.getContent();
78  if (contentFromNode instanceof AbstractFile) {
79  listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((AbstractFile) contentFromNode));
80  } else if (contentFromNode instanceof AnalysisResult) {
81  listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((AnalysisResult) contentFromNode));
82  } else if (contentFromNode instanceof DataArtifact) {
83  listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((DataArtifact) contentFromNode));
84  } else {
85  //JIRA-TODO : add code for Jira-7938 OsAccounts
86  }
87  comment = contentNode.getCommentProperty(tags, listOfPossibleAttributes);
88  CorrelationAttributeInstance corInstance = null;
89  if (CentralRepository.isEnabled()) {
90  if (listOfPossibleAttributes.size() > 1) {
91  //Don't display anything if there is more than 1 correlation property for an artifact but let the user know
92  description = Bundle.GetSCOTask_occurrences_multipleProperties();
93  } else if (!listOfPossibleAttributes.isEmpty()) {
94  //there should only be one item in the list
95  corInstance = listOfPossibleAttributes.get(0);
96  }
97  countAndDescription = contentNode.getCountPropertyAndDescription(corInstance, description);
98  }
99 
100  if(Thread.currentThread().isInterrupted()) {
101  return;
102  }
103 
104  // signal SCO data is available.
105  if (listener != null) {
106  listener.propertyChange(new PropertyChangeEvent(
107  AutopsyEvent.SourceType.LOCAL.toString(),
108  AbstractAbstractFileNode.NodeSpecificEvents.SCO_AVAILABLE.toString(),
109  null, new SCOData(scoreAndDescription, comment, countAndDescription)));
110  }
111  }
112 }

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.