19package org.sleuthkit.autopsy.datamodel;
21import java.beans.PropertyChangeEvent;
22import java.beans.PropertyChangeListener;
23import java.sql.ResultSet;
24import java.sql.SQLException;
25import java.util.ArrayList;
26import java.util.Collections;
27import java.util.EnumSet;
28import java.util.HashMap;
29import java.util.HashSet;
30import java.util.LinkedHashMap;
33import java.util.Observable;
34import java.util.Observer;
36import java.util.logging.Level;
37import org.openide.nodes.ChildFactory;
38import org.openide.nodes.Children;
39import org.openide.nodes.Node;
40import org.openide.nodes.Sheet;
41import org.openide.util.NbBundle;
42import org.openide.util.WeakListeners;
43import org.openide.util.lookup.Lookups;
44import org.sleuthkit.autopsy.casemodule.Case;
45import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
46import org.sleuthkit.autopsy.coreutils.Logger;
47import org.sleuthkit.autopsy.ingest.IngestManager;
48import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
49import org.sleuthkit.datamodel.BlackboardArtifact;
50import static org.sleuthkit.datamodel.BlackboardArtifact.Type.TSK_HASHSET_HIT;
51import org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
52import org.sleuthkit.datamodel.SleuthkitCase;
53import org.sleuthkit.datamodel.SleuthkitCase.CaseDbQuery;
54import org.sleuthkit.datamodel.TskCoreException;
55import org.sleuthkit.autopsy.datamodel.Artifacts.UpdatableCountTypeNode;
56import org.sleuthkit.datamodel.AnalysisResult;
63 private static final String
HASHSET_HITS = BlackboardArtifact.Type.TSK_HASHSET_HIT.getTypeName();
64 private static final String
DISPLAY_NAME = BlackboardArtifact.Type.TSK_HASHSET_HIT.getDisplayName();
91 this.filteringDSObjId = objId;
97 return visitor.
visit(
this);
104 private class HashsetResults
extends Observable {
114 List<String> getSetNames() {
119 Collections.sort(names);
123 Set<Long> getArtifactIds(String hashSetName) {
129 @SuppressWarnings(
"deprecation")
130 final
void update() {
139 int setNameId = ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID();
140 int artId = TSK_HASHSET_HIT.getTypeID();
141 String query =
"SELECT value_text,blackboard_artifacts.artifact_obj_id,attribute_type_id "
142 +
"FROM blackboard_attributes,blackboard_artifacts WHERE "
143 +
"attribute_type_id=" + setNameId
144 +
" AND blackboard_attributes.artifact_id=blackboard_artifacts.artifact_id"
145 +
" AND blackboard_artifacts.artifact_type_id=" + artId;
147 query +=
" AND blackboard_artifacts.data_source_obj_id = " +
filteringDSObjId;
150 try (CaseDbQuery dbQuery =
skCase.executeQuery(query)) {
151 ResultSet resultSet = dbQuery.getResultSet();
152 synchronized (hashSetHitsMap) {
153 while (resultSet.next()) {
154 String setName = resultSet.getString(
"value_text");
155 long artifactObjId = resultSet.getLong(
"artifact_obj_id");
156 if (!hashSetHitsMap.containsKey(setName)) {
157 hashSetHitsMap.put(setName, new HashSet<>());
159 hashSetHitsMap.get(setName).add(artifactObjId);
162 }
catch (TskCoreException | SQLException ex) {
163 logger.log(Level.WARNING,
"SQL Exception occurred: ", ex);
184 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/hashset_hits.png");
194 return visitor.
visit(
this);
199 Sheet sheet = super.createSheet();
200 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
201 if (sheetSet ==
null) {
202 sheetSet = Sheet.createPropertiesSet();
206 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"HashsetHits.createSheet.name.name"),
207 NbBundle.getMessage(
this.getClass(),
"HashsetHits.createSheet.name.displayName"),
208 NbBundle.getMessage(
this.getClass(),
"HashsetHits.createSheet.name.desc"),
216 return getClass().getName();
230 private final PropertyChangeListener
pcl =
new PropertyChangeListener() {
232 public void propertyChange(PropertyChangeEvent evt) {
233 String eventType = evt.getPropertyName();
275 if (evt.getNewValue() ==
null) {
283 private final PropertyChangeListener
weakPcl = WeakListeners.propertyChange(
pcl,
null);
315 public void update(Observable o, Object arg) {
332 this.setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/hashset_hits.png");
350 Sheet sheet = super.createSheet();
351 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
352 if (sheetSet ==
null) {
353 sheetSet = Sheet.createPropertiesSet();
357 sheetSet.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"HashsetHits.createSheet.name.name"),
358 NbBundle.getMessage(
this.getClass(),
"HashsetHits.createSheet.name.displayName"),
359 NbBundle.getMessage(
this.getClass(),
"HashsetHits.createSheet.name.desc"),
367 return visitor.
visit(
this);
371 public void update(Observable o, Object arg) {
381 return getClass().getName();
391 private final Map<Long, AnalysisResult>
artifactHits =
new HashMap<>();
414 public void update(Observable o, Object arg) {
425 AnalysisResult art =
skCase.getBlackboard().getAnalysisResultById(
id);
431 }
catch (TskCoreException ex) {
432 logger.log(Level.SEVERE,
"TSK Exception occurred", ex);
437 return Collections.emptyList();
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
synchronized static Logger getLogger(String name)
UpdatableCountTypeNode(Children children, Lookup lookup, String baseName, long filteringDSObjId, BlackboardArtifact.Type... types)
final long filteringDSObjId
static final Logger logger
BaseChildFactory(String nodeName)
DisplayableItemNode(Children children)
final PropertyChangeListener weakPcl
boolean createKeys(List< String > list)
final PropertyChangeListener pcl
Node createNodeForKey(String key)
void update(Observable o, Object arg)
void update(Observable o, Object arg)
HashsetNameNode(String hashSetName)
final Map< String, Set< Long > > hashSetHitsMap
HitFactory(String hashsetName)
final Map< Long, AnalysisResult > artifactHits
List< AnalysisResult > makeKeys()
Node createNodeForKey(AnalysisResult key)
void update(Observable o, Object arg)
static final String DISPLAY_NAME
final long filteringDSObjId
static final Set< IngestManager.IngestJobEvent > INGEST_JOB_EVENTS_OF_INTEREST
final HashsetResults hashsetResults
static final Set< IngestManager.IngestModuleEvent > INGEST_MODULE_EVENTS_OF_INTEREST
static final String HASHSET_HITS
static final Logger logger
HashsetHits(SleuthkitCase skCase)
HashsetHits(SleuthkitCase skCase, long objId)
static synchronized IngestManager getInstance()
void removeIngestModuleEventListener(final PropertyChangeListener listener)
void removeIngestJobEventListener(final PropertyChangeListener listener)
void addIngestModuleEventListener(final PropertyChangeListener listener)
void addIngestJobEventListener(final PropertyChangeListener listener)
BlackboardArtifact.Type getBlackboardArtifactType()
T visit(DataSourceFilesNode in)