19 package org.sleuthkit.autopsy.modules.fileextmismatch;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.logging.Level;
27 import org.openide.util.NbBundle;
50 private final FileExtMismatchDetectorModuleSettings
settings;
66 private static synchronized void addToTotals(
long ingestJobId,
long processTimeInc) {
68 if (ingestJobTotals == null) {
70 totalsForIngestJobs.put(ingestJobId, ingestJobTotals);
75 totalsForIngestJobs.put(ingestJobId, ingestJobTotals);
84 jobId = context.getJobId();
87 FileExtMismatchXML xmlLoader = FileExtMismatchXML.getDefault();
88 SigTypeToExtMap = xmlLoader.load();
96 || (abstractFile.
isFile() ==
false)) {
107 long startTime = System.currentTimeMillis();
111 addToTotals(jobId, System.currentTimeMillis() - startTime);
113 if (mismatchDetected) {
121 logger.log(Level.WARNING,
"Error matching file signature", ex);
137 if (settings.skipFilesWithNoExtension() && currActualExt.isEmpty()) {
145 String currActualSigType = attribute.getValueString();
146 if (settings.skipFilesWithTextPlainMimeType()) {
147 if (!currActualExt.isEmpty() && currActualSigType.equals(
"text/plain")) {
153 String[] allowedExtArray = SigTypeToExtMap.get(currActualSigType);
154 if (allowedExtArray != null) {
155 List<String> allowedExtList = Arrays.asList(allowedExtArray);
158 if (allowedExtList != null) {
159 for (String e : allowedExtList) {
160 if (e.equals(currActualExt)) {
169 logger.log(Level.WARNING,
"Error while getting file signature from blackboard.", ex);
181 jobTotals = totalsForIngestJobs.remove(jobId);
183 if (jobTotals != null) {
184 StringBuilder detailsSb =
new StringBuilder();
185 detailsSb.append(
"<table border='0' cellpadding='4' width='280'>");
187 detailsSb.append(
"<tr><td>").append(
188 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchIngestModule.complete.totalProcTime"))
189 .append(
"</td><td>").append(jobTotals.
processTime).append(
"</td></tr>\n");
190 detailsSb.append(
"<tr><td>").append(
191 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchIngestModule.complete.totalFiles"))
192 .append(
"</td><td>").append(jobTotals.
numFiles).append(
"</td></tr>\n");
193 detailsSb.append(
"</table>");
196 NbBundle.getMessage(this.getClass(),
197 "FileExtMismatchIngestModule.complete.svcMsg.text"),
198 detailsSb.toString()));
synchronized long decrementAndGet(long jobId)
boolean isDirNameFlagSet(TSK_FS_NAME_FLAG_ENUM flag)
static final HashMap< Long, IngestJobTotals > totalsForIngestJobs
static final Logger logger
TskData.TSK_DB_FILES_TYPE_ENUM getType()
TSK_EXT_MISMATCH_DETECTED
String getNameExtension()
synchronized long incrementAndGet(long jobId)
static IngestMessage createMessage(MessageType messageType, String source, String subject, String detailsHtml)
static final IngestModuleReferenceCounter refCounter
boolean compareSigTypeToExt(AbstractFile abstractFile)
HashMap< String, String[]> SigTypeToExtMap
boolean isMetaFlagSet(TSK_FS_META_FLAG_ENUM metaFlag)
void postMessage(final IngestMessage message)
void fireModuleDataEvent(ModuleDataEvent moduleDataEvent)
BlackboardArtifact newArtifact(int artifactTypeID)
void startUp(IngestJobContext context)
final FileExtMismatchDetectorModuleSettings settings
final IngestServices services
ArrayList< BlackboardAttribute > getGenInfoAttributes(ATTRIBUTE_TYPE attr_type)
static Logger getLogger(String name)
ProcessResult process(AbstractFile abstractFile)
static synchronized void addToTotals(long ingestJobId, long processTimeInc)
static synchronized IngestServices getInstance()