mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #606 from SynapticNulship/onemsg2
ingest message updates
This commit is contained in:
commit
57a767f39f
@ -395,18 +395,18 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized public int getRowCount() {
|
||||
public synchronized int getRowCount() {
|
||||
return getNumberGroups();
|
||||
}
|
||||
|
||||
public void markAllSeen() {
|
||||
public synchronized void markAllSeen() {
|
||||
for (TableEntry entry : messageData) {
|
||||
entry.hasBeenSeen(true);
|
||||
}
|
||||
fireTableChanged(new TableModelEvent(this));
|
||||
}
|
||||
|
||||
public int getNumberNewMessages() {
|
||||
public synchronized int getNumberNewMessages() {
|
||||
int newMessages = 0;
|
||||
for (TableEntry entry : messageData) {
|
||||
if (!entry.hasBeenSeen()) {
|
||||
@ -416,11 +416,11 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
return newMessages;
|
||||
}
|
||||
|
||||
synchronized int getNumberGroups() {
|
||||
public synchronized int getNumberGroups() {
|
||||
return messageData.size();
|
||||
}
|
||||
|
||||
synchronized int getNumberMessages() {
|
||||
public synchronized int getNumberMessages() {
|
||||
int total = 0;
|
||||
for (TableEntry e : messageData) {
|
||||
total += e.messageGroup.getCount();
|
||||
@ -428,7 +428,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
return total;
|
||||
}
|
||||
|
||||
synchronized int getNumberUnreadMessages() {
|
||||
public synchronized int getNumberUnreadMessages() {
|
||||
int total = 0;
|
||||
for (TableEntry e : messageData) {
|
||||
if (!e.hasBeenVisited) {
|
||||
@ -438,7 +438,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
return total;
|
||||
}
|
||||
|
||||
synchronized int getNumberUnreadGroups() {
|
||||
public synchronized int getNumberUnreadGroups() {
|
||||
int total = 0;
|
||||
for (TableEntry e : messageData) {
|
||||
if (!e.hasBeenVisited) {
|
||||
@ -513,7 +513,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
return ret;
|
||||
}
|
||||
|
||||
synchronized public void addMessage(IngestMessage m) {
|
||||
public synchronized void addMessage(IngestMessage m) {
|
||||
//check how many messages per module with the same uniqness
|
||||
//and add to existing group or create a new group
|
||||
String moduleName = m.getSource();
|
||||
@ -628,15 +628,27 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
}
|
||||
|
||||
public synchronized boolean isVisited(int rowNumber) {
|
||||
if (rowNumber < messageData.size()) {
|
||||
return messageData.get(rowNumber).hasBeenVisited();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized MessageType getMessageType(int rowNumber) {
|
||||
if (rowNumber < messageData.size()) {
|
||||
return messageData.get(rowNumber).messageGroup.getMessageType();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized IngestMessageGroup getMessageGroup(int rowNumber) {
|
||||
if (rowNumber < messageData.size()) {
|
||||
return messageData.get(rowNumber).messageGroup;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reSort(boolean chronoLogical) {
|
||||
@ -701,26 +713,22 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
List<IngestMessage> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
void add(IngestMessage message) {
|
||||
synchronized void add(IngestMessage message) {
|
||||
messages.add(message);
|
||||
}
|
||||
|
||||
//add all messages from another group
|
||||
void addAll(IngestMessageGroup group) {
|
||||
for (IngestMessage m : group.getMessages()) {
|
||||
synchronized void addAll(IngestMessageGroup group) {
|
||||
for (IngestMessage m : messages) {
|
||||
messages.add(m);
|
||||
}
|
||||
}
|
||||
|
||||
int getCount() {
|
||||
synchronized int getCount() {
|
||||
return messages.size();
|
||||
}
|
||||
|
||||
String getDetails() {
|
||||
synchronized String getDetails() {
|
||||
StringBuilder b = new StringBuilder("");
|
||||
for (IngestMessage m : messages) {
|
||||
String details = m.getDetails();
|
||||
@ -739,7 +747,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
* return color corresp to priority
|
||||
* @return
|
||||
*/
|
||||
Color getColor() {
|
||||
synchronized Color getColor() {
|
||||
int count = messages.size();
|
||||
if (count == 1) {
|
||||
return VERY_HIGH_PRI_COLOR;
|
||||
@ -757,7 +765,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
* used for chrono sort
|
||||
* @return
|
||||
*/
|
||||
Date getDatePosted() {
|
||||
synchronized Date getDatePosted() {
|
||||
return messages.get(messages.size() - 1).getDatePosted();
|
||||
}
|
||||
|
||||
@ -765,35 +773,35 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
* get subject of the first message
|
||||
* @return
|
||||
*/
|
||||
String getSubject() {
|
||||
synchronized String getSubject() {
|
||||
return messages.get(0).getSubject();
|
||||
}
|
||||
|
||||
/*
|
||||
* return unique key, should be the same for all msgs
|
||||
*/
|
||||
String getUniqueKey() {
|
||||
synchronized String getUniqueKey() {
|
||||
return messages.get(0).getUniqueKey();
|
||||
}
|
||||
|
||||
/*
|
||||
* return source module, should be the same for all msgs
|
||||
*/
|
||||
String getSource() {
|
||||
synchronized String getSource() {
|
||||
return messages.get(0).getSource();
|
||||
}
|
||||
|
||||
/*
|
||||
* return data of the first message
|
||||
*/
|
||||
BlackboardArtifact getData() {
|
||||
synchronized BlackboardArtifact getData() {
|
||||
return messages.get(0).getData();
|
||||
}
|
||||
|
||||
/*
|
||||
* return message type, should be the same for all msgs
|
||||
*/
|
||||
IngestMessage.MessageType getMessageType() {
|
||||
synchronized IngestMessage.MessageType getMessageType() {
|
||||
return messages.get(0).getMessageType();
|
||||
}
|
||||
}
|
||||
@ -858,6 +866,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
cell.setFont(new Font("", Font.PLAIN, 16));
|
||||
|
||||
final IngestMessageGroup messageGroup = tableModel.getMessageGroup(row);
|
||||
if (messageGroup != null) {
|
||||
MessageType mt = messageGroup.getMessageType();
|
||||
if (mt == MessageType.ERROR) {
|
||||
cell.setBackground(ERROR_COLOR);
|
||||
@ -867,7 +876,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
//cell.setBackground(table.getBackground());
|
||||
cell.setBackground(messageGroup.getColor());
|
||||
}
|
||||
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
@ -898,6 +907,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
}
|
||||
|
||||
final IngestMessageGroup messageGroup = tableModel.getMessageGroup(row);
|
||||
if (messageGroup != null) {
|
||||
MessageType mt = messageGroup.getMessageType();
|
||||
if (mt == MessageType.ERROR) {
|
||||
cell.setBackground(ERROR_COLOR);
|
||||
@ -907,7 +917,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
//cell.setBackground(table.getBackground());
|
||||
cell.setBackground(messageGroup.getColor());
|
||||
}
|
||||
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
@ -933,6 +943,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
Component cell = super.getTableCellRendererComponent(table, aValue, isSelected, hasFocus, row, column);
|
||||
|
||||
final IngestMessageGroup messageGroup = tableModel.getMessageGroup(row);
|
||||
if (messageGroup != null) {
|
||||
MessageType mt = messageGroup.getMessageType();
|
||||
if (mt == MessageType.ERROR) {
|
||||
cell.setBackground(ERROR_COLOR);
|
||||
@ -942,6 +953,7 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
//cell.setBackground(table.getBackground());
|
||||
cell.setBackground(messageGroup.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
@ -974,10 +986,12 @@ class IngestMessagePanel extends JPanel implements TableModelListener {
|
||||
messageTable.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
//check if has details
|
||||
IngestMessageGroup m = getMessageGroup(selected);
|
||||
if (m != null) {
|
||||
String details = m.getDetails();
|
||||
if (details != null && !details.equals("")) {
|
||||
mainPanel.showDetails(selected);
|
||||
}
|
||||
}
|
||||
messageTable.setCursor(null);
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,32 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.ingest;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* An adapter that provides a default implementation of the IngestModule
|
||||
* interface.
|
||||
*/
|
||||
public abstract class IngestModuleAdapter implements IngestModule {
|
||||
// Maps a JobId to the count of instances
|
||||
static HashMap<Long, Long> moduleRefCount = new HashMap<>();
|
||||
|
||||
public static synchronized long moduleRefCountIncrement(long jobId) {
|
||||
long count = moduleRefCount.containsKey(jobId) ? moduleRefCount.get(jobId) : 0;
|
||||
long nextCount = count + 1;
|
||||
moduleRefCount.put(jobId, nextCount);
|
||||
return nextCount;
|
||||
}
|
||||
|
||||
public static synchronized long moduleRefCountDecrementAndGet(long jobId) {
|
||||
if (moduleRefCount.containsKey(jobId)) {
|
||||
long count = moduleRefCount.get(jobId);
|
||||
moduleRefCount.put(jobId, --count);
|
||||
return count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
|
@ -32,11 +32,13 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import org.sleuthkit.autopsy.coreutils.ImageUtils;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleAdapter;
|
||||
import org.sleuthkit.autopsy.ingest.FileIngestModule;
|
||||
import org.sleuthkit.autopsy.ingest.IngestJobContext;
|
||||
import org.sleuthkit.autopsy.ingest.IngestServices;
|
||||
import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
@ -57,12 +59,20 @@ public final class ExifParserFileIngestModule extends IngestModuleAdapter implem
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ExifParserFileIngestModule.class.getName());
|
||||
private final IngestServices services = IngestServices.getInstance();
|
||||
private int filesProcessed = 0;
|
||||
private boolean filesToFire = false;
|
||||
private AtomicInteger filesProcessed = new AtomicInteger(0);
|
||||
private volatile boolean filesToFire = false;
|
||||
private long jobId;
|
||||
|
||||
ExifParserFileIngestModule() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
jobId = context.getJobId();
|
||||
IngestModuleAdapter.moduleRefCountIncrement(jobId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ProcessResult process(AbstractFile content) {
|
||||
//skip unalloc
|
||||
@ -76,8 +86,8 @@ public final class ExifParserFileIngestModule extends IngestModuleAdapter implem
|
||||
}
|
||||
|
||||
// update the tree every 1000 files if we have EXIF data that is not being being displayed
|
||||
filesProcessed++;
|
||||
if ((filesToFire) && (filesProcessed % 1000 == 0)) {
|
||||
final int filesProcessedValue = filesProcessed.incrementAndGet();
|
||||
if ((filesToFire) && (filesProcessedValue % 1000 == 0)) {
|
||||
services.fireModuleDataEvent(new ModuleDataEvent(ExifParserModuleFactory.getModuleName(), BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF));
|
||||
filesToFire = false;
|
||||
}
|
||||
@ -187,9 +197,12 @@ public final class ExifParserFileIngestModule extends IngestModuleAdapter implem
|
||||
|
||||
@Override
|
||||
public void shutDown(boolean ingestJobCancelled) {
|
||||
// We only need to check for this final event on the last module per job
|
||||
if (IngestModuleAdapter.moduleRefCountDecrementAndGet(jobId) == 0) {
|
||||
if (filesToFire) {
|
||||
//send the final new data event
|
||||
services.fireModuleDataEvent(new ModuleDataEvent(ExifParserModuleFactory.getModuleName(), BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.logging.Level;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@ -38,7 +39,6 @@ import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
import org.sleuthkit.datamodel.TskData.FileKnown;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
|
||||
/**
|
||||
@ -50,8 +50,9 @@ public class FileExtMismatchIngestModule extends IngestModuleAdapter implements
|
||||
private final IngestServices services = IngestServices.getInstance();
|
||||
private final FileExtMismatchDetectorModuleSettings settings;
|
||||
private HashMap<String, String[]> SigTypeToExtMap = new HashMap<>();
|
||||
private long processTime = 0;
|
||||
private long numFiles = 0;
|
||||
private long jobId;
|
||||
private static AtomicLong processTime = new AtomicLong(0);
|
||||
private static AtomicLong numFiles = new AtomicLong(0);
|
||||
|
||||
FileExtMismatchIngestModule(FileExtMismatchDetectorModuleSettings settings) {
|
||||
this.settings = settings;
|
||||
@ -59,6 +60,8 @@ public class FileExtMismatchIngestModule extends IngestModuleAdapter implements
|
||||
|
||||
@Override
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
jobId = context.getJobId();
|
||||
IngestModuleAdapter.moduleRefCountIncrement(jobId);
|
||||
FileExtMismatchXML xmlLoader = FileExtMismatchXML.getDefault();
|
||||
SigTypeToExtMap = xmlLoader.load();
|
||||
}
|
||||
@ -82,8 +85,8 @@ public class FileExtMismatchIngestModule extends IngestModuleAdapter implements
|
||||
|
||||
boolean mismatchDetected = compareSigTypeToExt(abstractFile);
|
||||
|
||||
processTime += (System.currentTimeMillis() - startTime);
|
||||
numFiles++;
|
||||
processTime.getAndAdd(System.currentTimeMillis() - startTime);
|
||||
numFiles.getAndIncrement();
|
||||
|
||||
if (mismatchDetected) {
|
||||
// add artifact
|
||||
@ -149,19 +152,22 @@ public class FileExtMismatchIngestModule extends IngestModuleAdapter implements
|
||||
|
||||
@Override
|
||||
public void shutDown(boolean ingestJobCancelled) {
|
||||
// We only need to post the summary msg from the last module per job
|
||||
if (IngestModuleAdapter.moduleRefCountDecrementAndGet(jobId) == 0) {
|
||||
StringBuilder detailsSb = new StringBuilder();
|
||||
detailsSb.append("<table border='0' cellpadding='4' width='280'>");
|
||||
detailsSb.append("<tr><td>").append(FileExtMismatchDetectorModuleFactory.getModuleName()).append("</td></tr>");
|
||||
detailsSb.append("<tr><td>").append(
|
||||
NbBundle.getMessage(this.getClass(), "FileExtMismatchIngestModule.complete.totalProcTime"))
|
||||
.append("</td><td>").append(processTime).append("</td></tr>\n");
|
||||
.append("</td><td>").append(processTime.get()).append("</td></tr>\n");
|
||||
detailsSb.append("<tr><td>").append(
|
||||
NbBundle.getMessage(this.getClass(), "FileExtMismatchIngestModule.complete.totalFiles"))
|
||||
.append("</td><td>").append(numFiles).append("</td></tr>\n");
|
||||
.append("</td><td>").append(numFiles.get()).append("</td></tr>\n");
|
||||
detailsSb.append("</table>");
|
||||
services.postMessage(IngestMessage.createMessage(IngestMessage.MessageType.INFO, FileExtMismatchDetectorModuleFactory.getModuleName(),
|
||||
NbBundle.getMessage(this.getClass(),
|
||||
"FileExtMismatchIngestModule.complete.svcMsg.text"),
|
||||
detailsSb.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,12 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.modules.filetypeid;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.ingest.FileIngestModule;
|
||||
import org.sleuthkit.autopsy.ingest.IngestJobContext;
|
||||
import org.sleuthkit.autopsy.ingest.IngestMessage;
|
||||
import org.sleuthkit.autopsy.ingest.IngestServices;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
@ -44,8 +45,10 @@ public class FileTypeIdIngestModule extends IngestModuleAdapter implements FileI
|
||||
private static final Logger logger = Logger.getLogger(FileTypeIdIngestModule.class.getName());
|
||||
private static final long MIN_FILE_SIZE = 512;
|
||||
private final FileTypeIdModuleSettings settings;
|
||||
private long matchTime = 0;
|
||||
private long numFiles = 0;
|
||||
private long jobId;
|
||||
private static AtomicLong matchTime = new AtomicLong(0);
|
||||
private static AtomicLong numFiles = new AtomicLong(0);
|
||||
|
||||
// The detector. Swap out with a different implementation of FileTypeDetectionInterface as needed.
|
||||
// If desired in the future to be more knowledgable about weird files or rare formats, we could
|
||||
// actually have a list of detectors which are called in order until a match is found.
|
||||
@ -55,6 +58,12 @@ public class FileTypeIdIngestModule extends IngestModuleAdapter implements FileI
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
jobId = context.getJobId();
|
||||
IngestModuleAdapter.moduleRefCountIncrement(jobId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessResult process(AbstractFile abstractFile) {
|
||||
// skip non-files
|
||||
@ -75,8 +84,8 @@ public class FileTypeIdIngestModule extends IngestModuleAdapter implements FileI
|
||||
try {
|
||||
long startTime = System.currentTimeMillis();
|
||||
FileTypeDetectionInterface.FileIdInfo fileId = detector.attemptMatch(abstractFile);
|
||||
matchTime += (System.currentTimeMillis() - startTime);
|
||||
numFiles++;
|
||||
matchTime.getAndAdd(System.currentTimeMillis() - startTime);
|
||||
numFiles.getAndIncrement();
|
||||
|
||||
if (!fileId.type.isEmpty()) {
|
||||
// add artifact
|
||||
@ -98,21 +107,24 @@ public class FileTypeIdIngestModule extends IngestModuleAdapter implements FileI
|
||||
|
||||
@Override
|
||||
public void shutDown(boolean ingestJobCancelled) {
|
||||
// We only need to post the summary msg from the last module per job
|
||||
if (IngestModuleAdapter.moduleRefCountDecrementAndGet(jobId) == 0) {
|
||||
StringBuilder detailsSb = new StringBuilder();
|
||||
detailsSb.append("<table border='0' cellpadding='4' width='280'>");
|
||||
detailsSb.append("<tr><td>").append(FileTypeIdModuleFactory.getModuleName()).append("</td></tr>");
|
||||
detailsSb.append("<tr><td>")
|
||||
.append(NbBundle.getMessage(this.getClass(), "FileTypeIdIngestModule.complete.totalProcTime"))
|
||||
.append("</td><td>").append(matchTime).append("</td></tr>\n");
|
||||
.append("</td><td>").append(matchTime.get()).append("</td></tr>\n");
|
||||
detailsSb.append("<tr><td>")
|
||||
.append(NbBundle.getMessage(this.getClass(), "FileTypeIdIngestModule.complete.totalFiles"))
|
||||
.append("</td><td>").append(numFiles).append("</td></tr>\n");
|
||||
.append("</td><td>").append(numFiles.get()).append("</td></tr>\n");
|
||||
detailsSb.append("</table>");
|
||||
IngestServices.getInstance().postMessage(IngestMessage.createMessage(IngestMessage.MessageType.INFO, FileTypeIdModuleFactory.getModuleName(),
|
||||
NbBundle.getMessage(this.getClass(),
|
||||
"FileTypeIdIngestModule.complete.srvMsg.text"),
|
||||
detailsSb.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate if a given mime type is in the detector's registry.
|
||||
|
@ -90,6 +90,7 @@ public final class SevenZipIngestModule extends IngestModuleAdapter implements F
|
||||
private final byte[] fileHeaderBuffer = new byte[readHeaderSize];
|
||||
private static final int ZIP_SIGNATURE_BE = 0x504B0304;
|
||||
private IngestJobContext context;
|
||||
private long jobId;
|
||||
|
||||
SevenZipIngestModule() {
|
||||
}
|
||||
@ -97,6 +98,7 @@ public final class SevenZipIngestModule extends IngestModuleAdapter implements F
|
||||
@Override
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
this.context = context;
|
||||
jobId = context.getJobId();
|
||||
|
||||
final Case currentCase = Case.getCurrentCase();
|
||||
|
||||
@ -121,6 +123,8 @@ public final class SevenZipIngestModule extends IngestModuleAdapter implements F
|
||||
}
|
||||
}
|
||||
|
||||
// if first instance of this module for this job then check 7zip init
|
||||
if (IngestModuleAdapter.moduleRefCountIncrement(jobId) == 1) {
|
||||
try {
|
||||
SevenZip.initSevenZipFromPlatformJAR();
|
||||
String platform = SevenZip.getUsedPlatform();
|
||||
@ -134,6 +138,7 @@ public final class SevenZipIngestModule extends IngestModuleAdapter implements F
|
||||
services.postMessage(IngestMessage.createErrorMessage(ArchiveFileExtractorModuleFactory.getModuleName(), msg, details));
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
archiveDepthCountTree = new ArchiveDepthCountTree();
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.hashdatabase;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.logging.Level;
|
||||
@ -56,37 +55,24 @@ public class HashDbIngestModule extends IngestModuleAdapter implements FileInges
|
||||
private final HashLookupModuleSettings settings;
|
||||
private List<HashDb> knownBadHashSets = new ArrayList<>();
|
||||
private List<HashDb> knownHashSets = new ArrayList<>();
|
||||
private long jobID;
|
||||
// Maps a JobId to the count of instances
|
||||
static HashMap<Long, Long> moduleRefCount = new HashMap<>();
|
||||
private long jobId;
|
||||
static AtomicLong totalKnownBadCount = new AtomicLong(0);
|
||||
static AtomicLong totalCalctime = new AtomicLong(0);
|
||||
static AtomicLong totalLookuptime = new AtomicLong(0);
|
||||
|
||||
private static synchronized void moduleRefCountIncrement(long jobID) {
|
||||
long count = moduleRefCount.containsKey(jobID) ? moduleRefCount.get(jobID) : 0;
|
||||
moduleRefCount.put(jobID, count + 1);
|
||||
}
|
||||
|
||||
private static synchronized long moduleRefCountDecrementAndGet(long jobID) {
|
||||
if (moduleRefCount.containsKey(jobID)) {
|
||||
long count = moduleRefCount.get(jobID);
|
||||
moduleRefCount.put(jobID, --count);
|
||||
return count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
HashDbIngestModule(HashLookupModuleSettings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startUp(org.sleuthkit.autopsy.ingest.IngestJobContext context) throws IngestModuleException {
|
||||
jobID = context.getJobId();
|
||||
moduleRefCountIncrement(jobID);
|
||||
jobId = context.getJobId();
|
||||
getEnabledHashSets(hashDbManager.getKnownBadFileHashSets(), knownBadHashSets);
|
||||
getEnabledHashSets(hashDbManager.getKnownFileHashSets(), knownHashSets);
|
||||
|
||||
if (IngestModuleAdapter.moduleRefCountIncrement(jobId) == 1) {
|
||||
// if first module for this job then post error msgs if needed
|
||||
|
||||
if (knownBadHashSets.isEmpty()) {
|
||||
services.postMessage(IngestMessage.createWarningMessage(
|
||||
HashLookupModuleFactory.getModuleName(),
|
||||
@ -96,7 +82,6 @@ public class HashDbIngestModule extends IngestModuleAdapter implements FileInges
|
||||
"HashDbIngestModule.knownBadFileSearchWillNotExecuteWarn")));
|
||||
}
|
||||
|
||||
getEnabledHashSets(hashDbManager.getKnownFileHashSets(), knownHashSets);
|
||||
if (knownHashSets.isEmpty()) {
|
||||
services.postMessage(IngestMessage.createWarningMessage(
|
||||
HashLookupModuleFactory.getModuleName(),
|
||||
@ -106,6 +91,7 @@ public class HashDbIngestModule extends IngestModuleAdapter implements FileInges
|
||||
"HashDbIngestModule.knownFileSearchWillNotExecuteWarn")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getEnabledHashSets(List<HashDb> hashSets, List<HashDb> enabledHashSets) {
|
||||
enabledHashSets.clear();
|
||||
@ -317,7 +303,7 @@ public class HashDbIngestModule extends IngestModuleAdapter implements FileInges
|
||||
|
||||
@Override
|
||||
public void shutDown(boolean ingestJobCancelled) {
|
||||
if (moduleRefCountDecrementAndGet(jobID) == 0) {
|
||||
if (IngestModuleAdapter.moduleRefCountDecrementAndGet(jobId) == 0) {
|
||||
if ((!knownBadHashSets.isEmpty()) || (!knownHashSets.isEmpty())) {
|
||||
StringBuilder detailsSb = new StringBuilder();
|
||||
//details
|
||||
|
@ -101,7 +101,13 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
SKIPPED_ERROR_TEXTEXTRACT, ///< File was skipped because of text extraction issues
|
||||
SKIPPED_ERROR_IO ///< File was skipped because of IO issues reading it
|
||||
};
|
||||
private Map<Long, IngestStatus> ingestStatus;
|
||||
private static final Map<Long, IngestStatus> ingestStatus = new HashMap<>(); //guarded by itself
|
||||
|
||||
static void putIngestStatus(long id, IngestStatus status) {
|
||||
synchronized(ingestStatus) {
|
||||
ingestStatus.put(id, status);
|
||||
}
|
||||
}
|
||||
|
||||
KeywordSearchIngestModule(KeywordSearchJobSettings settings) {
|
||||
this.settings = settings;
|
||||
@ -117,12 +123,14 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||
logger.log(Level.INFO, "Initializing instance {0}", instanceNum);
|
||||
initialized = false;
|
||||
|
||||
jobId = context.getJobId();
|
||||
caseHandle = Case.getCurrentCase().getSleuthkitCase();
|
||||
tikaFormatDetector = new Tika();
|
||||
ingester = Server.getIngester();
|
||||
|
||||
// increment the module reference count
|
||||
// if first instance of this module for this job then check the server and existence of keywords
|
||||
if (IngestModuleAdapter.moduleRefCountIncrement(jobId) == 1) {
|
||||
final Server server = KeywordSearch.getServer();
|
||||
try {
|
||||
if (!server.isRunning()) {
|
||||
@ -150,6 +158,21 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
ex.getMessage()));
|
||||
}
|
||||
|
||||
// check if this job has any searchable keywords
|
||||
List<KeywordList> keywordLists = KeywordSearchListsXML.getCurrent().getListsL();
|
||||
boolean hasKeywordsForSearch = false;
|
||||
for (KeywordList keywordList : keywordLists) {
|
||||
if (settings.isKeywordListEnabled(keywordList.getName()) && !keywordList.getKeywords().isEmpty()) {
|
||||
hasKeywordsForSearch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasKeywordsForSearch) {
|
||||
services.postMessage(IngestMessage.createWarningMessage(KeywordSearchModuleFactory.getModuleName(), NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.noKwInLstMsg"),
|
||||
NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.onlyIdxKwSkipMsg")));
|
||||
}
|
||||
}
|
||||
|
||||
//initialize extractors
|
||||
stringExtractor = new AbstractFileStringExtract(this);
|
||||
stringExtractor.setScripts(KeywordSearchSettings.getStringExtractScripts());
|
||||
@ -167,21 +190,6 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
textExtractors.add(new AbstractFileHtmlExtract(this));
|
||||
textExtractors.add(new AbstractFileTikaTextExtract(this));
|
||||
|
||||
ingestStatus = new HashMap<>();
|
||||
|
||||
List<KeywordList> keywordLists = KeywordSearchListsXML.getCurrent().getListsL();
|
||||
boolean hasKeywordsForSearch = false;
|
||||
for (KeywordList keywordList : keywordLists) {
|
||||
if (settings.isKeywordListEnabled(keywordList.getName()) && !keywordList.getKeywords().isEmpty()) {
|
||||
hasKeywordsForSearch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasKeywordsForSearch) {
|
||||
services.postMessage(IngestMessage.createWarningMessage(KeywordSearchModuleFactory.getModuleName(), NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.noKwInLstMsg"),
|
||||
NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.init.onlyIdxKwSkipMsg")));
|
||||
}
|
||||
|
||||
indexer = new Indexer();
|
||||
initialized = true;
|
||||
}
|
||||
@ -191,7 +199,7 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
if (initialized == false) //error initializing indexing/Solr
|
||||
{
|
||||
logger.log(Level.WARNING, "Skipping processing, module not initialized, file: {0}", abstractFile.getName());
|
||||
ingestStatus.put(abstractFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
putIngestStatus(abstractFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
return ProcessResult.OK;
|
||||
}
|
||||
try {
|
||||
@ -247,7 +255,10 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
// Remove from the search list and trigger final commit and final search
|
||||
SearchRunner.getInstance().endJob(jobId);
|
||||
|
||||
// We only need to post the summary msg from the last module per job
|
||||
if (IngestModuleAdapter.moduleRefCountDecrementAndGet(jobId) == 0) {
|
||||
postIndexSummary();
|
||||
}
|
||||
|
||||
//log number of files / chunks in index
|
||||
//signal a potential change in number of text_ingested files
|
||||
@ -276,7 +287,9 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
* Common cleanup code when module stops or final searcher completes
|
||||
*/
|
||||
private void cleanup() {
|
||||
synchronized(ingestStatus) {
|
||||
ingestStatus.clear();
|
||||
}
|
||||
|
||||
textExtractors.clear();
|
||||
textExtractors = null;
|
||||
@ -297,6 +310,8 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
int error_text = 0;
|
||||
int error_index = 0;
|
||||
int error_io = 0;
|
||||
|
||||
synchronized(ingestStatus) {
|
||||
for (IngestStatus s : ingestStatus.values()) {
|
||||
switch (s) {
|
||||
case TEXT_INGESTED:
|
||||
@ -321,6 +336,7 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append("<table border=0><tr><td>").append(NbBundle.getMessage(this.getClass(), "KeywordSearchIngestModule.postIndexSummary.knowFileHeaderLbl")).append("</td><td>").append(text_ingested).append("</td></tr>");
|
||||
@ -393,16 +409,16 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
private boolean extractStringsAndIndex(AbstractFile aFile) {
|
||||
try {
|
||||
if (stringExtractor.index(aFile)) {
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.STRINGS_INGESTED);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.STRINGS_INGESTED);
|
||||
return true;
|
||||
} else {
|
||||
logger.log(Level.WARNING, "Failed to extract strings and ingest, file ''{0}'' (id: {1}).", new Object[]{aFile.getName(), aFile.getId()});
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.SKIPPED_ERROR_TEXTEXTRACT);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.SKIPPED_ERROR_TEXTEXTRACT);
|
||||
return false;
|
||||
}
|
||||
} catch (IngesterException ex) {
|
||||
logger.log(Level.WARNING, "Failed to extract strings and ingest, file '" + aFile.getName() + "' (id: " + aFile.getId() + ").", ex);
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -448,9 +464,9 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
if ((indexContent == false || aFile.isDir() || size == 0)) {
|
||||
try {
|
||||
ingester.ingest(aFile, false); //meta-data only
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.METADATA_INGESTED);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.METADATA_INGESTED);
|
||||
} catch (IngesterException ex) {
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
logger.log(Level.WARNING, "Unable to index meta-data for file: " + aFile.getId(), ex);
|
||||
}
|
||||
return;
|
||||
@ -484,9 +500,9 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
if (AbstractFileExtract.ARCHIVE_MIME_TYPES.contains(detectedFormat)) {
|
||||
try {
|
||||
ingester.ingest(aFile, false); //meta-data only
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.METADATA_INGESTED);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.METADATA_INGESTED);
|
||||
} catch (IngesterException ex) {
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
logger.log(Level.WARNING, "Unable to index meta-data for file: " + aFile.getId(), ex);
|
||||
}
|
||||
return;
|
||||
@ -499,20 +515,20 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
//logger.log(Level.INFO, "indexing: " + aFile.getName());
|
||||
if (!extractTextAndIndex(aFile, detectedFormat)) {
|
||||
logger.log(Level.WARNING, "Failed to extract text and ingest, file ''{0}'' (id: {1}).", new Object[]{aFile.getName(), aFile.getId()});
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.SKIPPED_ERROR_TEXTEXTRACT);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.SKIPPED_ERROR_TEXTEXTRACT);
|
||||
} else {
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.TEXT_INGESTED);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.TEXT_INGESTED);
|
||||
wasTextAdded = true;
|
||||
}
|
||||
|
||||
} catch (IngesterException e) {
|
||||
logger.log(Level.INFO, "Could not extract text with Tika, " + aFile.getId() + ", "
|
||||
+ aFile.getName(), e);
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.SKIPPED_ERROR_INDEXING);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Error extracting text with Tika, " + aFile.getId() + ", "
|
||||
+ aFile.getName(), e);
|
||||
ingestStatus.put(aFile.getId(), IngestStatus.SKIPPED_ERROR_TEXTEXTRACT);
|
||||
putIngestStatus(aFile.getId(), IngestStatus.SKIPPED_ERROR_TEXTEXTRACT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -522,5 +538,4 @@ public final class KeywordSearchIngestModule extends IngestModuleAdapter impleme
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class ScalpelCarverIngestModule extends IngestModuleAdapter implements FileInges
|
||||
private static final Logger logger = Logger.getLogger(ScalpelCarverIngestModule.class.getName());
|
||||
private final String MODULE_OUTPUT_DIR_NAME = "ScalpelCarver";
|
||||
private String moduleOutputDirPath;
|
||||
private String configFileName = "scalpel.conf";
|
||||
private final String configFileName = "scalpel.conf";
|
||||
private String configFilePath;
|
||||
private boolean initialized = false;
|
||||
private ScalpelCarver carver;
|
||||
|
@ -54,7 +54,6 @@ public final class ThunderbirdMboxFileIngestModule extends IngestModuleAdapter i
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ThunderbirdMboxFileIngestModule.class.getName());
|
||||
private IngestServices services = IngestServices.getInstance();
|
||||
private int messageId = 0; // RJCTODO: Not thread safe
|
||||
private FileManager fileManager;
|
||||
private IngestJobContext context;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user