19 package org.sleuthkit.autopsy.modules.fileextmismatch;
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.logging.Level;
26 import org.openide.util.NbBundle;
40 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
53 private final FileExtMismatchDetectorModuleSettings
settings;
73 private static synchronized void addToTotals(
long ingestJobId,
long processTimeInc) {
75 if (ingestJobTotals == null) {
77 totalsForIngestJobs.put(ingestJobId, ingestJobTotals);
82 totalsForIngestJobs.put(ingestJobId, ingestJobTotals);
91 jobId = context.getJobId();
94 FileExtMismatchXML xmlLoader = FileExtMismatchXML.getDefault();
95 SigTypeToExtMap = xmlLoader.load();
107 if(this.settings.skipKnownFiles() && (abstractFile.getKnown() == FileKnown.KNOWN)) {
112 if ((abstractFile.getType() == TskData.TSK_DB_FILES_TYPE_ENUM.UNALLOC_BLOCKS)
113 || (abstractFile.getType() == TskData.TSK_DB_FILES_TYPE_ENUM.UNUSED_BLOCKS)
114 || (abstractFile.isFile() ==
false)) {
119 if ((abstractFile.isMetaFlagSet(TskData.TSK_FS_META_FLAG_ENUM.UNALLOC))
120 || (abstractFile.isDirNameFlagSet(TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC))) {
125 long startTime = System.currentTimeMillis();
129 addToTotals(jobId, System.currentTimeMillis() - startTime);
131 if (mismatchDetected) {
133 BlackboardArtifact bart = abstractFile.newArtifact(ARTIFACT_TYPE.TSK_EXT_MISMATCH_DETECTED);
139 logger.log(Level.SEVERE, NbBundle.getMessage(
Blackboard.class,
"Blackboard.unableToIndexArtifact.error.msg", bart.getDisplayName()), ex);
141 NbBundle.getMessage(
Blackboard.class,
"Blackboard.unableToIndexArtifact.exception.msg"), bart.getDisplayName());
147 }
catch (TskException ex) {
148 logger.log(Level.WARNING,
"Error matching file signature", ex);
161 String currActualExt = abstractFile.getNameExtension();
164 if (settings.skipFilesWithNoExtension() && currActualExt.isEmpty()) {
167 String currActualSigType = detector.
getFileType(abstractFile);
168 if (currActualSigType == null) {
171 if (settings.skipFilesWithTextPlainMimeType()) {
172 if (!currActualExt.isEmpty() && currActualSigType.equals(
"text/plain")) {
178 String[] allowedExtArray = SigTypeToExtMap.get(currActualSigType);
179 if (allowedExtArray != null) {
180 List<String> allowedExtList = Arrays.asList(allowedExtArray);
183 if (allowedExtList != null) {
184 for (String e : allowedExtList) {
185 if (e.equals(currActualExt)) {
201 synchronized (
this) {
202 jobTotals = totalsForIngestJobs.remove(jobId);
204 if (jobTotals != null) {
205 StringBuilder detailsSb =
new StringBuilder();
206 detailsSb.append(
"<table border='0' cellpadding='4' width='280'>");
208 detailsSb.append(
"<tr><td>").append(
209 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchIngestModule.complete.totalProcTime"))
210 .append(
"</td><td>").append(jobTotals.
processTime).append(
"</td></tr>\n");
211 detailsSb.append(
"<tr><td>").append(
212 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchIngestModule.complete.totalFiles"))
213 .append(
"</td><td>").append(jobTotals.
numFiles).append(
"</td></tr>\n");
214 detailsSb.append(
"</table>");
217 NbBundle.getMessage(this.getClass(),
218 "FileExtMismatchIngestModule.complete.svcMsg.text"),
219 detailsSb.toString()));
synchronized long decrementAndGet(long jobId)
void indexArtifact(BlackboardArtifact artifact)
FileTypeDetector detector
static final HashMap< Long, IngestJobTotals > totalsForIngestJobs
static final Logger logger
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
void postMessage(final IngestMessage message)
void fireModuleDataEvent(ModuleDataEvent moduleDataEvent)
Blackboard getBlackboard()
static void error(String title, String message)
void startUp(IngestJobContext context)
final FileExtMismatchDetectorModuleSettings settings
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
String getFileType(AbstractFile file)
final IngestServices services
ProcessResult process(AbstractFile abstractFile)
static Blackboard blackboard
static synchronized void addToTotals(long ingestJobId, long processTimeInc)
static synchronized IngestServices getInstance()