19 package org.sleuthkit.autopsy.datasourcesummary.datamodel;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.HashSet;
24 import java.util.List;
27 import java.util.function.Function;
28 import java.util.stream.Collectors;
29 import org.apache.commons.lang3.StringUtils;
30 import org.apache.commons.lang3.tuple.Pair;
34 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
36 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
46 private static final BlackboardAttribute.Type
TYPE_SET_NAME =
new BlackboardAttribute.Type(ATTRIBUTE_TYPE.TSK_SET_NAME);
91 public List<Pair<String, Long>>
getKeywordCounts(DataSource dataSource)
throws SleuthkitCaseProviderException, TskCoreException {
94 .filter((pair) -> pair != null && pair.getKey() != null && !EXCLUDED_KEYWORD_SEARCH_ITEMS.contains(pair.getKey().toUpperCase().trim()))
95 .collect(Collectors.toList());
110 public List<Pair<String, Long>>
getInterestingItemCounts(DataSource dataSource)
throws SleuthkitCaseProviderException, TskCoreException {
111 return getCountsData(dataSource,
TYPE_SET_NAME, ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT);
128 private List<Pair<String, Long>>
getCountsData(DataSource dataSource, BlackboardAttribute.Type keyType, ARTIFACT_TYPE... artifactTypes)
129 throws SleuthkitCaseProviderException, TskCoreException {
131 if (dataSource == null) {
132 return Collections.emptyList();
135 List<BlackboardArtifact> artifacts =
new ArrayList<>();
136 SleuthkitCase skCase = provider.
get();
139 for (ARTIFACT_TYPE type : artifactTypes) {
140 artifacts.addAll(skCase.getBlackboard().getArtifacts(type.getTypeID(), dataSource.getId()));
144 Map<String, Long> countedKeys = artifacts.stream()
147 return (StringUtils.isBlank(key)) ? null : key;
149 .filter((key) -> key != null)
150 .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
153 return countedKeys.entrySet().stream()
154 .map((e) -> Pair.of(e.getKey(), e.getValue()))
155 .sorted((a, b) -> -a.getValue().compareTo(b.getValue()))
156 .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)
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
List< Pair< String, Long > > getKeywordCounts(DataSource dataSource)
static String getStringOrNull(BlackboardArtifact artifact, Type attributeType)