19 package org.sleuthkit.autopsy.report.modules.portablecase;
22 import java.util.logging.Level;
23 import java.io.BufferedReader;
25 import java.io.InputStreamReader;
26 import java.io.IOException;
27 import java.nio.file.Paths;
28 import java.sql.ResultSet;
29 import java.sql.SQLException;
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.HashMap;
33 import java.util.List;
35 import org.apache.commons.io.FileUtils;
36 import org.openide.modules.InstalledFileLocator;
37 import org.openide.util.NbBundle;
60 import org.
sleuthkit.datamodel.SleuthkitCase.CaseDbTransaction;
110 "PortableCaseReportModule.getName.name=Portable Case"
114 return Bundle.PortableCaseReportModule_getName_name();
118 "PortableCaseReportModule.getDescription.description=Copies selected items to a new single-user case that can be easily shared"
122 return Bundle.PortableCaseReportModule_getDescription_description();
142 logger.log(Level.INFO,
"Portable case creation canceled by user");
160 logger.log(Level.WARNING, logWarning);
162 logger.log(Level.SEVERE, logWarning, ex);
170 "PortableCaseReportModule.generateReport.verifying=Verifying selected parameters...",
171 "PortableCaseReportModule.generateReport.creatingCase=Creating portable case database...",
172 "PortableCaseReportModule.generateReport.copyingTags=Copying tags...",
174 "PortableCaseReportModule.generateReport.copyingFiles=Copying files tagged as {0}...",
176 "PortableCaseReportModule.generateReport.copyingArtifacts=Copying artifacts tagged as {0}...",
177 "# {0} - output folder",
178 "PortableCaseReportModule.generateReport.outputDirDoesNotExist=Output folder {0} does not exist",
179 "# {0} - output folder",
180 "PortableCaseReportModule.generateReport.outputDirIsNotDir=Output folder {0} is not a folder",
181 "PortableCaseReportModule.generateReport.caseClosed=Current case has been closed",
182 "PortableCaseReportModule.generateReport.interestingItemError=Error loading intersting items",
183 "PortableCaseReportModule.generateReport.errorReadingTags=Error while reading tags from case database",
184 "PortableCaseReportModule.generateReport.errorReadingSets=Error while reading interesting items sets from case database",
185 "PortableCaseReportModule.generateReport.noContentToCopy=No interesting files, results, or tagged items to copy",
186 "PortableCaseReportModule.generateReport.errorCopyingTags=Error copying tags",
187 "PortableCaseReportModule.generateReport.errorCopyingFiles=Error copying tagged files",
188 "PortableCaseReportModule.generateReport.errorCopyingArtifacts=Error copying tagged artifacts",
189 "PortableCaseReportModule.generateReport.errorCopyingInterestingFiles=Error copying interesting files",
190 "PortableCaseReportModule.generateReport.errorCopyingInterestingResults=Error copying interesting results",
191 "PortableCaseReportModule.generateReport.errorCreatingImageTagTable=Error creating image tags table",
192 "# {0} - attribute type name",
193 "PortableCaseReportModule.generateReport.errorLookingUpAttrType=Error looking up attribute type {0}",
194 "PortableCaseReportModule.generateReport.compressingCase=Compressing case...",
195 "PortableCaseReportModule.generateReport.errorCreatingReportFolder=Could not make report folder",
196 "PortableCaseReportModule.generateReport.errorGeneratingUCOreport=Problem while generating CASE-UCO report"
200 this.settings = options;
202 progressPanel.
start();
203 progressPanel.
updateStatusLabel(Bundle.PortableCaseReportModule_generateReport_verifying());
209 File outputDir =
new File(reportPath);
210 if (! outputDir.exists()) {
211 handleError(
"Output folder " + outputDir.toString() +
" does not exist",
212 Bundle.PortableCaseReportModule_generateReport_outputDirDoesNotExist(outputDir.toString()), null, progressPanel);
216 if (! outputDir.isDirectory()) {
217 handleError(
"Output folder " + outputDir.toString() +
" is not a folder",
218 Bundle.PortableCaseReportModule_generateReport_outputDirIsNotDir(outputDir.toString()), null, progressPanel);
228 Bundle.PortableCaseReportModule_generateReport_caseClosed(), null, progressPanel);
233 List<TagName> tagNames;
239 Bundle.PortableCaseReportModule_generateReport_errorReadingTags(), ex, progressPanel);
246 List<String> setNames;
251 handleError(
"Unable to get all interesting items sets",
252 Bundle.PortableCaseReportModule_generateReport_errorReadingSets(), ex, progressPanel);
259 if (tagNames.isEmpty() && setNames.isEmpty()) {
261 Bundle.PortableCaseReportModule_generateReport_noContentToCopy(), null, progressPanel);
267 progressPanel.
updateStatusLabel(Bundle.PortableCaseReportModule_generateReport_creatingCase());
269 if (portableSkCase == null) {
283 }
catch (TskCoreException ex) {
284 handleError(
"Error creating image tag table", Bundle.PortableCaseReportModule_generateReport_errorCreatingImageTagTable(), ex, progressPanel);
289 progressPanel.
updateStatusLabel(Bundle.PortableCaseReportModule_generateReport_copyingTags());
291 for(TagName tagName:tagNames) {
292 TagName newTagName = portableSkCase.addOrUpdateTagName(tagName.getDisplayName(), tagName.getDescription(), tagName.getColor(), tagName.getKnownStatus());
293 oldTagNameToNewTagName.put(tagName, newTagName);
295 }
catch (TskCoreException ex) {
296 handleError(
"Error copying tags", Bundle.PortableCaseReportModule_generateReport_errorCopyingTags(), ex, progressPanel);
301 for (BlackboardArtifact.ARTIFACT_TYPE type:BlackboardArtifact.ARTIFACT_TYPE.values()) {
302 oldArtTypeIdToNewArtTypeId.put(type.getTypeID(), type.getTypeID());
304 for (BlackboardAttribute.ATTRIBUTE_TYPE type:BlackboardAttribute.ATTRIBUTE_TYPE.values()) {
307 }
catch (TskCoreException ex) {
308 handleError(
"Error looking up attribute name " + type.getLabel(),
309 Bundle.PortableCaseReportModule_generateReport_errorLookingUpAttrType(type.getLabel()),
316 for(TagName tagName:tagNames) {
322 progressPanel.
updateStatusLabel(Bundle.PortableCaseReportModule_generateReport_copyingFiles(tagName.getDisplayName()));
331 }
catch (TskCoreException ex) {
332 handleError(
"Error copying tagged files", Bundle.PortableCaseReportModule_generateReport_errorCopyingFiles(), ex, progressPanel);
338 for(TagName tagName:tagNames) {
344 progressPanel.
updateStatusLabel(Bundle.PortableCaseReportModule_generateReport_copyingArtifacts(tagName.getDisplayName()));
353 }
catch (TskCoreException ex) {
354 handleError(
"Error copying tagged artifacts", Bundle.PortableCaseReportModule_generateReport_errorCopyingArtifacts(), ex, progressPanel);
359 if (! setNames.isEmpty()) {
361 List<BlackboardArtifact> interestingFiles = currentCase.
getSleuthkitCase().getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
362 for (BlackboardArtifact art:interestingFiles) {
369 BlackboardAttribute setAttr = art.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME));
370 if (setNames.contains(setAttr.getValueString())) {
374 }
catch (TskCoreException ex) {
375 handleError(
"Error copying interesting files", Bundle.PortableCaseReportModule_generateReport_errorCopyingInterestingFiles(), ex, progressPanel);
380 List<BlackboardArtifact> interestingResults = currentCase.
getSleuthkitCase().getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT);
381 for (BlackboardArtifact art:interestingResults) {
387 BlackboardAttribute setAttr = art.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME));
388 if (setNames.contains(setAttr.getValueString())) {
392 }
catch (TskCoreException ex) {
393 handleError(
"Error copying interesting results", Bundle.PortableCaseReportModule_generateReport_errorCopyingInterestingResults(), ex, progressPanel);
404 File reportsFolder = Paths.get(caseFolder.toString(),
"Reports").toFile();
405 if(!reportsFolder.mkdir()) {
406 handleError(
"Could not make report folder", Bundle.PortableCaseReportModule_generateReport_errorCreatingReportFolder(), null, progressPanel);
413 handleError(
"Problem while generating CASE-UCO report",
414 Bundle.PortableCaseReportModule_generateReport_errorGeneratingUCOreport(), ex, progressPanel);
419 progressPanel.
updateStatusLabel(Bundle.PortableCaseReportModule_generateReport_compressingCase());
445 List<String> setNames =
new ArrayList<>();
446 Map<String, Long> setCounts;
450 String innerSelect =
"SELECT (value_text) AS set_name FROM blackboard_attributes WHERE (artifact_type_id = '"
451 + BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT.getTypeID() +
"' OR artifact_type_id = '"
452 + BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_ARTIFACT_HIT.getTypeID() +
"') AND attribute_type_id = '"
453 + BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID() +
"'";
456 String query =
"set_name, count(1) AS set_count FROM (" + innerSelect +
") set_names GROUP BY set_name";
461 setNames.addAll(setCounts.keySet());
474 "# {0} - case folder",
475 "PortableCaseReportModule.createCase.caseDirExists=Case folder {0} already exists",
476 "PortableCaseReportModule.createCase.errorCreatingCase=Error creating case",
478 "PortableCaseReportModule.createCase.errorCreatingFolder=Error creating folder {0}",
479 "PortableCaseReportModule.createCase.errorStoringMaxIds=Error storing maximum database IDs",
484 caseFolder = Paths.get(outputDir.toString(),
caseName).toFile();
486 if (caseFolder.exists()) {
487 handleError(
"Case folder " + caseFolder.toString() +
" already exists",
488 Bundle.PortableCaseReportModule_createCase_caseDirExists(caseFolder.toString()), null, progressPanel);
495 }
catch (TskCoreException ex) {
496 handleError(
"Error creating case " + caseName +
" in folder " + caseFolder.toString(),
497 Bundle.PortableCaseReportModule_createCase_errorCreatingCase(), ex, progressPanel);
504 }
catch (TskCoreException ex) {
506 Bundle.PortableCaseReportModule_createCase_errorStoringMaxIds(), ex, progressPanel);
511 copiedFilesFolder = Paths.get(caseFolder.toString(),
FILE_FOLDER_NAME).toFile();
512 if (! copiedFilesFolder.mkdir()) {
513 handleError(
"Error creating folder " + copiedFilesFolder.toString(),
514 Bundle.PortableCaseReportModule_createCase_errorCreatingFolder(copiedFilesFolder.toString()), null, progressPanel);
520 File subFolder = Paths.get(copiedFilesFolder.toString(), cat.getDisplayName()).toFile();
521 if (! subFolder.mkdir()) {
522 handleError(
"Error creating folder " + subFolder.toString(),
523 Bundle.PortableCaseReportModule_createCase_errorCreatingFolder(subFolder.toString()), null, progressPanel);
528 if (! unknownTypeFolder.mkdir()) {
529 handleError(
"Error creating folder " + unknownTypeFolder.toString(),
530 Bundle.PortableCaseReportModule_createCase_errorCreatingFolder(unknownTypeFolder.toString()), null, progressPanel);
543 CaseDbAccessManager currentCaseDbManager = currentCase.
getSleuthkitCase().getCaseDbAccessManager();
545 String tableSchema =
"( table_name TEXT PRIMARY KEY, "
548 portableSkCase.getCaseDbAccessManager().createTable(MAX_ID_TABLE_NAME, tableSchema);
550 currentCaseDbManager.select(
"max(obj_id) as max_id from tsk_objects",
new StoreMaxIdCallback(
"tsk_objects"));
551 currentCaseDbManager.select(
"max(tag_id) as max_id from content_tags",
new StoreMaxIdCallback(
"content_tags"));
552 currentCaseDbManager.select(
"max(tag_id) as max_id from blackboard_artifact_tags",
new StoreMaxIdCallback(
"blackboard_artifact_tags"));
553 currentCaseDbManager.select(
"max(examiner_id) as max_id from tsk_examiners",
new StoreMaxIdCallback(
"tsk_examiners"));
566 CaseDbAccessManager portableDbAccessManager = portableSkCase.getCaseDbAccessManager();
586 for (ContentTag tag : tags) {
593 Content content = tag.getContent();
594 if (content instanceof AbstractFile) {
599 if (! oldTagNameToNewTagName.containsKey(tag.getName())) {
600 throw new TskCoreException(
"TagName map is missing entry for ID " + tag.getName().getId() +
" with display name " + tag.getName().getDisplayName());
602 ContentTag newContentTag = portableSkCase.addContentTag(newIdToContent.get(newFileId), oldTagNameToNewTagName.get(tag.getName()), tag.getComment(), tag.getBeginByteOffset(), tag.getEndByteOffset());
607 if (! appData.isEmpty()) {
627 currentCase.
getSleuthkitCase().getCaseDbAccessManager().select(query, callback);
628 return callback.getAppData();
644 appData = rs.getString(
"app_data");
645 }
catch (SQLException ex) {
646 logger.log(Level.WARNING,
"Unable to get app_data from result set", ex);
649 }
catch (SQLException ex) {
650 logger.log(Level.WARNING,
"Failed to get next result for app_data", ex);
659 String getAppData() {
673 String insert =
"(content_tag_id, app_data) VALUES (" + newContentTag.getId() +
", '" + appData +
"')";
691 for (BlackboardArtifactTag tag : tags) {
699 Content content = tag.getContent();
703 BlackboardArtifact newArtifact =
copyArtifact(newContentId, tag.getArtifact());
706 if (! oldTagNameToNewTagName.containsKey(tag.getName())) {
707 throw new TskCoreException(
"TagName map is missing entry for ID " + tag.getName().getId() +
" with display name " + tag.getName().getDisplayName());
709 portableSkCase.addBlackboardArtifactTag(newArtifact, oldTagNameToNewTagName.get(tag.getName()), tag.getComment());
723 private BlackboardArtifact
copyArtifact(
long newContentId, BlackboardArtifact artifactToCopy)
throws TskCoreException {
725 if (oldArtifactIdToNewArtifact.containsKey(artifactToCopy.getArtifactID())) {
726 return oldArtifactIdToNewArtifact.get(artifactToCopy.getArtifactID());
730 BlackboardAttribute oldAssociatedAttribute = artifactToCopy.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
731 List<BlackboardAttribute> newAttrs =
new ArrayList<>();
732 if (oldAssociatedAttribute != null) {
733 BlackboardArtifact oldAssociatedArtifact = currentCase.
getSleuthkitCase().getBlackboardArtifact(oldAssociatedAttribute.getValueLong());
734 BlackboardArtifact newAssociatedArtifact =
copyArtifact(newContentId, oldAssociatedArtifact);
735 newAttrs.add(
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT,
736 String.join(
",", oldAssociatedAttribute.getSources()), newAssociatedArtifact.getArtifactID()));
741 BlackboardArtifact newArtifact = portableSkCase.newBlackboardArtifact(newArtifactTypeId, newContentId);
742 List<BlackboardAttribute> oldAttrs = artifactToCopy.getAttributes();
745 for (BlackboardAttribute oldAttr:oldAttrs) {
748 if (oldAttr.getAttributeType().getTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT.getTypeID()) {
753 switch (oldAttr.getValueType()) {
755 newAttrs.add(
new BlackboardAttribute(newAttributeType, String.join(
",", oldAttr.getSources()),
756 oldAttr.getValueBytes()));
759 newAttrs.add(
new BlackboardAttribute(newAttributeType, String.join(
",", oldAttr.getSources()),
760 oldAttr.getValueDouble()));
763 newAttrs.add(
new BlackboardAttribute(newAttributeType, String.join(
",", oldAttr.getSources()),
764 oldAttr.getValueInt()));
768 newAttrs.add(
new BlackboardAttribute(newAttributeType, String.join(
",", oldAttr.getSources()),
769 oldAttr.getValueLong()));
773 newAttrs.add(
new BlackboardAttribute(newAttributeType, String.join(
",", oldAttr.getSources()),
774 oldAttr.getValueString()));
777 throw new TskCoreException(
"Unexpected attribute value type found: " + oldAttr.getValueType().getLabel());
781 newArtifact.addAttributes(newAttrs);
783 oldArtifactIdToNewArtifact.put(artifactToCopy.getArtifactID(), newArtifact);
796 if (oldArtTypeIdToNewArtTypeId.containsKey(oldArtifact.getArtifactTypeID())) {
797 return oldArtTypeIdToNewArtTypeId.get(oldArtifact.getArtifactTypeID());
800 BlackboardArtifact.Type oldCustomType = currentCase.
getSleuthkitCase().getArtifactType(oldArtifact.getArtifactTypeName());
802 BlackboardArtifact.Type newCustomType = portableSkCase.addBlackboardArtifactType(oldCustomType.getTypeName(), oldCustomType.getDisplayName());
803 oldArtTypeIdToNewArtTypeId.put(oldArtifact.getArtifactTypeID(), newCustomType.getTypeID());
804 return newCustomType.getTypeID();
805 }
catch (TskDataException ex) {
806 throw new TskCoreException(
"Error creating new artifact type " + oldCustomType.getTypeName(), ex);
818 private BlackboardAttribute.Type
getNewAttributeType(BlackboardAttribute oldAttribute)
throws TskCoreException {
819 BlackboardAttribute.Type oldAttrType = oldAttribute.getAttributeType();
825 BlackboardAttribute.Type newCustomType = portableSkCase.addArtifactAttributeType(oldAttrType.getTypeName(),
826 oldAttrType.getValueType(), oldAttrType.getDisplayName());
828 return newCustomType;
829 }
catch (TskDataException ex) {
830 throw new TskCoreException(
"Error creating new attribute type " + oldAttrType.getTypeName(), ex);
846 "PortableCaseReportModule.copyContentToPortableCase.copyingFile=Copying file {0}",
849 progressPanel.
updateStatusLabel(Bundle.PortableCaseReportModule_copyContentToPortableCase_copyingFile(content.getUniquePath()));
862 private long copyContent(Content content)
throws TskCoreException {
865 if (oldIdToNewContent.containsKey(content.getId())) {
866 return oldIdToNewContent.get(content.getId()).getId();
873 if (content.getParent() != null) {
878 if (content instanceof BlackboardArtifact) {
879 BlackboardArtifact artifactToCopy = (BlackboardArtifact)content;
882 CaseDbTransaction trans = portableSkCase.beginTransaction();
884 if (content instanceof Image) {
885 Image image = (Image)content;
886 newContent = portableSkCase.addImage(image.getType(), image.getSsize(), image.getSize(), image.getName(),
887 new ArrayList<>(), image.getTimeZone(), image.getMd5(), image.getSha1(), image.getSha256(), image.getDeviceId(), trans);
888 }
else if (content instanceof VolumeSystem) {
889 VolumeSystem vs = (VolumeSystem)content;
890 newContent = portableSkCase.addVolumeSystem(parentId, vs.getType(), vs.getOffset(), vs.getBlockSize(), trans);
891 }
else if (content instanceof Volume) {
892 Volume vs = (Volume)content;
893 newContent = portableSkCase.addVolume(parentId, vs.getAddr(), vs.getStart(), vs.getLength(),
894 vs.getDescription(), vs.getFlags(), trans);
895 }
else if (content instanceof Pool) {
896 Pool pool = (Pool)content;
897 newContent = portableSkCase.addPool(parentId, pool.getType(), trans);
898 }
else if (content instanceof FileSystem) {
899 FileSystem fs = (FileSystem)content;
900 newContent = portableSkCase.addFileSystem(parentId, fs.getImageOffset(), fs.getFsType(), fs.getBlock_size(),
901 fs.getBlock_count(), fs.getRoot_inum(), fs.getFirst_inum(), fs.getLastInum(),
902 fs.getName(), trans);
903 }
else if (content instanceof BlackboardArtifact) {
904 BlackboardArtifact artifactToCopy = (BlackboardArtifact)content;
906 }
else if (content instanceof AbstractFile) {
907 AbstractFile abstractFile = (AbstractFile)content;
909 if (abstractFile instanceof LocalFilesDataSource) {
910 LocalFilesDataSource localFilesDS = (LocalFilesDataSource)abstractFile;
911 newContent = portableSkCase.addLocalFilesDataSource(localFilesDS.getDeviceId(), localFilesDS.getName(), localFilesDS.getTimeZone(), trans);
913 if (abstractFile.isDir()) {
914 newContent = portableSkCase.addLocalDirectory(parentId, abstractFile.getName(), trans);
920 File exportFolder = Paths.get(copiedFilesFolder.toString(), exportSubFolder).toFile();
921 File localFile =
new File(exportFolder, fileName);
925 Content oldParent = abstractFile.getParent();
926 if (! oldIdToNewContent.containsKey(oldParent.getId())) {
927 throw new TskCoreException(
"Parent of file with ID " + abstractFile.getId() +
" has not been created");
929 Content newParent = oldIdToNewContent.get(oldParent.getId());
932 String relativePath = FILE_FOLDER_NAME + File.separator + exportSubFolder + File.separator + fileName;
934 newContent = portableSkCase.addLocalFile(abstractFile.getName(), relativePath, abstractFile.getSize(),
935 abstractFile.getCtime(), abstractFile.getCrtime(), abstractFile.getAtime(), abstractFile.getMtime(),
936 abstractFile.getMd5Hash(), abstractFile.getKnown(), abstractFile.getMIMEType(),
937 true, TskData.EncodingType.NONE,
939 }
catch (IOException ex) {
940 throw new TskCoreException(
"Error copying file " + abstractFile.getName() +
" with original obj ID "
941 + abstractFile.getId(), ex);
946 throw new TskCoreException(
"Trying to copy unexpected Content type " + content.getClass().getName());
949 }
catch (TskCoreException ex) {
956 oldIdToNewContent.put(content.getId(), newContent);
957 newIdToContent.put(newContent.getId(), newContent);
958 return oldIdToNewContent.get(content.getId()).getId();
969 if (abstractFile.getMIMEType() == null || abstractFile.getMIMEType().isEmpty()) {
974 if (cat.getMediaTypes().contains(abstractFile.getMIMEType())) {
975 return cat.getDisplayName();
985 oldIdToNewContent.clear();
986 newIdToContent.clear();
987 oldTagNameToNewTagName.clear();
988 oldArtTypeIdToNewArtTypeId.clear();
990 oldArtifactIdToNewArtifact.clear();
996 copiedFilesFolder = null;
1003 if (portableSkCase != null) {
1004 portableSkCase.close();
1005 portableSkCase = null;
1029 Long maxId = rs.getLong(
"max_id");
1030 String query =
" (table_name, max_id) VALUES ('" + tableName +
"', '" + maxId +
"')";
1031 portableSkCase.getCaseDbAccessManager().insert(MAX_ID_TABLE_NAME, query);
1033 }
catch (SQLException ex) {
1034 logger.log(Level.WARNING,
"Unable to get maximum ID from result set", ex);
1035 }
catch (TskCoreException ex) {
1036 logger.log(Level.WARNING,
"Unable to save maximum ID from result set", ex);
1040 }
catch (SQLException ex) {
1041 logger.log(Level.WARNING,
"Failed to get maximum ID from result set", ex);
1046 @NbBundle.Messages({
1047 "PortableCaseReportModule.compressCase.errorFinding7zip=Could not locate 7-Zip executable",
1048 "# {0} - Temp folder path",
1049 "PortableCaseReportModule.compressCase.errorCreatingTempFolder=Could not create temporary folder {0}",
1050 "PortableCaseReportModule.compressCase.errorCompressingCase=Error compressing case",
1051 "PortableCaseReportModule.compressCase.canceled=Compression canceled by user",
1059 File tempZipFolder = Paths.get(currentCase.
getTempDirectory(),
"portableCase" + System.currentTimeMillis()).toFile();
1060 if (! tempZipFolder.mkdir()) {
1061 handleError(
"Error creating temporary folder " + tempZipFolder.toString(),
1062 Bundle.PortableCaseReportModule_compressCase_errorCreatingTempFolder(tempZipFolder.toString()), null, progressPanel);
1068 if (sevenZipExe == null) {
1069 handleError(
"Error finding 7-Zip exectuable", Bundle.PortableCaseReportModule_compressCase_errorFinding7zip(), null, progressPanel);
1074 String chunkOption =
"";
1079 File zipFile = Paths.get(tempZipFolder.getAbsolutePath(), caseName +
".zip").toFile();
1080 ProcessBuilder procBuilder =
new ProcessBuilder();
1081 procBuilder.command(
1082 sevenZipExe.getAbsolutePath(),
1084 zipFile.getAbsolutePath(),
1085 caseFolder.getAbsolutePath(),
1090 Process process = procBuilder.start();
1092 while (process.isAlive()) {
1099 int exitCode = process.exitValue();
1100 if (exitCode != 0) {
1102 StringBuilder sb =
new StringBuilder();
1103 try (BufferedReader br =
new BufferedReader(
new InputStreamReader(process.getErrorStream()))) {
1105 while ((line = br.readLine()) != null) {
1106 sb.append(line).append(System.getProperty(
"line.separator"));
1110 handleError(
"Error compressing case\n7-Zip output: " + sb.toString(), Bundle.PortableCaseReportModule_compressCase_errorCompressingCase(), null, progressPanel);
1113 }
catch (IOException | InterruptedException ex) {
1114 handleError(
"Error compressing case", Bundle.PortableCaseReportModule_compressCase_errorCompressingCase(), ex, progressPanel);
1120 FileUtils.cleanDirectory(caseFolder);
1121 FileUtils.copyDirectory(tempZipFolder, caseFolder);
1122 FileUtils.deleteDirectory(tempZipFolder);
1123 }
catch (IOException ex) {
1124 handleError(
"Error compressing case", Bundle.PortableCaseReportModule_compressCase_errorCompressingCase(), ex, progressPanel);
1141 String executableToFindName = Paths.get(
"7-Zip",
"7z.exe").toString();
1143 if (null == exeFile) {
1147 if (!exeFile.canExecute()) {
1160 private final Map<String, Long>
setCounts =
new HashMap<>();
1167 Long setCount = rs.getLong(
"set_count");
1168 String setName = rs.getString(
"set_name");
1170 setCounts.put(setName, setCount);
1172 }
catch (SQLException ex) {
1173 logger.log(Level.WARNING,
"Unable to get data_source_obj_id or value from result set", ex);
1176 }
catch (SQLException ex) {
1177 logger.log(Level.WARNING,
"Failed to get next result for values by datasource", ex);
final Map< Integer, Integer > oldArtTypeIdToNewArtTypeId
void handleError(String logWarning, String dialogWarning, Exception ex, ReportProgressPanel progressPanel)
long copyContent(Content content)
static final Logger logger
int getNewArtifactTypeId(BlackboardArtifact oldArtifact)
static final List< FileTypeCategory > FILE_TYPE_CATEGORIES
static final String MAX_ID_TABLE_NAME
void process(ResultSet rs)
final Map< TagName, TagName > oldTagNameToNewTagName
final Map< Long, Content > oldIdToNewContent
final Map< Long, BlackboardArtifact > oldArtifactIdToNewArtifact
PortableCaseReportModule()
String getTempDirectory()
boolean compressCase(ReportProgressPanel progressPanel)
long copyContentToPortableCase(Content content, ReportProgressPanel progressPanel)
void addArtifactsToPortableCase(TagName oldTagName, ReportProgressPanel progressPanel)
static final String FILE_FOLDER_NAME
final Map< Integer, BlackboardAttribute.Type > oldAttrTypeIdToNewAttrType
void process(ResultSet rs)
void complete(ReportStatus reportStatus)
List< TagName > getSelectedTagNames()
Map< String, Long > getSetCountMap()
static File locate7ZipExecutable()
static< T > long writeToFile(Content content, java.io.File outputFile, ProgressHandle progress, Future< T > worker, boolean source)
void closePortableCaseDatabase()
List< String > getAllInterestingItemsSets()
static final String UNKNOWN_FILE_TYPE_FOLDER
Logger(String name, String resourceBundleName)
void setIndeterminate(boolean indeterminate)
BlackboardAttribute.Type getNewAttributeType(BlackboardAttribute oldAttribute)
void addFilesToPortableCase(TagName oldTagName, ReportProgressPanel progressPanel)
void generateReport(String reportPath, PortableCaseReportModuleSettings options, ReportProgressPanel progressPanel)
String getRelativeFilePath()
TagsManager getTagsManager()
void initializeImageTags(ReportProgressPanel progressPanel)
String getExportSubfolder(AbstractFile abstractFile)
static final String TABLE_SCHEMA_SQLITE
final Map< Long, Content > newIdToContent
SleuthkitCase portableSkCase
static final String TABLE_NAME
final Map< String, Long > setCounts
SleuthkitCase getSleuthkitCase()
List< String > getSelectedSetNames()
BlackboardArtifact copyArtifact(long newContentId, BlackboardArtifact artifactToCopy)
SleuthkitCase createPortableCase(String caseName, File portableCaseFolder)
boolean areAllTagsSelected()
static String escapeFileName(String fileName)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
void updateStatusLabel(String statusMessage)
String getImageTagDataForContentTag(ContentTag tag)
String getSevenZipParam()
boolean areAllSetsSelected()
void addImageTagToPortableCase(ContentTag newContentTag, String appData)
void handleCancellation(ReportProgressPanel progressPanel)
void createCase(File outputDir, ReportProgressPanel progressPanel)
void process(ResultSet rs)
PortableCaseReportModuleSettings settings