mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-09 06:39:33 +00:00
2229: Part 25: Use getOpenCase() instead of getCurrentCase() in ingest, modules, recentactivity...
This commit is contained in:
parent
b5d4935f6b
commit
cd6b24075d
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Central Repository
|
||||
*
|
||||
* Copyright 2015-2017 Basis Technology Corp.
|
||||
* Copyright 2015-2018 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -46,6 +46,7 @@ import org.openide.nodes.Node;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.openide.util.lookup.ServiceProvider;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
|
||||
@ -97,7 +98,11 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
|
||||
} else if (jmi.equals(showCaseDetailsMenuItem)) {
|
||||
showCaseDetails(otherCasesTable.getSelectedRow());
|
||||
} else if (jmi.equals(exportToCSVMenuItem)) {
|
||||
saveToCSV();
|
||||
try {
|
||||
saveToCSV();
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Exception while getting open case.", ex); // NON-NLS
|
||||
}
|
||||
} else if (jmi.equals(showCommonalityMenuItem)) {
|
||||
showCommonalityDetails();
|
||||
}
|
||||
@ -159,8 +164,19 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
|
||||
@Messages({"DataContentViewerOtherCases.caseDetailsDialog.notSelected=No Row Selected",
|
||||
"DataContentViewerOtherCases.caseDetailsDialog.noDetails=No details for this case.",
|
||||
"DataContentViewerOtherCases.caseDetailsDialog.noDetailsReference=No case details for Global reference properties.",
|
||||
"DataContentViewerOtherCases.caseDetailsDialog.noCaseNameError=Error"})
|
||||
"DataContentViewerOtherCases.caseDetailsDialog.noCaseNameError=Error",
|
||||
"DataContentViewerOtherCases.noOpenCase.errMsg=No open case available."})
|
||||
private void showCaseDetails(int selectedRowViewIdx) {
|
||||
Case openCase;
|
||||
try {
|
||||
openCase = Case.getOpenCase();
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
JOptionPane.showConfirmDialog(showCaseDetailsMenuItem,
|
||||
Bundle.DataContentViewerOtherCases_noOpenCase_errMsg(),
|
||||
Bundle.DataContentViewerOtherCases_noOpenCase_errMsg(),
|
||||
DEFAULT_OPTION, PLAIN_MESSAGE);
|
||||
return;
|
||||
}
|
||||
String caseDisplayName = Bundle.DataContentViewerOtherCases_caseDetailsDialog_noCaseNameError();
|
||||
try {
|
||||
if (-1 != selectedRowViewIdx) {
|
||||
@ -177,7 +193,7 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
|
||||
}
|
||||
caseDisplayName = eamCasePartial.getDisplayName();
|
||||
// query case details
|
||||
CorrelationCase eamCase = dbManager.getCase(Case.getCurrentCase());
|
||||
CorrelationCase eamCase = dbManager.getCase(openCase);
|
||||
if (eamCase == null) {
|
||||
JOptionPane.showConfirmDialog(showCaseDetailsMenuItem,
|
||||
Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetails(),
|
||||
@ -205,11 +221,11 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToCSV() {
|
||||
private void saveToCSV() throws NoCurrentCaseException {
|
||||
if (0 != otherCasesTable.getSelectedRowCount()) {
|
||||
Calendar now = Calendar.getInstance();
|
||||
String fileName = String.format("%1$tY%1$tm%1$te%1$tI%1$tM%1$tS_other_data_sources.csv", now);
|
||||
CSVFileChooser.setCurrentDirectory(new File(Case.getCurrentCase().getExportDirectory()));
|
||||
CSVFileChooser.setCurrentDirectory(new File(Case.getOpenCase().getExportDirectory()));
|
||||
CSVFileChooser.setSelectedFile(new File(fileName));
|
||||
CSVFileChooser.setFileFilter(new FileNameExtensionFilter("csv file", "csv"));
|
||||
|
||||
@ -417,8 +433,8 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
|
||||
*/
|
||||
private Collection<CorrelationAttributeInstance> getCorrelatedInstances(CorrelationAttribute corAttr, String dataSourceName, String deviceId) {
|
||||
// @@@ Check exception
|
||||
String caseUUID = Case.getCurrentCase().getName();
|
||||
try {
|
||||
String caseUUID = Case.getOpenCase().getName();
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
Collection<CorrelationAttributeInstance> artifactInstances = dbManager.getArtifactInstancesByTypeValue(corAttr.getCorrelationType(), corAttr.getCorrelationValue()).stream()
|
||||
.filter(artifactInstance -> !artifactInstance.getCorrelationCase().getCaseUUID().equals(caseUUID)
|
||||
@ -428,6 +444,8 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
|
||||
return artifactInstances;
|
||||
} catch (EamDbException ex) {
|
||||
LOGGER.log(Level.SEVERE, "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 Collections.emptyList();
|
||||
@ -473,9 +491,9 @@ public class DataContentViewerOtherCases extends javax.swing.JPanel implements D
|
||||
if (af != null) {
|
||||
Content dataSource = af.getDataSource();
|
||||
dataSourceName = dataSource.getName();
|
||||
deviceId = Case.getCurrentCase().getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
|
||||
deviceId = Case.getOpenCase().getSleuthkitCase().getDataSource(dataSource.getId()).getDeviceId();
|
||||
}
|
||||
} catch (TskException ex) {
|
||||
} catch (TskException | NoCurrentCaseException ex) {
|
||||
// do nothing.
|
||||
// @@@ Review this behavior
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011-2017 Basis Technology Corp.
|
||||
* Copyright 2011-2018 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -41,6 +41,7 @@ import org.netbeans.api.progress.ProgressHandle;
|
||||
import org.openide.util.Cancellable;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
import org.sleuthkit.datamodel.AbstractContent;
|
||||
@ -100,7 +101,8 @@ final class ExtractUnallocAction extends AbstractAction {
|
||||
"ExtractUnallocAction.volumeInProgress=Already extracting unallocated space into {0} - will skip this volume",
|
||||
"ExtractUnallocAction.volumeError=Error extracting unallocated space from volume",
|
||||
"ExtractUnallocAction.noFiles=No unallocated files found on volume",
|
||||
"ExtractUnallocAction.imageError=Error extracting unallocated space from image"})
|
||||
"ExtractUnallocAction.imageError=Error extracting unallocated space from image",
|
||||
"ExtractUnallocAction.noOpenCase.errMsg=No open case available."})
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (filesToExtract != null && filesToExtract.size() > 0) {
|
||||
@ -111,6 +113,13 @@ final class ExtractUnallocAction extends AbstractAction {
|
||||
//JOptionPane.showMessageDialog(new Frame(), "Unallocated Space is already being extracted on this Image. Please select a different Image.");
|
||||
return;
|
||||
}
|
||||
Case openCase;
|
||||
try {
|
||||
openCase = Case.getOpenCase();
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
MessageNotifyUtil.Message.info(Bundle.ExtractAction_noOpenCase_errMsg());
|
||||
return;
|
||||
}
|
||||
List<OutputFileData> copyList = new ArrayList<OutputFileData>() {
|
||||
{
|
||||
addAll(filesToExtract);
|
||||
@ -130,7 +139,7 @@ final class ExtractUnallocAction extends AbstractAction {
|
||||
}
|
||||
};
|
||||
|
||||
fileChooser.setCurrentDirectory(new File(Case.getCurrentCase().getExportDirectory()));
|
||||
fileChooser.setCurrentDirectory(new File(openCase.getExportDirectory()));
|
||||
fileChooser.setDialogTitle(
|
||||
NbBundle.getMessage(this.getClass(), "ExtractUnallocAction.dlgTitle.selectDirToSaveTo.msg"));
|
||||
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
|
@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.ingest;
|
||||
|
||||
import java.util.Map;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
@ -53,18 +54,20 @@ public final class IngestServices {
|
||||
* Get the current Autopsy case.
|
||||
*
|
||||
* @return The current case.
|
||||
* @throws NoCurrentCaseException if there is no open case.
|
||||
*/
|
||||
public Case getCurrentCase() {
|
||||
return Case.getCurrentCase();
|
||||
public Case getOpenCase() throws NoCurrentCaseException {
|
||||
return Case.getOpenCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current SleuthKit case. The SleuthKit case is the case database.
|
||||
*
|
||||
* @return The current case database.
|
||||
* @throws NoCurrentCaseException if there is no open case.
|
||||
*/
|
||||
public SleuthkitCase getCurrentSleuthkitCaseDb() {
|
||||
return Case.getCurrentCase().getSleuthkitCase();
|
||||
public SleuthkitCase getCurrentSleuthkitCaseDb() throws NoCurrentCaseException {
|
||||
return Case.getOpenCase().getSleuthkitCase();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2013-2014 Basis Technology Corp.
|
||||
* Copyright 2013-2018 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -42,6 +42,7 @@ import org.netbeans.api.progress.ProgressHandle;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
|
||||
import org.sleuthkit.autopsy.casemodule.services.FileManager;
|
||||
import org.sleuthkit.autopsy.coreutils.FileUtil;
|
||||
@ -252,7 +253,12 @@ class SevenZipExtractor {
|
||||
*/
|
||||
@Messages({"SevenZipExtractor.indexError.message=Failed to index encryption detected artifact for keyword search."})
|
||||
void unpack(AbstractFile archiveFile) {
|
||||
blackboard = Case.getCurrentCase().getServices().getBlackboard();
|
||||
try {
|
||||
blackboard = Case.getOpenCase().getServices().getBlackboard();
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
logger.log(Level.INFO, "Exception while getting open case.", ex); //NON-NLS
|
||||
return;
|
||||
}
|
||||
String archiveFilePath;
|
||||
try {
|
||||
archiveFilePath = archiveFile.getUniquePath();
|
||||
@ -518,8 +524,8 @@ class SevenZipExtractor {
|
||||
}
|
||||
}
|
||||
|
||||
} catch (TskCoreException e) {
|
||||
logger.log(Level.SEVERE, "Error populating complete derived file hierarchy from the unpacked dir structure"); //NON-NLS
|
||||
} catch (TskCoreException | NoCurrentCaseException e) {
|
||||
logger.log(Level.SEVERE, "Error populating complete derived file hierarchy from the unpacked dir structure", e); //NON-NLS
|
||||
//TODO decide if anything to cleanup, for now bailing
|
||||
}
|
||||
|
||||
@ -839,8 +845,8 @@ class SevenZipExtractor {
|
||||
* Traverse the tree top-down after unzipping is done and create derived
|
||||
* files for the entire hierarchy
|
||||
*/
|
||||
void addDerivedFilesToCase() throws TskCoreException {
|
||||
final FileManager fileManager = Case.getCurrentCase().getServices().getFileManager();
|
||||
void addDerivedFilesToCase() throws TskCoreException, NoCurrentCaseException {
|
||||
final FileManager fileManager = Case.getOpenCase().getServices().getFileManager();
|
||||
for (UnpackedNode child : rootNode.children) {
|
||||
addDerivedFilesToCaseRec(child, fileManager);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2012-2014 Basis Technology Corp.
|
||||
* Copyright 2012-2018 Basis Technology Corp.
|
||||
*
|
||||
* Copyright 2012 42six Solutions.
|
||||
* Contact: aebadirad <at> 42six <dot> com
|
||||
@ -30,6 +30,7 @@ import java.util.logging.Level;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||
@ -106,15 +107,19 @@ abstract class Extract {
|
||||
*
|
||||
* @param bbart Blackboard artifact to be indexed
|
||||
*/
|
||||
@Messages({"Extract.indexError.message=Failed to index artifact for keyword search."})
|
||||
@Messages({"Extract.indexError.message=Failed to index artifact for keyword search.",
|
||||
"Extract.noOpenCase.errMsg=No open case available."})
|
||||
void indexArtifact(BlackboardArtifact bbart) {
|
||||
Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard();
|
||||
try {
|
||||
Blackboard blackboard = Case.getOpenCase().getServices().getBlackboard();
|
||||
// index the artifact for keyword search
|
||||
blackboard.indexArtifact(bbart);
|
||||
} catch (Blackboard.BlackboardException ex) {
|
||||
logger.log(Level.SEVERE, "Unable to index blackboard artifact " + bbart.getDisplayName(), ex); //NON-NLS
|
||||
MessageNotifyUtil.Notify.error(Bundle.Extract_indexError_message(), bbart.getDisplayName());
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
|
||||
MessageNotifyUtil.Notify.error(Bundle.Extract_noOpenCase_errMsg(), bbart.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011-2016 Basis Technology Corp.
|
||||
* Copyright 2011-2018 Basis Technology Corp.
|
||||
*
|
||||
* Copyright 2012 42six Solutions.
|
||||
* Contact: aebadirad <at> 42six <dot> com
|
||||
@ -44,6 +44,7 @@ import java.util.Scanner;
|
||||
import java.util.stream.Collectors;
|
||||
import org.openide.modules.InstalledFileLocator;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.datamodel.ContentUtils;
|
||||
import org.sleuthkit.autopsy.ingest.IngestServices;
|
||||
import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
|
||||
@ -72,9 +73,9 @@ class ExtractIE extends Extract {
|
||||
private Content dataSource;
|
||||
private IngestJobContext context;
|
||||
|
||||
ExtractIE() {
|
||||
ExtractIE() throws NoCurrentCaseException {
|
||||
moduleName = NbBundle.getMessage(ExtractIE.class, "ExtractIE.moduleName.text");
|
||||
moduleTempResultsDir = RAImageIngestModule.getRATempPath(Case.getCurrentCase(), "IE") + File.separator + "results"; //NON-NLS
|
||||
moduleTempResultsDir = RAImageIngestModule.getRATempPath(Case.getOpenCase(), "IE") + File.separator + "results"; //NON-NLS
|
||||
JAVA_PATH = PlatformUtil.getJavaPath();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2012-2014 Basis Technology Corp.
|
||||
* Copyright 2012-2018 Basis Technology Corp.
|
||||
*
|
||||
* Copyright 2012 42six Solutions.
|
||||
* Contact: aebadirad <at> 42six <dot> com
|
||||
@ -27,9 +27,9 @@ import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.ingest.DataSourceIngestModule;
|
||||
import org.sleuthkit.autopsy.ingest.DataSourceIngestModuleProgress;
|
||||
@ -59,9 +59,14 @@ public final class RAImageIngestModule implements DataSourceIngestModule {
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
this.context = context;
|
||||
|
||||
|
||||
Extract iexplore;
|
||||
try {
|
||||
iexplore = new ExtractIE();
|
||||
} catch (NoCurrentCaseException ex) {
|
||||
throw new IngestModuleException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
Extract registry = new ExtractRegistry();
|
||||
Extract iexplore = new ExtractIE();
|
||||
Extract recentDocuments = new RecentDocumentsByLnk();
|
||||
Extract chrome = new Chrome();
|
||||
Extract firefox = new Firefox();
|
||||
|
Loading…
x
Reference in New Issue
Block a user