From db74d751ae07ef47540e2e54788e1f41fc9a9f40 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Fri, 5 Apr 2019 16:58:56 -0400 Subject: [PATCH 1/4] Initial check in of fix for admin data source deletion --- .../autoingest/Bundle.properties-MERGED | 9 +++-- .../autoingest/DeleteCaseTask.java | 37 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED index b5316c4bc1..cc7704604a 100755 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED @@ -89,6 +89,10 @@ AutoIngestControlPanel.runningTable.toolTipText=The Running table displays the c AutoIngestControlPanel.SharedConfigurationDisabled=Shared configuration disabled AutoIngestControlPanel.ShowLogFailed.Message=Case log file does not exist AutoIngestControlPanel.ShowLogFailed.Title=Unable to display case log +# {0} - case db status +# {1} - search svc Status +# {2} - coord svc Status +# {3} - msg broker status AutoIngestControlPanel.tbServicesStatusMessage.Message=Case databases {0}, keyword search {1}, coordination {2}, messaging {3} AutoIngestControlPanel.tbServicesStatusMessage.Message.Down=down AutoIngestControlPanel.tbServicesStatusMessage.Message.Unknown=unknown @@ -182,9 +186,8 @@ DeleteCaseTask.progress.acquiringManifestLocks=Acquiring exclusive manifest file DeleteCaseTask.progress.connectingToCoordSvc=Connecting to the coordination service... DeleteCaseTask.progress.deletingCaseDirCoordSvcNode=Deleting case directory znode... DeleteCaseTask.progress.deletingCaseNameCoordSvcNode=Deleting case name znode... -# {0} - data source name -# {1} - device id -DeleteCaseTask.progress.deletingDataSource=Deleting data source {0} with device id {1}... +# {0} - data source path +DeleteCaseTask.progress.deletingDataSource=Deleting data source {0}... DeleteCaseTask.progress.deletingJobLogLockNode=Deleting case auto ingest log znode... # {0} - manifest file path DeleteCaseTask.progress.deletingManifest=Deleting manifest file {0}... diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java index 915fde13fe..c585dbd2bb 100755 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java @@ -594,12 +594,12 @@ final class DeleteCaseTask implements Runnable { * otherwise. */ @NbBundle.Messages({ - "# {0} - data source name", "# {1} - device id", "DeleteCaseTask.progress.deletingDataSource=Deleting data source {0} with device id {1}...",}) + "# {0} - data source path", "DeleteCaseTask.progress.deletingDataSource=Deleting data source {0}..." + }) private boolean deleteDataSources(Manifest manifest, List dataSources) { - final String dataSourceFileName = manifest.getDataSourceFileName(); - final String dataSourceDeviceId = manifest.getDeviceId(); - progress.progress(Bundle.DeleteCaseTask_progress_deletingDataSource(dataSourceFileName, dataSourceDeviceId)); - logger.log(Level.INFO, String.format("Deleting data source %s with device id %s from %s", dataSourceFileName, dataSourceDeviceId, caseNodeData.getDisplayName())); + final Path dataSourcePath = manifest.getDataSourcePath(); + progress.progress(Bundle.DeleteCaseTask_progress_deletingDataSource(dataSourcePath)); + logger.log(Level.INFO, String.format("Deleting data source %s from %s", dataSourcePath, caseNodeData.getDisplayName())); /* * There are two possibilities here. The data source may be an image, @@ -609,26 +609,27 @@ final class DeleteCaseTask implements Runnable { * set, report file, archive file, etc.). In this case, just the file * referenced by the manifest will be deleted. */ - boolean allFilesDeleted = true; Set filesToDelete = new HashSet<>(); - for (DataSource dataSource : dataSources) { + int index = 0; + while (index < dataSources.size() && filesToDelete.isEmpty()) { + DataSource dataSource = dataSources.get(index); if (dataSource instanceof Image) { Image image = (Image) dataSource; - if (image.getName().equals(dataSourceFileName) && image.getDeviceId().equals(dataSourceDeviceId)) { - String[] imageFilePaths = image.getPaths(); - for (String path : imageFilePaths) { - Path imageFilePath = Paths.get(path); - filesToDelete.add(imageFilePath); + String[] imageFilePaths = image.getPaths(); + for (String imageFilePath : imageFilePaths) { + Path candidatePath = Paths.get(imageFilePath); + if (candidatePath.equals(dataSourcePath)) { + for (String path : imageFilePaths) { + filesToDelete.add(Paths.get(path)); + } + break; } - break; } } } - if (filesToDelete.isEmpty()) { - final Path dataSourcePath = manifest.getDataSourcePath(); - filesToDelete.add(dataSourcePath); - } - + filesToDelete.add(dataSourcePath); + + boolean allFilesDeleted = true; for (Path path : filesToDelete) { File fileOrDir = path.toFile(); if (fileOrDir.exists() && !FileUtil.deleteFileDir(fileOrDir)) { From 8c87b1313abd8ca8afa0f0f5b551519507c4d681 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Mon, 8 Apr 2019 14:50:38 -0400 Subject: [PATCH 2/4] Add comments to extended admin data src deletion --- .../autoingest/Bundle.properties-MERGED | 5 ----- .../autoingest/DeleteCaseTask.java | 22 ++++++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED index 18fa77ff35..3887732228 100755 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED @@ -89,10 +89,6 @@ AutoIngestControlPanel.runningTable.toolTipText=The Running table displays the c AutoIngestControlPanel.SharedConfigurationDisabled=Shared configuration disabled AutoIngestControlPanel.ShowLogFailed.Message=Case log file does not exist AutoIngestControlPanel.ShowLogFailed.Title=Unable to display case log -# {0} - case db status -# {1} - search svc Status -# {2} - coord svc Status -# {3} - msg broker status AutoIngestControlPanel.tbServicesStatusMessage.Message=Case databases {0}, keyword search {1}, coordination {2}, messaging {3} AutoIngestControlPanel.tbServicesStatusMessage.Message.Down=down AutoIngestControlPanel.tbServicesStatusMessage.Message.Unknown=unknown @@ -208,7 +204,6 @@ HINT_CasesDashboardTopComponent=This is an adminstrative dashboard for multi-use OpenAutoIngestLogAction.deletedLogErrorMsg=The case auto ingest log has been deleted. OpenAutoIngestLogAction.logOpenFailedErrorMsg=Failed to open case auto ingest log. See application log for details. OpenAutoIngestLogAction.menuItemText=Open Auto Ingest Log File -# {0} - caseErrorMessage OpenCaseAction.errorMsg=Failed to open case: {0} OpenCaseAction.menuItemText=Open OpenIDE-Module-Long-Description=This module contains features that are being developed by Basis Technology and are not part of the default Autopsy distribution. You can enable this module to use the new features. The features should be stable, but their exact behavior and API are subject to change.\n\nWe make no guarantee that the API of this module will not change, so developers should be careful when relying on it. diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java index d1f0347597..d2c07264d2 100755 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java @@ -613,9 +613,17 @@ final class DeleteCaseTask implements Runnable { if (dataSource instanceof Image) { Image image = (Image) dataSource; String[] imageFilePaths = image.getPaths(); + /* + * Check for a match between one of the paths for the image + * files and the data source file path in the manifest. + */ for (String imageFilePath : imageFilePaths) { Path candidatePath = Paths.get(imageFilePath); if (candidatePath.equals(dataSourcePath)) { + /* + * If a match is found, add all of the file paths for + * the image to the set of files to be deleted. + */ for (String path : imageFilePaths) { filesToDelete.add(Paths.get(path)); } @@ -624,8 +632,20 @@ final class DeleteCaseTask implements Runnable { } } } + + /* + * At a minimum, the data source at the file path given in the manifest + * should be deleted. If the data source is not a disk image, this will + * be the path of an archive, a logical file, or a logical directory. + * TODO-4933: Currently, the contents extracted from an archive are not + * deleted, nor are any additional files associated with a report data + * source. + */ filesToDelete.add(dataSourcePath); - + + /* + * Delete the file(s). + */ boolean allFilesDeleted = true; for (Path path : filesToDelete) { File fileOrDir = path.toFile(); From 1b1793a78b22248e30a0edb81de53c9a277f24af Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Mon, 8 Apr 2019 14:54:23 -0400 Subject: [PATCH 3/4] Fix bundle MERGE file for Experimental NBM --- .../autopsy/experimental/autoingest/Bundle.properties-MERGED | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED index 3887732228..18fa77ff35 100755 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/Bundle.properties-MERGED @@ -89,6 +89,10 @@ AutoIngestControlPanel.runningTable.toolTipText=The Running table displays the c AutoIngestControlPanel.SharedConfigurationDisabled=Shared configuration disabled AutoIngestControlPanel.ShowLogFailed.Message=Case log file does not exist AutoIngestControlPanel.ShowLogFailed.Title=Unable to display case log +# {0} - case db status +# {1} - search svc Status +# {2} - coord svc Status +# {3} - msg broker status AutoIngestControlPanel.tbServicesStatusMessage.Message=Case databases {0}, keyword search {1}, coordination {2}, messaging {3} AutoIngestControlPanel.tbServicesStatusMessage.Message.Down=down AutoIngestControlPanel.tbServicesStatusMessage.Message.Unknown=unknown @@ -204,6 +208,7 @@ HINT_CasesDashboardTopComponent=This is an adminstrative dashboard for multi-use OpenAutoIngestLogAction.deletedLogErrorMsg=The case auto ingest log has been deleted. OpenAutoIngestLogAction.logOpenFailedErrorMsg=Failed to open case auto ingest log. See application log for details. OpenAutoIngestLogAction.menuItemText=Open Auto Ingest Log File +# {0} - caseErrorMessage OpenCaseAction.errorMsg=Failed to open case: {0} OpenCaseAction.menuItemText=Open OpenIDE-Module-Long-Description=This module contains features that are being developed by Basis Technology and are not part of the default Autopsy distribution. You can enable this module to use the new features. The features should be stable, but their exact behavior and API are subject to change.\n\nWe make no guarantee that the API of this module will not change, so developers should be careful when relying on it. From 5dca160fd28445eb2325ae1fa56e1545a91c5de1 Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Mon, 8 Apr 2019 15:31:12 -0400 Subject: [PATCH 4/4] Fix loop counter increment bug in admin case deletion --- .../autopsy/experimental/autoingest/DeleteCaseTask.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java index d2c07264d2..eef60f8a36 100755 --- a/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java +++ b/Experimental/src/org/sleuthkit/autopsy/experimental/autoingest/DeleteCaseTask.java @@ -631,6 +631,7 @@ final class DeleteCaseTask implements Runnable { } } } + ++index; } /*