diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/DataSourceLoader.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/DataSourceLoader.java index 117d45bc90..8bafeef885 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/DataSourceLoader.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/DataSourceLoader.java @@ -69,7 +69,7 @@ public class DataSourceLoader { public Map getDataSourceMap() throws NoCurrentCaseException, TskCoreException, SQLException { Map dataSouceMap = new HashMap<>(); - Case currentCase = Case.getOpenCase(); + Case currentCase = Case.getCurrentCaseThrows(); SleuthkitCase tskDb = currentCase.getSleuthkitCase(); loadLogicalSources(tskDb, dataSouceMap); diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IngestedWithHashAlgOnly.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IngestedWithHashAlgOnly.java index 1358f50d8a..2f0d52245f 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IngestedWithHashAlgOnly.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IngestedWithHashAlgOnly.java @@ -21,11 +21,8 @@ package org.sleuthkit.autopsy.commonfilessearch; import java.sql.SQLException; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import junit.framework.Test; import org.netbeans.junit.NbModuleSuite; import org.openide.util.Exceptions; @@ -35,8 +32,6 @@ import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.commonfilesearch.AllDataSourcesCommonFilesAlgorithm; import org.sleuthkit.autopsy.commonfilesearch.CommonFilesMetadata; import org.sleuthkit.autopsy.commonfilesearch.CommonFilesMetadataBuilder; -import org.sleuthkit.autopsy.commonfilesearch.FileInstanceMetadata; -import org.sleuthkit.autopsy.commonfilesearch.Md5Metadata; import org.sleuthkit.autopsy.commonfilesearch.SingleDataSource; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType; @@ -46,6 +41,9 @@ import org.sleuthkit.autopsy.testutils.IngestUtils; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; +/** + * Add #1, #2, #3, and #4 to case and ingest with hash algorithm. + */ public class IngestedWithHashAlgOnly extends IntraCaseCommonFilesSearchTest { public static Test suite() { @@ -71,7 +69,7 @@ public class IngestedWithHashAlgOnly extends IntraCaseCommonFilesSearchTest { IngestJobSettings ingestJobSettings = new IngestJobSettings(IngestedWithHashAlgOnly.class.getCanonicalName(), IngestType.FILES_ONLY, templates); try { - IngestUtils.runIngestJob(Case.getOpenCase().getDataSources(), ingestJobSettings); + IngestUtils.runIngestJob(Case.getCurrentCaseThrows().getDataSources(), ingestJobSettings); } catch (NoCurrentCaseException | TskCoreException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); @@ -79,12 +77,8 @@ public class IngestedWithHashAlgOnly extends IntraCaseCommonFilesSearchTest { } /** - * Add #1, #2, #3, and #4 to case and ingest with hash algorithm. Find all - * matches & all file types. Confirm file.jpg is found on all three and - * file.docx is found on two. Find matches on ‘#1’ & all file types. Confirm - * same results. Find matches on ‘#2 & all file types: Confirm file.jpg. - * Find matches on ‘#3’ & all file types: Confirm file.jpg and file.docx. - * Find matches on #4 & all file types: Confirm nothing is found + * Find all matches & all file types. Confirm file.jpg is found on all three and + * file.docx is found on two. */ public void testOne() { try { @@ -92,11 +86,27 @@ public class IngestedWithHashAlgOnly extends IntraCaseCommonFilesSearchTest { CommonFilesMetadataBuilder allSourcesBuilder = new AllDataSourcesCommonFilesAlgorithm(dataSources, false, false); CommonFilesMetadata metadata = allSourcesBuilder.findCommonFiles(); - + Map objectIdToDataSource = mapFileInstancesToDataSources(metadata); - + List files = getFiles(objectIdToDataSource.keySet()); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET1, 2)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET2, 1)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET3, 1)); + + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 1)); + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 3)); + + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET4, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET4, 0)); } catch (NoCurrentCaseException ex) { @@ -107,31 +117,14 @@ public class IngestedWithHashAlgOnly extends IntraCaseCommonFilesSearchTest { Exceptions.printStackTrace(ex); } } - - private boolean fileExists(List files, String name, String dataSource, int count){ - for (AbstractFile file : files){ - - Long id = file.getId(); - - String fileName = file.getName(); - - final String dataSourceName = objectIdToDataSource.get(id); - - switch(fileName){ - case "IMG_6175.jpg": - - case "BasicStyleGuide.doc": - case "asdf.pdf": - case "file.dat": - - } - } - } - - private boolean fileExists(List files, String name, String dataSource){ - return fileExists(files, name, dataSource, 1); - } + + + /** + * Find matches on ‘#1’ & all file types. Confirm + * same results. + * + */ public void testTwo() { try { Map dataSources = this.dataSourceLoader.getDataSourceMap(); @@ -139,40 +132,146 @@ public class IngestedWithHashAlgOnly extends IntraCaseCommonFilesSearchTest { CommonFilesMetadataBuilder singleSourceBuilder = new SingleDataSource(first, dataSources, false, false); CommonFilesMetadata metadata = singleSourceBuilder.findCommonFiles(); - + Map objectIdToDataSource = mapFileInstancesToDataSources(metadata); + + List files = getFiles(objectIdToDataSource.keySet()); + + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET1, 2)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET2, 1)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET3, 1)); + + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 1)); + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 3)); + + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET4, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET4, 0)); } catch (NoCurrentCaseException | TskCoreException | SQLException ex) { Exceptions.printStackTrace(ex); Assert.fail(ex); } } - - private Map mapFileInstancesToDataSources(CommonFilesMetadata metadata) { - Map instanceIdToDataSource = new HashMap<>(); - - for(Entry entry : metadata.getMetadata().entrySet()){ - for (FileInstanceMetadata md : entry.getValue().getMetadata()){ - instanceIdToDataSource.put(md.getObjectId(), md.getDataSourceName()); - } + + /** + * Find matches on ‘#2 & all file types: Confirm file.jpg. + * + */ + public void testThree(){ + try { + Map dataSources = this.dataSourceLoader.getDataSourceMap(); + Long second = new Long(2); + + CommonFilesMetadataBuilder singleSourceBuilder = new SingleDataSource(second, dataSources, false, false); + CommonFilesMetadata metadata = singleSourceBuilder.findCommonFiles(); + + Map objectIdToDataSource = mapFileInstancesToDataSources(metadata); + + List files = getFiles(objectIdToDataSource.keySet()); + + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET1, 2)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET2, 1)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET3, 1)); + + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET4, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET4, 0)); + + } catch (NoCurrentCaseException | TskCoreException | SQLException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex); } - - return instanceIdToDataSource; } - - private List getFiles(Set keySet) { - List files = new ArrayList<>(keySet.size()); - - for(Long id : keySet){ - try { - AbstractFile file = Case.getOpenCase().getSleuthkitCase().getAbstractFileById(id); - files.add(file); - } catch (NoCurrentCaseException | TskCoreException ex) { - Exceptions.printStackTrace(ex); - Assert.fail(ex); - } + + /** + * Find matches on #4 & all file types: Confirm nothing is found. + */ + public void testFour(){ + try { + Map dataSources = this.dataSourceLoader.getDataSourceMap(); + Long last = new Long(4); + + CommonFilesMetadataBuilder singleSourceBuilder = new SingleDataSource(last, dataSources, false, false); + CommonFilesMetadata metadata = singleSourceBuilder.findCommonFiles(); + + Map objectIdToDataSource = mapFileInstancesToDataSources(metadata); + + List files = getFiles(objectIdToDataSource.keySet()); + + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET3, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET4, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET4, 0)); + + } catch (NoCurrentCaseException | TskCoreException | SQLException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex); + } + } + + /** + * Find matches on ‘#3’ & all file types: Confirm file.jpg and file.docx. + */ + public void testFive(){ + try { + Map dataSources = this.dataSourceLoader.getDataSourceMap(); + Long third = new Long(3); + + CommonFilesMetadataBuilder singleSourceBuilder = new SingleDataSource(third, dataSources, false, false); + CommonFilesMetadata metadata = singleSourceBuilder.findCommonFiles(); + + Map objectIdToDataSource = mapFileInstancesToDataSources(metadata); + + List files = getFiles(objectIdToDataSource.keySet()); + + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET1, 2)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET2, 1)); + assertTrue(fileExists(files, objectIdToDataSource, IMG, SET3, 1)); + + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, DOC, SET1, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, PDF, SET4, 0)); + + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET1, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET2, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET3, 0)); + assertTrue(fileExists(files, objectIdToDataSource, EMPTY, SET4, 0)); + + } catch (NoCurrentCaseException | TskCoreException | SQLException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex); } - - return files; } } diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IntraCaseCommonFilesSearchTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IntraCaseCommonFilesSearchTest.java index 25a322a1af..1933597089 100644 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IntraCaseCommonFilesSearchTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/commonfilessearch/IntraCaseCommonFilesSearchTest.java @@ -21,15 +21,51 @@ package org.sleuthkit.autopsy.commonfilessearch; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.netbeans.junit.NbTestCase; +import org.openide.util.Exceptions; +import org.python.icu.impl.Assert; +import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.ImageDSProcessor; +import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; +import org.sleuthkit.autopsy.commonfilesearch.CommonFilesMetadata; import org.sleuthkit.autopsy.commonfilesearch.DataSourceLoader; +import org.sleuthkit.autopsy.commonfilesearch.FileInstanceMetadata; +import org.sleuthkit.autopsy.commonfilesearch.Md5Metadata; import org.sleuthkit.autopsy.testutils.CaseUtils; import org.sleuthkit.autopsy.testutils.IngestUtils; +import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.datamodel.TskCoreException; /** * - * @author bsweeney + * Provides setup and utility for testing presence of files in different data + * sets discoverable by Common Files Features. + * + * Data set definitions: + * + * set 1 + * + file1 + * - IMG_6175.jpg + * + file2 + * - IMG_6175.jpg + * + file3 + * - BasicStyleGuide.doc + * + * set 2 + * - adsf.pdf + * - IMG_6175.jpg + * + * set 3 + * - BasicStyleGuide.doc + * - IMG_6175.jpg + * + * set 4 + * - file.dat (empty file) */ public abstract class IntraCaseCommonFilesSearchTest extends NbTestCase { @@ -40,6 +76,16 @@ public abstract class IntraCaseCommonFilesSearchTest extends NbTestCase { private final Path IMAGE_PATH_2 = Paths.get(this.getDataDir().toString(), "3776", "commonfiles_image2_v1.vhd"); private final Path IMAGE_PATH_3 = Paths.get(this.getDataDir().toString(), "3776", "commonfiles_image3_v1.vhd"); protected final Path IMAGE_PATH_4 = Paths.get(this.getDataDir().toString(), "3776", "commonfiles_image4_v1.vhd"); + + protected final String IMG = "IMG_6175.jpg"; + protected final String DOC = "BasicStyleGuide.doc"; + protected final String PDF = "adsf.pdf"; + protected final String EMPTY = "file.dat"; + + protected final String SET1 = "commonfiles_image1_v1.vhd"; + protected final String SET2 = "commonfiles_image2_v1.vhd"; + protected final String SET3 = "commonfiles_image3_v1.vhd"; + protected final String SET4 = "commonfiles_image4_v1.vhd"; protected DataSourceLoader dataSourceLoader; @@ -50,7 +96,7 @@ public abstract class IntraCaseCommonFilesSearchTest extends NbTestCase { @Override public void setUp() { - CaseUtils.createCase(CASE_DIRECTORY_PATH); + CaseUtils.createCase(CASE_DIRECTORY_PATH, "IntraCaseCommonFilesSearchTests"); IngestUtils.addDataSource(new ImageDSProcessor(), IMAGE_PATH_1); IngestUtils.addDataSource(new ImageDSProcessor(), IMAGE_PATH_2); @@ -65,4 +111,56 @@ public abstract class IntraCaseCommonFilesSearchTest extends NbTestCase { CaseUtils.closeCase(); CaseUtils.deleteCaseDir(CASE_DIRECTORY_PATH); } + + protected boolean fileExists(List files, Map objectIdToDataSource, String name, String dataSource, int count) { + + int tally = 0; + + for (AbstractFile file : files) { + + Long id = file.getId(); + + String fileName = file.getName(); + + String dataSourceName = objectIdToDataSource.get(id); + + if (fileName.equals(name) && dataSourceName.equals(dataSource)) { + tally++; + } + } + + return tally == count; + } + + protected boolean fileExists(List files, Map objectIdToDataSource, String name, String dataSource) { + return fileExists(files, objectIdToDataSource, name, dataSource, 1); + } + + protected Map mapFileInstancesToDataSources(CommonFilesMetadata metadata) { + Map instanceIdToDataSource = new HashMap<>(); + + for (Map.Entry entry : metadata.getMetadata().entrySet()) { + for (FileInstanceMetadata md : entry.getValue().getMetadata()) { + instanceIdToDataSource.put(md.getObjectId(), md.getDataSourceName()); + } + } + + return instanceIdToDataSource; + } + + protected List getFiles(Set keySet) { + List files = new ArrayList<>(keySet.size()); + + for (Long id : keySet) { + try { + AbstractFile file = Case.getCurrentCaseThrows().getSleuthkitCase().getAbstractFileById(id); + files.add(file); + } catch (NoCurrentCaseException | TskCoreException ex) { + Exceptions.printStackTrace(ex); + Assert.fail(ex); + } + } + + return files; + } } diff --git a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties index b1adb5d40b..9a9a904cc5 100644 --- a/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties +++ b/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties @@ -1,5 +1,5 @@ #Updated by build script -#Mon, 19 Mar 2018 11:17:11 -0700 +#Tue, 08 May 2018 10:29:55 -0600 LBL_splash_window_title=Starting Autopsy SPLASH_HEIGHT=314 SPLASH_WIDTH=538 @@ -8,4 +8,4 @@ SplashRunningTextBounds=0,289,538,18 SplashRunningTextColor=0x0 SplashRunningTextFontSize=19 -currentVersion=Autopsy 4.6.0 +currentVersion=Autopsy 4.7.0 diff --git a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties index 6cb9d4bdea..db3cd01af5 100644 --- a/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties +++ b/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties @@ -1,4 +1,4 @@ #Updated by build script -#Fri, 09 Mar 2018 13:03:41 -0700 -CTL_MainWindow_Title=Autopsy 4.6.0 -CTL_MainWindow_Title_No_Project=Autopsy 4.6.0 +#Tue, 08 May 2018 10:29:55 -0600 +CTL_MainWindow_Title=Autopsy 4.7.0 +CTL_MainWindow_Title_No_Project=Autopsy 4.7.0