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;
148 logger.log(Level.INFO,
"Error searching database for artifact.", ex);
149 return ProcessResult.ERROR;
160 abstractFile.getParentPath() + abstractFile.
getName(),
162 TskData.FileKnown.UNKNOWN
166 logger.log(Level.SEVERE,
"Error adding artifact to bulk artifacts.", ex);
167 return ProcessResult.ERROR;
169 logger.log(Level.INFO,
"Error adding artifact to bulk artifacts.", ex);
170 return ProcessResult.ERROR;
173 return ProcessResult.OK;
177 public void shutDown() {
180 if ((
EamDb.
isEnabled() ==
false) || (eamCase == null) || (eamDataSource == null)) {
187 logger.log(Level.SEVERE,
"Error connecting to Central Repository database.", ex);
193 logger.log(Level.SEVERE,
"Error doing bulk insert of artifacts.", ex);
197 logger.log(Level.INFO,
"{0} artifacts in db for case: {1} ds:{2}",
new Object[]{count, eamCase.getDisplayName(), eamDataSource.getName()});
199 logger.log(Level.SEVERE,
"Error counting artifacts.", ex);
208 "IngestModule.notfyBubble.title=Central Repository Not Initialized",
209 "IngestModule.errorMessage.isNotEnabled=Central repository settings are not initialized, cannot run Correlation Engine ingest module."
212 public void startUp(
IngestJobContext context)
throws IngestModuleException {
252 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
253 throw new IngestModuleException(
"Exception while getting open case.", ex);
259 logger.log(Level.SEVERE,
"Cannot run correlation engine on a multi-user case with a SQLite central repository.");
260 throw new IngestModuleException(
"Cannot run on a multi-user case with a SQLite central repository.");
268 logger.log(Level.SEVERE,
"Error connecting to central repository database.", ex);
269 throw new IngestModuleException(
"Error connecting to central repository database.", ex);
275 logger.log(Level.SEVERE,
"Error getting correlation type FILES in ingest module start up.", ex);
276 throw new IngestModuleException(
"Error getting correlation type FILES in ingest module start up.", ex);
280 eamCase = centralRepoDb.
getCase(autopsyCase);
282 throw new IngestModuleException(
"Unable to get case from central repository database ", ex);
284 if (eamCase == null) {
287 eamCase = centralRepoDb.
newCase(autopsyCase);
289 logger.log(Level.SEVERE,
"Error creating new case in ingest module start up.", ex);
290 throw new IngestModuleException(
"Error creating new case in ingest module start up.", ex);
297 logger.log(Level.SEVERE,
"Error getting data source info.", ex);
298 throw new IngestModuleException(
"Error getting data source info.", ex);
311 logger.log(Level.SEVERE,
"Error adding data source to Central Repository.", ex);
312 throw new IngestModuleException(
"Error adding data source to Central Repository.", ex);
318 private void postCorrelatedBadFileToBlackboard(AbstractFile abstractFile, List<String> caseDisplayNames) {
322 BlackboardArtifact tifArtifact = abstractFile.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
323 BlackboardAttribute att =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME, MODULE_NAME,
324 Bundle.IngestModule_prevTaggedSet_text());
325 BlackboardAttribute att2 =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_COMMENT, MODULE_NAME,
326 Bundle.IngestModule_prevCaseComment_text() + caseDisplayNames.stream().distinct().collect(Collectors.joining(
",",
"",
"")));
327 tifArtifact.addAttribute(att);
328 tifArtifact.addAttribute(att2);
334 logger.log(Level.SEVERE,
"Unable to index blackboard artifact " + tifArtifact.getArtifactID(), ex);
338 sendBadFileInboxMessage(tifArtifact, abstractFile.getName(), abstractFile.getMd5Hash());
342 }
catch (TskCoreException ex) {
343 logger.log(Level.SEVERE,
"Failed to create BlackboardArtifact.", ex);
344 }
catch (IllegalStateException ex) {
345 logger.log(Level.SEVERE,
"Failed to create BlackboardAttribute.", ex);
357 @Messages({
"IngestModule.postToBB.fileName=File Name",
358 "IngestModule.postToBB.md5Hash=MD5 Hash",
359 "IngestModule.postToBB.hashSetSource=Source of Hash",
360 "IngestModule.postToBB.eamHit=Central Repository",
361 "# {0} - Name of file that is Notable",
362 "IngestModule.postToBB.knownBadMsg=Notable: {0}"})
363 public void sendBadFileInboxMessage(BlackboardArtifact artifact, String name, String md5Hash) {
364 StringBuilder detailsSb =
new StringBuilder();
366 detailsSb.append(
"<table border='0' cellpadding='4' width='280'>");
368 detailsSb.append(
"<tr>");
369 detailsSb.append(
"<th>")
370 .append(Bundle.IngestModule_postToBB_fileName())
372 detailsSb.append(
"<td>")
375 detailsSb.append(
"</tr>");
377 detailsSb.append(
"<tr>");
378 detailsSb.append(
"<th>")
379 .append(Bundle.IngestModule_postToBB_md5Hash())
381 detailsSb.append(
"<td>").append(md5Hash).append(
"</td>");
382 detailsSb.append(
"</tr>");
384 detailsSb.append(
"<tr>");
385 detailsSb.append(
"<th>")
386 .append(Bundle.IngestModule_postToBB_hashSetSource())
388 detailsSb.append(
"<td>").append(Bundle.IngestModule_postToBB_eamHit()).append(
"</td>");
389 detailsSb.append(
"</tr>");
391 detailsSb.append(
"</table>");
394 Bundle.IngestModule_postToBB_knownBadMsg(name),
395 detailsSb.toString(),
CorrelationDataSource getDataSource(CorrelationCase correlationCase, String dataSourceDeviceId)
synchronized long decrementAndGet(long jobId)
static synchronized int getCeModuleInstanceCount()
static IngestMessage createDataMessage(String source, String subject, String detailsHtml, String uniqueKey, BlackboardArtifact data)
static boolean runningWithGUI
List< String > getListCasesHavingArtifactInstancesKnownBad(CorrelationAttributeInstance.Type aType, String value)
CorrelationCase newCase(CorrelationCase eamCase)
static CorrelationDataSource fromTSKDataSource(CorrelationCase correlationCase, Content dataSource)
static boolean isSupportedAbstractFileType(AbstractFile file)
synchronized long incrementAndGet(long jobId)
static TimingMetric getTimingMetric(String name)
static synchronized boolean isFlagNotableItems()
void addAttributeInstanceBulk(CorrelationAttributeInstance eamArtifact)
static EamDb getInstance()
void commitAttributeInstancesBulk()
CorrelationAttributeInstance.Type getCorrelationTypeById(int typeId)
void postMessage(final IngestMessage message)
void fireModuleDataEvent(ModuleDataEvent moduleDataEvent)
Long getCountArtifactInstancesByCaseDataSource(String caseUUID, String dataSourceID)
static boolean isEnabled()
static synchronized void setFlagNotableItems(boolean value)
static void submitTimingMetric(TimingMetric metric)
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 final int FILES_TYPE_ID
static synchronized IngestServices getInstance()