19 package org.sleuthkit.autopsy.centralrepository.ingestmodule;
23 import java.util.List;
24 import java.util.logging.Level;
25 import java.util.stream.Collectors;
26 import org.openide.util.NbBundle.Messages;
59 @Messages({
"IngestModule.prevTaggedSet.text=Previously Tagged As Notable (Central Repository)",
60 "IngestModule.prevCaseComment.text=Previous Case: "})
63 static final boolean DEFAULT_FLAG_TAGGED_NOTABLE_ITEMS =
true;
75 private final boolean flagTaggedNotableItems;
82 IngestModule(IngestSettings settings) {
83 flagTaggedNotableItems = settings.isFlagTaggedNotableItems();
87 public ProcessResult process(AbstractFile abstractFile) {
95 return ProcessResult.OK;
101 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
102 return ProcessResult.ERROR;
106 return ProcessResult.OK;
109 if (abstractFile.getKnown() == TskData.FileKnown.KNOWN) {
110 return ProcessResult.OK;
117 logger.log(Level.SEVERE,
"Error connecting to Central Repository database.", ex);
118 return ProcessResult.ERROR;
122 if (!filesType.isEnabled()) {
123 return ProcessResult.OK;
127 String md5 = abstractFile.getMd5Hash();
128 if ((md5 == null) || (HashUtility.isNoDataMd5(md5))) {
129 return ProcessResult.OK;
136 if (abstractFile.getKnown() != TskData.FileKnown.KNOWN && flagTaggedNotableItems) {
141 if (!caseDisplayNamesList.isEmpty()) {
142 postCorrelatedBadFileToBlackboard(abstractFile, caseDisplayNamesList);
145 logger.log(Level.SEVERE,
"Error searching database for artifact.", ex);
146 return ProcessResult.ERROR;
156 abstractFile.getParentPath() + abstractFile.
getName(),
158 TskData.FileKnown.UNKNOWN
163 logger.log(Level.SEVERE,
"Error adding artifact to bulk artifacts.", ex);
164 return ProcessResult.ERROR;
167 return ProcessResult.OK;
171 public void shutDown() {
174 if ((
EamDb.
isEnabled() ==
false) || (eamCase == null) || (eamDataSource == null)) {
181 logger.log(Level.SEVERE,
"Error connecting to Central Repository database.", ex);
187 logger.log(Level.SEVERE,
"Error doing bulk insert of artifacts.", ex);
191 logger.log(Level.INFO,
"{0} artifacts in db for case: {1} ds:{2}",
new Object[]{count, eamCase.getDisplayName(), eamDataSource.getName()});
193 logger.log(Level.SEVERE,
"Error counting artifacts.", ex);
202 "IngestModule.notfyBubble.title=Central Repository Not Initialized",
203 "IngestModule.errorMessage.isNotEnabled=Central repository settings are not initialized, cannot run Correlation Engine ingest module."
206 public void startUp(
IngestJobContext context)
throws IngestModuleException {
246 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
247 throw new IngestModuleException(
"Exception while getting open case.", ex);
253 logger.log(Level.SEVERE,
"Cannot run correlation engine on a multi-user case with a SQLite central repository.");
254 throw new IngestModuleException(
"Cannot run on a multi-user case with a SQLite central repository.");
262 logger.log(Level.SEVERE,
"Error connecting to central repository database.", ex);
263 throw new IngestModuleException(
"Error connecting to central repository database.", ex);
269 logger.log(Level.SEVERE,
"Error getting correlation type FILES in ingest module start up.", ex);
270 throw new IngestModuleException(
"Error getting correlation type FILES in ingest module start up.", ex);
274 eamCase = centralRepoDb.
getCase(autopsyCase);
276 throw new IngestModuleException(
"Unable to get case from central repository database ", ex);
278 if (eamCase == null) {
281 eamCase = centralRepoDb.
newCase(autopsyCase);
283 logger.log(Level.SEVERE,
"Error creating new case in ingest module start up.", ex);
284 throw new IngestModuleException(
"Error creating new case in ingest module start up.", ex);
291 logger.log(Level.SEVERE,
"Error getting data source info.", ex);
292 throw new IngestModuleException(
"Error getting data source info.", ex);
305 logger.log(Level.SEVERE,
"Error adding data source to Central Repository.", ex);
306 throw new IngestModuleException(
"Error adding data source to Central Repository.", ex);
312 private void postCorrelatedBadFileToBlackboard(AbstractFile abstractFile, List<String> caseDisplayNames) {
316 BlackboardArtifact tifArtifact = abstractFile.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
317 BlackboardAttribute att =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, MODULE_NAME,
318 Bundle.IngestModule_prevTaggedSet_text());
319 BlackboardAttribute att2 =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COMMENT, MODULE_NAME,
320 Bundle.IngestModule_prevCaseComment_text() + caseDisplayNames.stream().distinct().collect(Collectors.joining(
",",
"",
"")));
321 tifArtifact.addAttribute(att);
322 tifArtifact.addAttribute(att2);
328 logger.log(Level.SEVERE,
"Unable to index blackboard artifact " + tifArtifact.getArtifactID(), ex);
332 sendBadFileInboxMessage(tifArtifact, abstractFile.getName(), abstractFile.getMd5Hash());
336 }
catch (TskCoreException ex) {
337 logger.log(Level.SEVERE,
"Failed to create BlackboardArtifact.", ex);
338 }
catch (IllegalStateException ex) {
339 logger.log(Level.SEVERE,
"Failed to create BlackboardAttribute.", ex);
351 @Messages({
"IngestModule.postToBB.fileName=File Name",
352 "IngestModule.postToBB.md5Hash=MD5 Hash",
353 "IngestModule.postToBB.hashSetSource=Source of Hash",
354 "IngestModule.postToBB.eamHit=Central Repository",
355 "# {0} - Name of file that is Notable",
356 "IngestModule.postToBB.knownBadMsg=Notable: {0}"})
357 public void sendBadFileInboxMessage(BlackboardArtifact artifact, String name, String md5Hash) {
358 StringBuilder detailsSb =
new StringBuilder();
360 detailsSb.append(
"<table border='0' cellpadding='4' width='280'>");
362 detailsSb.append(
"<tr>");
363 detailsSb.append(
"<th>")
364 .append(Bundle.IngestModule_postToBB_fileName())
366 detailsSb.append(
"<td>")
369 detailsSb.append(
"</tr>");
371 detailsSb.append(
"<tr>");
372 detailsSb.append(
"<th>")
373 .append(Bundle.IngestModule_postToBB_md5Hash())
375 detailsSb.append(
"<td>").append(md5Hash).append(
"</td>");
376 detailsSb.append(
"</tr>");
378 detailsSb.append(
"<tr>");
379 detailsSb.append(
"<th>")
380 .append(Bundle.IngestModule_postToBB_hashSetSource())
382 detailsSb.append(
"<td>").append(Bundle.IngestModule_postToBB_eamHit()).append(
"</td>");
383 detailsSb.append(
"</tr>");
385 detailsSb.append(
"</table>");
388 Bundle.IngestModule_postToBB_knownBadMsg(name),
389 detailsSb.toString(),
CorrelationDataSource getDataSource(CorrelationCase correlationCase, String dataSourceDeviceId)
CorrelationAttribute.Type getCorrelationTypeById(int typeId)
synchronized long decrementAndGet(long jobId)
static synchronized int getCeModuleInstanceCount()
static void submitTimingMetric(TimingMetric metric)
static IngestMessage createDataMessage(String source, String subject, String detailsHtml, String uniqueKey, BlackboardArtifact data)
static boolean runningWithGUI
static final int FILES_TYPE_ID
void prepareBulkArtifact(CorrelationAttribute eamArtifact)
CorrelationCase newCase(CorrelationCase eamCase)
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)
static boolean isSupportedAbstractFileType(AbstractFile file)
synchronized long incrementAndGet(long jobId)
void bulkInsertArtifacts()
List< String > getListCasesHavingArtifactInstancesKnownBad(CorrelationAttribute.Type aType, String value)
void addInstance(CorrelationAttributeInstance artifactInstance)
static synchronized boolean isFlagNotableItems()
static EamDb getInstance()
static TimingMetric getTimingMetric(String name)
void postMessage(final IngestMessage message)
void fireModuleDataEvent(ModuleDataEvent moduleDataEvent)
Long getCountArtifactInstancesByCaseDataSource(String caseUUID, String dataSourceID)
static boolean isEnabled()
static synchronized void setFlagNotableItems(boolean value)
Blackboard getBlackboard()
CorrelationCase getCase(Case autopsyCase)
synchronized void indexArtifact(BlackboardArtifact artifact)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static synchronized void incrementCorrelationEngineModuleCount()
static synchronized void decrementCorrelationEngineModuleCount()
static void warn(String title, String message)
void newDataSource(CorrelationDataSource eamDataSource)
static synchronized IngestServices getInstance()