mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
7918 second batch of cutting out case DB code from OO viewer
This commit is contained in:
parent
9e39dcff3e
commit
25612ae6da
@ -55,7 +55,6 @@ import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.OsAccount;
|
||||
import org.sleuthkit.datamodel.OsAccountInstance;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
|
||||
@ -86,7 +85,7 @@ public final class OtherOccurrences {
|
||||
|
||||
if (osAccountAddr.isPresent()) {
|
||||
try {
|
||||
for (OsAccountInstance instance : osAccount.getOsAccountInstances()) {
|
||||
for (OsAccountInstance instance : osAccount.getOsAccountInstances()) {
|
||||
CorrelationAttributeInstance correlationAttributeInstance = CorrelationAttributeUtil.makeCorrAttr(instance.getOsAccount(), instance.getDataSource());
|
||||
if (correlationAttributeInstance != null) {
|
||||
ret.add(correlationAttributeInstance);
|
||||
@ -148,25 +147,6 @@ public final class OtherOccurrences {
|
||||
} catch (CentralRepoException | TskCoreException ex) {
|
||||
logger.log(Level.SEVERE, "Error connecting to DB", ex); // NON-NLS
|
||||
}
|
||||
// If EamDb not enabled, get the Files default correlation type to allow Other Occurances to be enabled.
|
||||
} else if (file != null && file.getSize() > 0) {
|
||||
String md5 = file.getMd5Hash();
|
||||
if (md5 != null && !md5.isEmpty()) {
|
||||
try {
|
||||
final CorrelationAttributeInstance.Type fileAttributeType
|
||||
= CorrelationAttributeInstance.getDefaultCorrelationTypes()
|
||||
.stream()
|
||||
.filter(attrType -> attrType.getId() == CorrelationAttributeInstance.FILES_TYPE_ID)
|
||||
.findAny()
|
||||
.get();
|
||||
//The Central Repository is not enabled
|
||||
ret.add(new CorrelationAttributeInstance(fileAttributeType, md5, null, null, "", "", TskData.FileKnown.UNKNOWN, file.getId()));
|
||||
} catch (CentralRepoException ex) {
|
||||
logger.log(Level.SEVERE, "Error connecting to DB", ex); // NON-NLS
|
||||
} catch (CorrelationAttributeNormalizationException ex) {
|
||||
logger.log(Level.INFO, String.format("Unable to create CorrelationAttributeInstance for value %s", md5), ex); // NON-NLS
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -270,44 +250,12 @@ public final class OtherOccurrences {
|
||||
logger.log(Level.INFO, "Error getting artifact instances from database.", ex); // NON-NLS
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
logger.log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS
|
||||
}
|
||||
}
|
||||
|
||||
return new HashMap<>(
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all other abstract files in the current case with the same MD5 as the
|
||||
* selected node.
|
||||
*
|
||||
* @param corAttr The CorrelationAttribute containing the MD5 to search for
|
||||
* @param openCase The current case
|
||||
* @param file The current file.
|
||||
*
|
||||
* @return List of matching AbstractFile objects
|
||||
*
|
||||
* @throws NoCurrentCaseException
|
||||
* @throws TskCoreException
|
||||
* @throws CentralRepoException
|
||||
*/
|
||||
public static List<AbstractFile> getCaseDbMatches(CorrelationAttributeInstance corAttr, Case openCase, AbstractFile file) throws NoCurrentCaseException, TskCoreException, CentralRepoException {
|
||||
List<AbstractFile> caseDbArtifactInstances = new ArrayList<>();
|
||||
if (file != null) {
|
||||
String md5 = corAttr.getCorrelationValue();
|
||||
SleuthkitCase tsk = openCase.getSleuthkitCase();
|
||||
List<AbstractFile> matches = tsk.findAllFilesWhere(String.format("md5 = '%s'", new Object[]{md5}));
|
||||
|
||||
for (AbstractFile fileMatch : matches) {
|
||||
if (file.equals(fileMatch)) {
|
||||
continue; // If this is the file the user clicked on
|
||||
}
|
||||
caseDbArtifactInstances.add(fileMatch);
|
||||
}
|
||||
}
|
||||
return caseDbArtifactInstances;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the file to the nodeDataMap map if it does not already exist
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Central Repository
|
||||
*
|
||||
* Copyright 2019 Basis Technology Corp.
|
||||
* Copyright 2019-2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -29,7 +29,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -202,13 +201,9 @@ final class OccurrencePanel extends javax.swing.JPanel {
|
||||
}
|
||||
String caseDate = "";
|
||||
try {
|
||||
if (occurrence.isCentralRepoNode()) {
|
||||
if (CentralRepository.isEnabled()) {
|
||||
CorrelationCase partialCase = occurrence.getCorrelationAttributeInstance().getCorrelationCase();
|
||||
caseDate = CentralRepository.getInstance().getCaseByUUID(partialCase.getCaseUUID()).getCreationDate();
|
||||
}
|
||||
} else {
|
||||
caseDate = Case.getCurrentCase().getCreatedDate();
|
||||
if (CentralRepository.isEnabled()) {
|
||||
CorrelationCase partialCase = occurrence.getCorrelationAttributeInstance().getCorrelationCase();
|
||||
caseDate = CentralRepository.getInstance().getCaseByUUID(partialCase.getCaseUUID()).getCreationDate();
|
||||
}
|
||||
} catch (CentralRepoException ex) {
|
||||
LOGGER.log(Level.WARNING, "Error getting case created date for other occurrence content viewer", ex);
|
||||
|
@ -29,7 +29,6 @@ import java.util.logging.Level;
|
||||
import javax.swing.SwingWorker;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.application.NodeData;
|
||||
import org.sleuthkit.autopsy.centralrepository.application.OtherOccurrences;
|
||||
import org.sleuthkit.autopsy.centralrepository.application.UniquePathKey;
|
||||
@ -116,21 +115,11 @@ class OtherOccurrenceOneTypeWorker extends SwingWorker<OneTypeData, Void> {
|
||||
if (isCancelled()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (nodeData.isCentralRepoNode()) {
|
||||
try {
|
||||
dataSources.add(OtherOccurrences.makeDataSourceString(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
|
||||
caseNames.put(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getCorrelationAttributeInstance().getCorrelationCase());
|
||||
} catch (CentralRepoException ex) {
|
||||
logger.log(Level.WARNING, "Unable to get correlation case for displaying other occurrence for case: " + nodeData.getCaseName(), ex);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
dataSources.add(OtherOccurrences.makeDataSourceString(Case.getCurrentCaseThrows().getName(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
|
||||
caseNames.put(Case.getCurrentCaseThrows().getName(), new CorrelationCase(Case.getCurrentCaseThrows().getName(), Case.getCurrentCaseThrows().getDisplayName()));
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
logger.log(Level.WARNING, "No current case open for other occurrences", ex);
|
||||
}
|
||||
try {
|
||||
dataSources.add(OtherOccurrences.makeDataSourceString(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
|
||||
caseNames.put(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getCorrelationAttributeInstance().getCorrelationCase());
|
||||
} catch (CentralRepoException ex) {
|
||||
logger.log(Level.WARNING, "Unable to get correlation case for displaying other occurrence for case: " + nodeData.getCaseName(), ex);
|
||||
}
|
||||
totalCount++;
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import java.util.logging.Level;
|
||||
import javax.swing.SwingWorker;
|
||||
import org.openide.nodes.Node;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.centralrepository.application.NodeData;
|
||||
import org.sleuthkit.autopsy.centralrepository.application.OtherOccurrences;
|
||||
import org.sleuthkit.autopsy.centralrepository.contentviewer.OtherOccurrencesNodeWorker.OtherOccurrencesData;
|
||||
@ -85,7 +84,7 @@ class OtherOccurrencesNodeWorker extends SwingWorker<OtherOccurrencesData, Void>
|
||||
}
|
||||
Collection<CorrelationAttributeInstance> correlationAttributes = new ArrayList<>();
|
||||
if (osAccount != null) {
|
||||
correlationAttributes = OtherOccurrences.getCorrelationAttributeFromOsAccount(node, osAccount);
|
||||
correlationAttributes = OtherOccurrences.getCorrelationAttributeFromOsAccount(node, osAccount);
|
||||
} else {
|
||||
correlationAttributes = OtherOccurrences.getCorrelationAttributesFromNode(node, file);
|
||||
}
|
||||
@ -93,23 +92,13 @@ class OtherOccurrencesNodeWorker extends SwingWorker<OtherOccurrencesData, Void>
|
||||
Set<String> dataSources = new HashSet<>();
|
||||
for (CorrelationAttributeInstance corAttr : correlationAttributes) {
|
||||
for (NodeData nodeData : OtherOccurrences.getCorrelatedInstances(file, deviceId, dataSourceName, corAttr).values()) {
|
||||
if (nodeData.isCentralRepoNode()) {
|
||||
try {
|
||||
dataSources.add(OtherOccurrences.makeDataSourceString(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
|
||||
caseNames.put(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getCorrelationAttributeInstance().getCorrelationCase());
|
||||
} catch (CentralRepoException ex) {
|
||||
logger.log(Level.WARNING, "Unable to get correlation case for displaying other occurrence for case: " + nodeData.getCaseName(), ex);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
dataSources.add(OtherOccurrences.makeDataSourceString(Case.getCurrentCaseThrows().getName(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
|
||||
caseNames.put(Case.getCurrentCaseThrows().getName(), new CorrelationCase(Case.getCurrentCaseThrows().getName(), Case.getCurrentCaseThrows().getDisplayName()));
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
logger.log(Level.WARNING, "No current case open for other occurrences", ex);
|
||||
}
|
||||
try {
|
||||
dataSources.add(OtherOccurrences.makeDataSourceString(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
|
||||
caseNames.put(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getCorrelationAttributeInstance().getCorrelationCase());
|
||||
} catch (CentralRepoException ex) {
|
||||
logger.log(Level.WARNING, "Unable to get correlation case for displaying other occurrence for case: " + nodeData.getCaseName(), ex);
|
||||
}
|
||||
totalCount++;
|
||||
|
||||
if (isCancelled()) {
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user