19 package org.sleuthkit.autopsy.datasourcesummary.datamodel;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Collections;
25 import java.util.HashSet;
26 import java.util.List;
29 import java.util.function.Function;
30 import java.util.stream.Collectors;
31 import org.apache.commons.lang3.StringUtils;
32 import org.apache.commons.lang3.tuple.Pair;
35 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
37 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
47 private static final BlackboardAttribute.Type
TYPE_SET_NAME =
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_SET_NAME);
58 ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID(),
59 ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID(),
60 ARTIFACT_TYPE.TSK_HASHSET_HIT.getTypeID(),
61 ARTIFACT_TYPE.TSK_KEYWORD_HIT.getTypeID()
111 public List<Pair<String, Long>>
getKeywordCounts(DataSource dataSource)
throws SleuthkitCaseProviderException, TskCoreException {
114 .filter((pair) -> pair != null && pair.getKey() != null && !EXCLUDED_KEYWORD_SEARCH_ITEMS.contains(pair.getKey().toUpperCase().trim()))
115 .collect(Collectors.toList());
130 public List<Pair<String, Long>>
getInterestingItemCounts(DataSource dataSource)
throws SleuthkitCaseProviderException, TskCoreException {
131 return getCountsData(dataSource,
TYPE_SET_NAME, ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT);
148 private List<Pair<String, Long>>
getCountsData(DataSource dataSource, BlackboardAttribute.Type keyType, ARTIFACT_TYPE... artifactTypes)
149 throws SleuthkitCaseProviderException, TskCoreException {
151 if (dataSource == null) {
152 return Collections.emptyList();
155 List<BlackboardArtifact> artifacts =
new ArrayList<>();
156 SleuthkitCase skCase = provider.
get();
159 for (ARTIFACT_TYPE type : artifactTypes) {
160 artifacts.addAll(skCase.getBlackboard().getArtifacts(type.getTypeID(), dataSource.getId()));
164 Map<String, Long> countedKeys = artifacts.stream()
166 String key = DataSourceInfoUtilities.getStringOrNull(art, keyType);
167 return (StringUtils.isBlank(key)) ? null : key;
169 .filter((key) -> key != null)
170 .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
173 return countedKeys.entrySet().stream()
174 .map((e) -> Pair.of(e.getKey(), e.getValue()))
175 .sorted((a, b) -> -a.getValue().compareTo(b.getValue()))
176 .collect(Collectors.toList());
List< Pair< String, Long > > getInterestingItemCounts(DataSource dataSource)
SleuthkitCaseProvider DEFAULT
List< Pair< String, Long > > getCountsData(DataSource dataSource, BlackboardAttribute.Type keyType, ARTIFACT_TYPE...artifactTypes)
Set< Integer > getArtifactTypeIdsForRefresh()
static final Set< String > EXCLUDED_KEYWORD_SEARCH_ITEMS
final SleuthkitCaseProvider provider
AnalysisSummary(SleuthkitCaseProvider provider)
List< Pair< String, Long > > getHashsetCounts(DataSource dataSource)
static final BlackboardAttribute.Type TYPE_SET_NAME
static final Set< Integer > ARTIFACT_UPDATE_TYPE_IDS
List< Pair< String, Long > > getKeywordCounts(DataSource dataSource)