Go to the documentation of this file.
19package org.sleuthkit.autopsy.datasourcesummary.datamodel;
21import java.util.Collections;
22import java.util.HashMap;
25import java.util.logging.Level;
26import org.sleuthkit.autopsy.casemodule.Case;
27import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
28import org.sleuthkit.autopsy.coreutils.Logger;
29import org.sleuthkit.datamodel.BlackboardArtifact;
30import org.sleuthkit.datamodel.BlackboardAttribute;
31import org.sleuthkit.datamodel.SleuthkitCase;
32import org.sleuthkit.datamodel.TskCoreException;
33import org.sleuthkit.datamodel.TskData;
53 List<BlackboardArtifact> listOfArtifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_DATA_SOURCE_USAGE);
54 Map<Long, String> typeMap =
new HashMap<>();
55 for (BlackboardArtifact typeArtifact : listOfArtifacts) {
56 BlackboardAttribute descriptionAttr = typeArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DESCRIPTION));
57 if (typeArtifact.getDataSource() !=
null && descriptionAttr !=
null) {
58 long dsId = typeArtifact.getDataSource().getId();
59 String type = typeMap.get(typeArtifact.getDataSource().getId());
61 type = descriptionAttr.getValueString();
63 type = type +
", " + descriptionAttr.getValueString();
65 typeMap.put(dsId, type);
70 logger.log(Level.WARNING,
"Unable to get types of files for all datasources, providing empty results", ex);
71 return Collections.emptyMap();
85 final String countFilesQuery =
"data_source_obj_id, COUNT(*) AS value FROM tsk_files"
86 +
" WHERE meta_type=" + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue()
87 +
" AND type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType()
88 +
" AND dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue()
90 +
" GROUP BY data_source_obj_id";
93 logger.log(Level.WARNING,
"Unable to get counts of files for all datasources, providing empty results", ex);
94 return Collections.emptyMap();
108 final String countArtifactsQuery =
"data_source_obj_id, COUNT(*) AS value"
109 +
" FROM blackboard_artifacts WHERE review_status_id !=" + BlackboardArtifact.ReviewStatus.REJECTED.getID()
110 +
" GROUP BY data_source_obj_id";
113 logger.log(Level.WARNING,
"Unable to get counts of artifacts for all datasources, providing empty results", ex);
114 return Collections.emptyMap();
129 final String countFileTagsQuery =
"data_source_obj_id, COUNT(*) AS value"
130 +
" FROM content_tags as content_tags, tsk_files as tsk_files"
131 +
" WHERE content_tags.obj_id = tsk_files.obj_id"
132 +
" GROUP BY data_source_obj_id";
134 Map<Long, Long> tagCountMap =
new HashMap<>(
getValuesMap(countFileTagsQuery));
135 final String countArtifactTagsQuery =
"data_source_obj_id, COUNT(*) AS value"
136 +
" FROM blackboard_artifact_tags as artifact_tags, blackboard_artifacts AS arts"
137 +
" WHERE artifact_tags.artifact_id = arts.artifact_id"
138 +
" GROUP BY data_source_obj_id";
140 getValuesMap(countArtifactTagsQuery).forEach((key, value) -> tagCountMap.merge(key, value, (value1, value2) -> value1 + value2));
143 logger.log(Level.WARNING,
"Unable to get counts of tags for all datasources, providing empty results", ex);
144 return Collections.emptyMap();
161 DataSourceSingleValueCallback callback =
new DataSourceSingleValueCallback();
162 skCase.getCaseDbAccessManager().select(query, callback);
163 return callback.getMapOfValues();
SleuthkitCase getSleuthkitCase()
static Case getCurrentCaseThrows()
synchronized static Logger getLogger(String name)
static final Logger logger
static Map< Long, String > getDataSourceTypes()
static Map< Long, Long > getCountsOfArtifacts()
static Map< Long, Long > getCountsOfTags()
static Map< Long, Long > getValuesMap(String query)
static Map< Long, Long > getCountsOfFiles()
Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.