19 package org.sleuthkit.autopsy.modules.embeddedfileextractor;
22 import java.nio.file.Paths;
23 import java.util.HashMap;
25 import java.util.concurrent.ConcurrentHashMap;
26 import java.util.logging.Level;
27 import javax.annotation.concurrent.GuardedBy;
28 import org.openide.util.NbBundle;
35 import net.sf.sevenzipjbinding.SevenZipNativeInitializationException;
38 import java.util.logging.Logger;
49 "CannotCreateOutputFolder=Unable to create output folder.",
50 "CannotRunFileTypeDetection=Unable to run file type detection.",
51 "UnableToInitializeLibraries=Unable to initialize 7Zip libraries.",
52 "EmbeddedFileExtractorIngestModule.NoOpenCase.errMsg=No open case available.",
53 "EmbeddedFileExtractorIngestModule.UnableToGetMSOfficeExtractor.errMsg=Unable to get MSOfficeEmbeddedContentExtractor."
57 private static final String TASK_RETRY_STATS_LOG_NAME =
"task_retry_stats";
59 private static final Object execMapLock =
new Object();
60 @GuardedBy(
"execMapLock")
61 private static final Map<Long, FileTaskExecutor> fileTaskExecsByJob = new HashMap<>();
63 private static final ConcurrentHashMap<Long, ConcurrentHashMap<Long, Archive>> mapOfDepthTrees = new ConcurrentHashMap<>();
65 private DocumentEmbeddedContentExtractor documentExtractor;
66 private SevenZipExtractor archiveExtractor;
79 "EmbeddedFileExtractor_make_output_dir_err=Failed to create module output directory for Embedded File Extractor"
100 if (refCounter.incrementAndGet(jobId) == 1) {
110 FileTaskExecutor fileTaskExecutor =
new FileTaskExecutor(context);
111 synchronized (execMapLock) {
112 fileTaskExecsByJob.put(jobId, fileTaskExecutor);
116 File extractionDirectory =
new File(moduleDirAbsolute);
117 if (!fileTaskExecutor.exists(extractionDirectory)) {
118 fileTaskExecutor.mkdirs(extractionDirectory);
120 }
catch (FileTaskExecutor.FileTaskFailedException | InterruptedException ex) {
138 mapOfDepthTrees.put(jobId,
new ConcurrentHashMap<>());
148 archiveExtractor =
new SevenZipExtractor(context, fileTypeDetector, moduleDirRelative, moduleDirAbsolute, fileTaskExecsByJob.get(jobId));
149 }
catch (SevenZipNativeInitializationException ex) {
159 documentExtractor =
new DocumentEmbeddedContentExtractor(context, fileTypeDetector, moduleDirRelative, moduleDirAbsolute, fileTaskExecsByJob.get(jobId));
166 throw new IngestModuleException(Bundle.EmbeddedFileExtractorIngestModule_UnableToGetMSOfficeExtractor_errMsg(), ex);
175 if ((abstractFile.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS))
176 || (abstractFile.getType().equals(TskData.TSK_DB_FILES_TYPE_ENUM.SLACK))) {
183 if (abstractFile.getKnown().equals(TskData.FileKnown.KNOWN)) {
190 if (!abstractFile.isFile()) {
198 if (archiveExtractor.isSevenZipExtractionSupported(abstractFile)) {
199 archiveExtractor.unpack(abstractFile, mapOfDepthTrees.get(jobId));
200 }
else if (documentExtractor.isContentExtractionSupported(abstractFile)) {
201 documentExtractor.extractEmbeddedContent(abstractFile);
208 if (refCounter.decrementAndGet(jobId) == 0) {
209 mapOfDepthTrees.remove(jobId);
210 FileTaskExecutor fileTaskExecutor;
211 synchronized (execMapLock) {
212 fileTaskExecutor = fileTaskExecsByJob.remove(jobId);
214 fileTaskExecutor.shutDown();
227 static String getUniqueName(AbstractFile file) {
228 return Long.toString(file.getId());
String getModuleOutputDirectoryRelativePath()
synchronized static Logger getLogger(String logName)
static long getTotalTasksCount()
static long getTotalTaskAttemptTimeOutsCount()
String getModuleDirectory()
static long getTotalTaskRetriesCount()
static Case getCurrentCase()
static long getTotalFailedTasksCount()