19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.sql.ResultSet;
24 import java.sql.SQLException;
25 import java.util.ArrayList;
26 import java.util.Collections;
27 import java.util.EnumSet;
28 import java.util.HashMap;
29 import java.util.HashSet;
30 import java.util.LinkedHashMap;
31 import java.util.List;
33 import java.util.Observable;
34 import java.util.Observer;
36 import java.util.logging.Level;
37 import org.openide.nodes.ChildFactory;
38 import org.openide.nodes.Children;
39 import org.openide.nodes.Node;
40 import org.openide.nodes.Sheet;
41 import org.openide.util.NbBundle;
42 import org.openide.util.lookup.Lookups;
51 import org.
sleuthkit.datamodel.SleuthkitCase.CaseDbQuery;
57 .getMessage(
InterestingHits.class,
"InterestingHits.interestingItems.text");
85 this.filteringDSObjId = objId;
86 interestingResults.
update();
95 List<String> setNames;
97 setNames =
new ArrayList<>(interestingItemsMap.keySet());
99 Collections.sort(setNames);
105 return interestingItemsMap.get(setName).get(typeName);
111 interestingItemsMap.clear();
113 loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
114 loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT);
123 @SuppressWarnings(
"deprecation")
125 if (skCase == null) {
129 int setNameId = BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID();
130 int artId = artType.getTypeID();
131 String query =
"SELECT value_text,blackboard_attributes.artifact_id,attribute_type_id "
132 +
"FROM blackboard_attributes,blackboard_artifacts WHERE "
133 +
"attribute_type_id=" + setNameId
134 +
" AND blackboard_attributes.artifact_id=blackboard_artifacts.artifact_id"
135 +
" AND blackboard_artifacts.artifact_type_id=" + artId;
136 if (filteringDSObjId > 0) {
137 query +=
" AND blackboard_artifacts.data_source_obj_id = " +
filteringDSObjId;
140 try (CaseDbQuery dbQuery = skCase.executeQuery(query)) {
142 ResultSet resultSet = dbQuery.getResultSet();
143 while (resultSet.next()) {
144 String value = resultSet.getString(
"value_text");
145 long artifactId = resultSet.getLong(
"artifact_id");
146 if (!interestingItemsMap.containsKey(value)) {
147 interestingItemsMap.put(value,
new LinkedHashMap<>());
148 interestingItemsMap.get(value).put(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getDisplayName(),
new HashSet<>());
149 interestingItemsMap.get(value).put(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getDisplayName(),
new HashSet<>());
151 interestingItemsMap.get(value).get(artType.getDisplayName()).add(artifactId);
154 }
catch (TskCoreException | SQLException ex) {
155 logger.log(Level.WARNING,
"SQL Exception occurred: ", ex);
162 return visitor.
visit(
this);
171 super(Children.create(
new SetNameFactory(),
true), Lookups.singleton(DISPLAY_NAME));
172 super.setName(INTERESTING_ITEMS);
173 super.setDisplayName(DISPLAY_NAME);
174 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/interesting_item.png");
184 return visitor.
visit(
this);
189 Sheet sheet = super.createSheet();
190 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
191 if (sheetSet == null) {
192 sheetSet = Sheet.createPropertiesSet();
196 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.name"),
197 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.displayName"),
198 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.desc"),
206 return getClass().getName();
210 private class SetNameFactory extends ChildFactory.Detachable<String> implements Observer {
217 private final PropertyChangeListener
pcl = (PropertyChangeEvent evt) -> {
218 String eventType = evt.getPropertyName();
235 if (null != eventData && (eventData.
getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID()
236 || eventData.
getBlackboardArtifactType().getTypeID() == BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID())) {
237 interestingResults.
update();
254 interestingResults.
update();
262 if (evt.getNewValue() == null) {
274 interestingResults.
update();
275 interestingResults.addObserver(
this);
283 interestingResults.deleteObserver(
this);
298 public void update(Observable o, Object arg) {
308 super(Children.create(
new HitTypeFactory(setName),
true), Lookups.singleton(setName));
310 super.setName(setName);
312 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/interesting_item.png");
313 interestingResults.addObserver(
this);
317 int sizeOfSet = interestingResults.
getArtifactIds(setName, BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getDisplayName()).size()
318 + interestingResults.
getArtifactIds(setName, BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getDisplayName()).size();
319 super.setDisplayName(setName +
" (" + sizeOfSet +
")");
329 Sheet sheet = super.createSheet();
330 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
331 if (sheetSet == null) {
332 sheetSet = Sheet.createPropertiesSet();
336 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.name"),
337 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.name"),
338 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.desc"),
346 return visitor.
visit(
this);
350 public void update(Observable o, Object arg) {
360 return getClass().getName();
367 private final Map<Long, BlackboardArtifact>
artifactHits =
new HashMap<>();
372 interestingResults.addObserver(
this);
377 list.add(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getDisplayName());
378 list.add(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getDisplayName());
388 public void update(Observable o, Object arg) {
399 super(Children.create(
new HitFactory(setName, typeName),
true), Lookups.singleton(setName));
407 super.setName(setName +
"_" + typeName);
409 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/interesting_item.png");
410 interestingResults.addObserver(
this);
414 super.setDisplayName(typeName +
" (" + interestingResults.
getArtifactIds(setName, typeName).size() +
")");
424 Sheet sheet = super.createSheet();
425 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
426 if (sheetSet == null) {
427 sheetSet = Sheet.createPropertiesSet();
430 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.name"),
431 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.name"),
432 NbBundle.getMessage(
this.getClass(),
"InterestingHits.createSheet.name.desc"),
439 return visitor.
visit(
this);
443 public void update(Observable o, Object arg) {
453 return getClass().getName();
461 private final Map<Long, BlackboardArtifact>
artifactHits =
new HashMap<>();
469 super(setName +
"_" + typeName);
472 interestingResults.addObserver(
this);
478 if (skCase != null) {
479 interestingResults.
getArtifactIds(setName, typeName).forEach((
id) -> {
481 if (!artifactHits.containsKey(
id)) {
482 BlackboardArtifact art = skCase.getBlackboardArtifact(
id);
486 artifactHits.put(
id, art);
488 }
catch (TskCoreException ex) {
489 logger.log(Level.SEVERE,
"TSK Exception occurred", ex);
493 return new ArrayList<>(artifactHits.values());
495 return Collections.emptyList();
504 public void update(Observable o, Object arg) {
static final String DISPLAY_NAME
BlackboardArtifact.Type getBlackboardArtifactType()
void removeIngestModuleEventListener(final PropertyChangeListener listener)
static final String INTERESTING_ITEMS
HitTypeFactory(String setName)
static final Set< IngestManager.IngestModuleEvent > INGEST_MODULE_EVENTS_OF_INTEREST
static synchronized IngestManager getInstance()
boolean createKeys(List< String > list)
Node createNodeForKey(String key)
void loadArtifacts(BlackboardArtifact.ARTIFACT_TYPE artType)
void update(Observable o, Object arg)
InterestingHits(SleuthkitCase skCase, long objId)
boolean createKeys(List< String > list)
List< String > getSetNames()
HitFactory(String setName, String typeName)
T visit(DataSourcesNode in)
void removeIngestJobEventListener(final PropertyChangeListener listener)
final PropertyChangeListener pcl
void update(Observable o, Object arg)
SetNameNode(String setName)
void addIngestJobEventListener(final PropertyChangeListener listener)
final long filteringDSObjId
static final Set< IngestManager.IngestJobEvent > INGEST_JOB_EVENTS_OF_INTEREST
Set< Long > getArtifactIds(String setName, String typeName)
void update(Observable o, Object arg)
void update(Observable o, Object arg)
List< BlackboardArtifact > makeKeys()
final Map< Long, BlackboardArtifact > artifactHits
void addIngestModuleEventListener(final PropertyChangeListener listener)
Node createNodeForKey(String key)
InterestingItemTypeNode(String setName, String typeName)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
InterestingHits(SleuthkitCase skCase)
final Map< Long, BlackboardArtifact > artifactHits
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
final InterestingResults interestingResults
final Map< String, Map< String, Set< Long > > > interestingItemsMap
Node createNodeForKey(BlackboardArtifact art)
void update(Observable o, Object arg)
static final Logger logger