From 968eea2b7d8bc2dd488cac7a78e59e8ec36c5aaf Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 22 May 2018 11:24:22 -0400 Subject: [PATCH 1/4] Fix issues with EncryptionDetectionTest following bad merge --- .../EncryptionDetectionTest.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java b/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java index 6bc7c7b3da..30124789b8 100755 --- a/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java +++ b/Core/test/qa-functional/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionTest.java @@ -51,14 +51,14 @@ import org.sleuthkit.datamodel.VolumeSystem; public class EncryptionDetectionTest extends NbTestCase { private static final String BITLOCKER_CASE_NAME = "testBitlockerEncryption"; - private static final Path BITLOCKER_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "encryption_detection_bitlocker_test.vhd"); + private final Path BITLOCKER_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "encryption_detection_bitlocker_test.vhd"); private static final String SQLCIPHER_DETECTION_CASE_NAME = "SQLCipherDetectionTest"; - private static final Path SQLCIPHER_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "encryption_detection_sqlcipher_test.vhd"); + private final Path SQLCIPHER_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "encryption_detection_sqlcipher_test.vhd"); private static final String PASSWORD_DETECTION_CASE_NAME = "PasswordDetectionTest"; - private static final Path PASSWORD_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "password_detection_test.img"); + private final Path PASSWORD_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "password_detection_test.img"); private static final String VERACRYPT_DETECTION_CASE_NAME = "VeraCryptDetectionTest"; - private static final Path VERACRYPT_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "veracrypt_detection_test.vhd"); - + private final Path VERACRYPT_DETECTION_IMAGE_PATH = Paths.get(this.getDataDir().toString(), "veracrypt_detection_test.vhd"); + public static Test suite() { NbModuleSuite.Configuration conf = NbModuleSuite.createConfiguration(EncryptionDetectionTest.class). clusters(".*"). @@ -90,7 +90,7 @@ public class EncryptionDetectionTest extends NbTestCase { */ ArrayList templates = new ArrayList<>(); templates.add(IngestUtils.getIngestModuleTemplate(new EncryptionDetectionModuleFactory())); - IngestJobSettings ingestJobSettings = new IngestJobSettings(PASSWORD_DETECTION_CASE_NAME, IngestType.FILES_ONLY, templates); + IngestJobSettings ingestJobSettings = new IngestJobSettings(SQLCIPHER_DETECTION_CASE_NAME, IngestType.FILES_ONLY, templates); IngestUtils.runIngestJob(openCase.getDataSources(), ingestJobSettings); /* @@ -144,9 +144,11 @@ public class EncryptionDetectionTest extends NbTestCase { */ public void testBitlockerEncryption() { try { - CaseUtils.createCase(BITLOCKER_CASE_DIRECTORY_PATH, BITLOCKER_CASE_NAME); + + CaseUtils.createCase(BITLOCKER_CASE_NAME); ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); IngestUtils.addDataSource(dataSourceProcessor, BITLOCKER_IMAGE_PATH); + Case openCase = Case.getCurrentCaseThrows(); IngestModuleFactory ingestModuleFactory = new EncryptionDetectionModuleFactory(); IngestModuleIngestJobSettings settings = ingestModuleFactory.getDefaultIngestJobSettings(); IngestModuleTemplate template = new IngestModuleTemplate(ingestModuleFactory, settings); @@ -211,12 +213,12 @@ public class EncryptionDetectionTest extends NbTestCase { public void testPasswordProtection() { try { CaseUtils.createCase(PASSWORD_DETECTION_CASE_NAME); - + ImageDSProcessor dataSourceProcessor = new ImageDSProcessor(); List errorMessages = IngestUtils.addDataSource(dataSourceProcessor, PASSWORD_DETECTION_IMAGE_PATH); String joinedErrors = String.join(System.lineSeparator(), errorMessages); assertEquals(joinedErrors, 0, errorMessages.size()); - + Case openCase = Case.getCurrentCaseThrows(); /* From 3fd5a526dbea3c59a1e8516e6f3589712a627803 Mon Sep 17 00:00:00 2001 From: esaunders Date: Tue, 22 May 2018 15:24:48 -0400 Subject: [PATCH 2/4] Fix snapshot refresh issues by passing latest job state along with each event. --- .../autoingest/AutoIngestAdminActions.java | 2 +- .../autoingest/AutoIngestDashboard.java | 6 +-- .../autoingest/AutoIngestJobsNode.java | 11 +++-- .../autoingest/AutoIngestJobsPanel.java | 4 +- .../AutoIngestNodeRefreshEvents.java | 47 ++++++++++++++----- .../autoingest/PrioritizationAction.java | 21 ++++----- 6 files changed, 57 insertions(+), 34 deletions(-) diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java index f17372f055..87c805fa12 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestAdminActions.java @@ -338,7 +338,7 @@ final class AutoIngestAdminActions { dashboard.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); AutoIngestManager.CaseDeletionResult result = dashboard.getMonitor().deleteCase(job); - dashboard.getCompletedJobsPanel().refresh(dashboard.getMonitor().getJobsSnapshot(), new AutoIngestNodeRefreshEvents.RefreshChildrenEvent()); + dashboard.getCompletedJobsPanel().refresh(new AutoIngestNodeRefreshEvents.RefreshChildrenEvent(dashboard.getMonitor().getJobsSnapshot())); dashboard.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); if (AutoIngestManager.CaseDeletionResult.FAILED == result) { JOptionPane.showMessageDialog(dashboard, diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboard.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboard.java index fc486dcfa2..f191823dc2 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboard.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestDashboard.java @@ -271,9 +271,9 @@ final class AutoIngestDashboard extends JPanel implements Observer { * @param nodeStateSnapshot The jobs snapshot. */ void refreshTables() { - pendingJobsPanel.refresh(autoIngestMonitor.getJobsSnapshot(), new RefreshChildrenEvent()); - runningJobsPanel.refresh(autoIngestMonitor.getJobsSnapshot(), new RefreshChildrenEvent()); - completedJobsPanel.refresh(autoIngestMonitor.getJobsSnapshot(), new RefreshChildrenEvent()); + pendingJobsPanel.refresh(new RefreshChildrenEvent(autoIngestMonitor.getJobsSnapshot())); + runningJobsPanel.refresh(new RefreshChildrenEvent(autoIngestMonitor.getJobsSnapshot())); + completedJobsPanel.refresh(new RefreshChildrenEvent(autoIngestMonitor.getJobsSnapshot())); } /** diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java index 55837299ae..15913dfba7 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsNode.java @@ -60,8 +60,8 @@ final class AutoIngestJobsNode extends AbstractNode { /** * Construct a new AutoIngestJobsNode. */ - AutoIngestJobsNode(JobsSnapshot jobsSnapshot, AutoIngestJobStatus status, EventBus eventBus) { - super(Children.create(new AutoIngestNodeChildren(jobsSnapshot, status, eventBus), false)); + AutoIngestJobsNode(AutoIngestJobStatus status, EventBus eventBus) { + super(Children.create(new AutoIngestNodeChildren(status, eventBus), false)); refreshChildrenEventBus = eventBus; } @@ -78,7 +78,7 @@ final class AutoIngestJobsNode extends AbstractNode { static final class AutoIngestNodeChildren extends ChildFactory { private final AutoIngestJobStatus autoIngestJobStatus; - private final JobsSnapshot jobsSnapshot; + private JobsSnapshot jobsSnapshot; private final RefreshChildrenSubscriber refreshChildrenSubscriber = new RefreshChildrenSubscriber(); private final EventBus refreshEventBus; @@ -89,8 +89,8 @@ final class AutoIngestJobsNode extends AbstractNode { * @param snapshot the snapshot which contains the AutoIngestJobs * @param status the status of the jobs being displayed */ - AutoIngestNodeChildren(JobsSnapshot snapshot, AutoIngestJobStatus status, EventBus eventBus) { - jobsSnapshot = snapshot; + AutoIngestNodeChildren(AutoIngestJobStatus status, EventBus eventBus) { + jobsSnapshot = new JobsSnapshot(); autoIngestJobStatus = status; refreshEventBus = eventBus; refreshChildrenSubscriber.register(refreshEventBus); @@ -159,6 +159,7 @@ final class AutoIngestJobsNode extends AbstractNode { //Ignore netbeans suggesting this isn't being used, it is used behind the scenes by the EventBus //RefreshChildrenEvents can change which children are present however //RefreshJobEvents and RefreshCaseEvents can still change the order we want to display them in + jobsSnapshot = refreshEvent.getJobsSnapshot(); refresh(true); } diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsPanel.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsPanel.java index 561864df59..7818dd8d68 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsPanel.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestJobsPanel.java @@ -164,14 +164,14 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa * @param jobsSnapshot - the JobsSnapshot which will provide the new * contents */ - void refresh(JobsSnapshot jobsSnapshot, AutoIngestRefreshEvent refreshEvent) { + void refresh(AutoIngestRefreshEvent refreshEvent) { synchronized (this) { outline.setRowSelectionAllowed(false); if (explorerManager.getRootContext() instanceof AutoIngestJobsNode) { ((AutoIngestJobsNode) explorerManager.getRootContext()).refresh(refreshEvent); } else { //Make a new AutoIngestJobsNode with it's own EventBus and set it as the root context - explorerManager.setRootContext(new AutoIngestJobsNode(jobsSnapshot, status, new EventBus("AutoIngestJobsNodeEventBus"))); + explorerManager.setRootContext(new AutoIngestJobsNode(status, new EventBus("AutoIngestJobsNodeEventBus"))); } outline.setRowSelectionAllowed(true); outline.setFocusable(true); diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestNodeRefreshEvents.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestNodeRefreshEvents.java index c01158f44a..2c554bf00f 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestNodeRefreshEvents.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/AutoIngestNodeRefreshEvents.java @@ -18,6 +18,8 @@ */ package org.sleuthkit.autopsy.experimental.autoingest; +import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestMonitor.JobsSnapshot; + /** * Class which contains events to identify what should be refreshed in the * AutoIngestJobsNode @@ -25,23 +27,37 @@ package org.sleuthkit.autopsy.experimental.autoingest; class AutoIngestNodeRefreshEvents { /** - * An empty interface for all refresh events to implement. + * The base class for all refresh events. */ - interface AutoIngestRefreshEvent { + static class AutoIngestRefreshEvent { + private final JobsSnapshot jobsSnapshot; + + AutoIngestRefreshEvent(JobsSnapshot jobs) { + this.jobsSnapshot = jobs; + } + + /** + * Get the state of the jobs lists when the event was fired. + * + * @return + */ + JobsSnapshot getJobsSnapshot() { + return this.jobsSnapshot; + } } /** * An event to denote that the children of the AutoIngestJobsNode should be * refreshed but no specific nodes need their properties refreshed. */ - static final class RefreshChildrenEvent implements AutoIngestRefreshEvent { + static final class RefreshChildrenEvent extends AutoIngestRefreshEvent { /** * Constructs a RefreshChildrenEvent. */ - RefreshChildrenEvent() { - + RefreshChildrenEvent(JobsSnapshot jobs) { + super(jobs); } } @@ -49,14 +65,18 @@ class AutoIngestNodeRefreshEvents { * An event to denote that all nodes which represent jobs which are part of * the specified case should be refreshed. */ - static final class RefreshCaseEvent implements AutoIngestRefreshEvent { + static final class RefreshCaseEvent extends AutoIngestRefreshEvent { private final String caseName; /** - * Constructs a RefreshCaseEvent. + * Contructs a RefreshCaseEvent + * + * @param jobs The current state of the jobs lists. + * @param name The name of the case whose nodes should be refreshed. */ - RefreshCaseEvent(String name) { + RefreshCaseEvent(JobsSnapshot jobs, String name) { + super(jobs); caseName = name; } @@ -76,19 +96,23 @@ class AutoIngestNodeRefreshEvents { /** * An event to denote that a node for a specific job should be refreshed. */ - static final class RefreshJobEvent implements AutoIngestRefreshEvent { + static final class RefreshJobEvent extends AutoIngestRefreshEvent { private final AutoIngestJob autoIngestJob; /** * Constructs a RefreshJobEvent. + * + * @param jobs The curent state of the jobs lists. + * @param job The job which should be refreshed. */ - RefreshJobEvent(AutoIngestJob job) { + RefreshJobEvent(JobsSnapshot jobs, AutoIngestJob job) { + super(jobs); autoIngestJob = job; } /** - * Get the AutoIngestJob which should have it's node refresheds. + * Get the AutoIngestJob which should have it's node refreshed. * * @return autoIngestJob - the AutoIngestJob which should have it's node * refreshed @@ -97,5 +121,4 @@ class AutoIngestNodeRefreshEvents { return autoIngestJob; } } - } diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/PrioritizationAction.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/PrioritizationAction.java index 371fe71ad3..3d57057bff 100644 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/PrioritizationAction.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/PrioritizationAction.java @@ -27,7 +27,6 @@ import org.openide.util.NbBundle.Messages; import org.openide.windows.WindowManager; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; -import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestNodeRefreshEvents; /** * Abstract actions which are for the modification of AutoIngestJob or Case @@ -90,7 +89,7 @@ abstract class PrioritizationAction extends AbstractAction { EventQueue.invokeLater(() -> { try { modifyPriority(dashboard.getMonitor()); - dashboard.getPendingJobsPanel().refresh(dashboard.getMonitor().getJobsSnapshot(), getRefreshEvent()); + dashboard.getPendingJobsPanel().refresh(getRefreshEvent(dashboard.getMonitor())); } catch (AutoIngestMonitor.AutoIngestMonitorException ex) { String errorMessage = getErrorMessage(); logger.log(Level.SEVERE, errorMessage, ex); @@ -109,7 +108,7 @@ abstract class PrioritizationAction extends AbstractAction { return super.clone(); //To change body of generated methods, choose Tools | Templates. } - abstract AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent(); + abstract AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent(AutoIngestMonitor monitor); /** * Action to prioritize the specified AutoIngestJob @@ -145,8 +144,8 @@ abstract class PrioritizationAction extends AbstractAction { } @Override - AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent() { - return new AutoIngestNodeRefreshEvents.RefreshJobEvent(getJob()); + AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent(AutoIngestMonitor monitor) { + return new AutoIngestNodeRefreshEvents.RefreshJobEvent(monitor.getJobsSnapshot(), getJob()); } } @@ -184,8 +183,8 @@ abstract class PrioritizationAction extends AbstractAction { } @Override - AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent() { - return new AutoIngestNodeRefreshEvents.RefreshJobEvent(getJob()); + AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent(AutoIngestMonitor monitor) { + return new AutoIngestNodeRefreshEvents.RefreshJobEvent(monitor.getJobsSnapshot(), getJob()); } } @@ -225,8 +224,8 @@ abstract class PrioritizationAction extends AbstractAction { } @Override - AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent() { - return new AutoIngestNodeRefreshEvents.RefreshCaseEvent(getJob().getManifest().getCaseName()); + AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent(AutoIngestMonitor monitor) { + return new AutoIngestNodeRefreshEvents.RefreshCaseEvent(monitor.getJobsSnapshot(), getJob().getManifest().getCaseName()); } } @@ -266,8 +265,8 @@ abstract class PrioritizationAction extends AbstractAction { } @Override - AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent() { - return new AutoIngestNodeRefreshEvents.RefreshCaseEvent(getJob().getManifest().getCaseName()); + AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent getRefreshEvent(AutoIngestMonitor monitor) { + return new AutoIngestNodeRefreshEvents.RefreshCaseEvent(monitor.getJobsSnapshot(), getJob().getManifest().getCaseName()); } } } From c9a3b590dc92bc157c662fa4bcc8b1213fa441e7 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 22 May 2018 15:27:52 -0400 Subject: [PATCH 3/4] Add sqlcipher test image download back to build.xml --- Core/build.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/build.xml b/Core/build.xml index bd7674e56d..94c0c56825 100644 --- a/Core/build.xml +++ b/Core/build.xml @@ -85,6 +85,7 @@ + From 5386c936f276662b32bfb525dc3cb0fd52d57676 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 23 May 2018 11:57:47 -0400 Subject: [PATCH 4/4] Remove duplicate comment adding from flagFile in encryptionDetection module --- .../EncryptionDetectionFileIngestModule.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionFileIngestModule.java index 0d3144c65c..1d5d5d05d1 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/modules/encryptiondetection/EncryptionDetectionFileIngestModule.java @@ -184,10 +184,6 @@ final class EncryptionDetectionFileIngestModule extends FileIngestModuleAdapter private IngestModule.ProcessResult flagFile(AbstractFile file, BlackboardArtifact.ARTIFACT_TYPE artifactType, String comment) { try { BlackboardArtifact artifact = file.newArtifact(artifactType); - artifact.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COMMENT, - EncryptionDetectionModuleFactory.getModuleName(), comment) - ); - artifact.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COMMENT, EncryptionDetectionModuleFactory.getModuleName(), comment));