19 package org.sleuthkit.autopsy.datasourcesummary.datamodel;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.HashSet;
26 import java.util.List;
28 import java.util.stream.Collectors;
29 import java.util.stream.Stream;
30 import org.apache.commons.lang3.tuple.Pair;
36 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
83 public PastCasesResult(List<Pair<String, Long>> previouslyNotable, List<Pair<String, Long>> previouslySeenDevices, List<Pair<String, Long>> previouslySeenResults) {
84 this.previouslyNotable = Collections.unmodifiableList(previouslyNotable);
85 this.previouslySeenDevices = Collections.unmodifiableList(previouslySeenDevices);
86 this.previouslySeenResults = Collections.unmodifiableList(previouslySeenResults);
112 ARTIFACT_TYPE.TSK_PREVIOUSLY_SEEN.getTypeID(),
113 ARTIFACT_TYPE.TSK_PREVIOUSLY_NOTABLE.getTypeID()
119 ARTIFACT_TYPE.TSK_DEVICE_ATTACHED.getTypeID(),
120 ARTIFACT_TYPE.TSK_DEVICE_INFO.getTypeID(),
121 ARTIFACT_TYPE.TSK_SIM_ATTACHED.getTypeID(),
122 ARTIFACT_TYPE.TSK_WIFI_NETWORK_ADAPTER.getTypeID()
128 private final java.util.logging.Logger
logger;
151 java.util.logging.Logger
logger) {
153 this.caseProvider = provider;
167 if (sources == null) {
171 return sources.stream().anyMatch((str) -> {
172 return str != null && CENTRAL_REPO_INGEST_NAME.equalsIgnoreCase(str.trim());
185 if (artifact == null) {
186 return Collections.emptyList();
189 BlackboardAttribute commentAttr = null;
191 commentAttr = artifact.getAttribute(BlackboardAttribute.Type.TSK_OTHER_CASES);
192 }
catch (TskCoreException ignored) {
209 if (commentAttr == null) {
210 return Collections.emptyList();
214 return Collections.emptyList();
217 String justCasesStr = commentAttr.getValueString().trim();
218 return Stream.of(justCasesStr.split(CASE_SEPARATOR))
220 .collect(Collectors.toList());
233 private static List<Pair<String, Long>>
getCaseCounts(Stream<String> cases) {
234 Collection<List<String>> groupedCases = cases
236 .collect(Collectors.groupingBy((caseStr) -> caseStr.toUpperCase().trim()))
242 .filter((lst) -> lst != null && lst.size() > 0)
244 .map((lst) -> Pair.of(lst.get(0), (long) lst.size()))
246 .sorted((a, b) -> -Long.compare(a.getValue(), b.getValue()))
247 .collect(Collectors.toList());
259 List<String> cases =
new ArrayList<>();
260 for (BlackboardArtifact art : artifacts) {
280 BlackboardArtifact sourceArtifact = null;
281 SleuthkitCase skCase = caseProvider.
get();
282 Content content = skCase.getContentById(artifact.getObjectID());
283 if (content instanceof BlackboardArtifact) {
284 sourceArtifact = (BlackboardArtifact) content;
286 return sourceArtifact;
301 if (parent == null) {
305 return CR_DEVICE_TYPE_IDS.contains(parent.getArtifactTypeID());
322 if (dataSource == null) {
326 long dataSourceId = dataSource.getId();
328 Blackboard blackboard = caseProvider.
get().getBlackboard();
330 List<BlackboardArtifact> previouslyNotableArtifacts
331 = blackboard.getArtifacts(BlackboardArtifact.Type.TSK_PREVIOUSLY_NOTABLE.getTypeID(), dataSourceId);
333 List<BlackboardArtifact> previouslySeenArtifacts
334 = blackboard.getArtifacts(BlackboardArtifact.Type.TSK_PREVIOUSLY_SEEN.getTypeID(), dataSourceId);
336 List<BlackboardArtifact> previouslySeenDevice =
new ArrayList<>();
337 List<BlackboardArtifact> previouslySeenNoDevice =
new ArrayList<>();
339 for (BlackboardArtifact art : previouslySeenArtifacts) {
341 previouslySeenDevice.add(art);
343 previouslySeenNoDevice.add(art);
static final Set< Integer > ARTIFACT_UPDATE_TYPE_IDS
SleuthkitCaseProvider DEFAULT
PastCasesResult(List< Pair< String, Long >> previouslyNotable, List< Pair< String, Long >> previouslySeenDevices, List< Pair< String, Long >> previouslySeenResults)
static List< String > getCasesFromAttr(BlackboardAttribute commentAttr)
static final String CENTRAL_REPO_INGEST_NAME
final List< Pair< String, Long > > previouslyNotable
List< Pair< String, Long > > getPreviouslyNotable()
PastCasesResult getPastCasesData(DataSource dataSource)
final List< Pair< String, Long > > previouslySeenResults
BlackboardArtifact getParentArtifact(BlackboardArtifact artifact)
boolean hasDeviceAssociatedArtifact(BlackboardArtifact artifact)
final SleuthkitCaseProvider caseProvider
static List< Pair< String, Long > > getCaseCounts(Stream< String > cases)
static boolean isCentralRepoGenerated(List< String > sources)
static final String CASE_SEPARATOR
final java.util.logging.Logger logger
static String getModuleName()
static List< Pair< String, Long > > getCaseCountsFromArtifacts(List< BlackboardArtifact > artifacts)
List< Pair< String, Long > > getPreviouslySeenDevices()
static List< String > getCasesFromArtifact(BlackboardArtifact artifact)
synchronized static Logger getLogger(String name)
final List< Pair< String, Long > > previouslySeenDevices
static final Set< Integer > CR_DEVICE_TYPE_IDS
List< Pair< String, Long > > getPreviouslySeenResults()
PastCasesSummary(SleuthkitCaseProvider provider, java.util.logging.Logger logger)