19 package org.sleuthkit.autopsy.modules.interestingitems;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
25 import java.util.concurrent.ConcurrentHashMap;
26 import java.util.logging.Level;
42 final class FilesIdentifierIngestModule
implements FileIngestModule {
44 private static final Object sharedResourcesLock =
new Object();
45 private static final Logger logger = Logger.getLogger(FilesIdentifierIngestModule.class.getName());
46 private static final IngestModuleReferenceCounter refCounter =
new IngestModuleReferenceCounter();
47 private static final Map<Long, List<FilesSet>> interestingFileSetsByJob =
new ConcurrentHashMap<>();
48 private final FilesIdentifierIngestJobSettings settings;
49 private IngestJobContext context;
57 FilesIdentifierIngestModule(FilesIdentifierIngestJobSettings settings) {
58 this.settings = settings;
65 public void startUp(IngestJobContext context)
throws IngestModuleException {
66 this.context = context;
67 synchronized (FilesIdentifierIngestModule.sharedResourcesLock) {
68 if (FilesIdentifierIngestModule.refCounter.incrementAndGet(context.getJobId()) == 1) {
74 List<FilesSet> filesSets =
new ArrayList<>();
75 for (FilesSet set : InterestingItemDefsManager.getInstance().getInterestingFilesSets().values()) {
76 if (settings.interestingFilesSetIsEnabled(set.getName())) {
80 FilesIdentifierIngestModule.interestingFileSetsByJob.put(context.getJobId(), filesSets);
89 public ProcessResult process(AbstractFile file) {
91 List<FilesSet> filesSets = FilesIdentifierIngestModule.interestingFileSetsByJob.get(this.context.getJobId());
92 for (FilesSet filesSet : filesSets) {
93 String ruleSatisfied = filesSet.fileIsMemberOf(file);
94 if (ruleSatisfied != null) {
98 String moduleName = InterestingItemsIngestModuleFactory.getModuleName();
99 BlackboardArtifact artifact = file.newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT);
106 BlackboardAttribute setNameAttribute =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SET_NAME.getTypeID(), moduleName, filesSet.getName());
107 artifact.addAttribute(setNameAttribute);
111 BlackboardAttribute ruleNameAttribute =
new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_CATEGORY.getTypeID(), moduleName, ruleSatisfied);
112 artifact.addAttribute(ruleNameAttribute);
114 IngestServices.getInstance().fireModuleDataEvent(
new ModuleDataEvent(moduleName, BlackboardArtifact.ARTIFACT_TYPE.TSK_INTERESTING_FILE_HIT, Collections.singletonList(artifact)));
116 }
catch (TskCoreException ex) {
117 FilesIdentifierIngestModule.logger.log(Level.SEVERE,
"Error posting to the blackboard", ex);
121 return ProcessResult.OK;
128 public void shutDown() {
129 if (refCounter.decrementAndGet(
this.context.getJobId()) == 0) {
133 FilesIdentifierIngestModule.interestingFileSetsByJob.remove(this.context.getJobId());