mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
- added class ServiceDataEvent - services can notify listeners of new data while they are still processing, and send artifact type, and optionally IDs of all new artifacts (dir tree can refresh more efficiently)
- keyword search now sending the new event
This commit is contained in:
parent
55735bafcb
commit
ff136f5c3b
@ -94,7 +94,7 @@ public class IngestImageThread extends SwingWorker {
|
|||||||
//notify services of completion
|
//notify services of completion
|
||||||
if (!this.isCancelled()) {
|
if (!this.isCancelled()) {
|
||||||
service.complete();
|
service.complete();
|
||||||
IngestManager.firePropertyChange(IngestManager.SERVICE_COMPLETED_EVT, service.getName());
|
IngestManager.fireServiceEvent(IngestManager.SERVICE_COMPLETED_EVT, service.getName());
|
||||||
}
|
}
|
||||||
} catch (CancellationException e) {
|
} catch (CancellationException e) {
|
||||||
//task was cancelled
|
//task was cancelled
|
||||||
@ -117,6 +117,6 @@ public class IngestImageThread extends SwingWorker {
|
|||||||
|
|
||||||
private void handleInterruption() {
|
private void handleInterruption() {
|
||||||
service.stop();
|
service.stop();
|
||||||
IngestManager.firePropertyChange(IngestManager.SERVICE_STOPPED_EVT, service.getName());
|
IngestManager.fireServiceEvent(IngestManager.SERVICE_STOPPED_EVT, service.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,12 @@ public class IngestManager {
|
|||||||
pcs.addPropertyChangeListener(l);
|
pcs.addPropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void firePropertyChange(String property, String serviceName) {
|
public static synchronized void fireServiceEvent(String eventType, String serviceName) {
|
||||||
pcs.firePropertyChange(property, serviceName, null);
|
pcs.firePropertyChange(eventType, serviceName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static synchronized void fireServiceDataEvent(ServiceDataEvent serviceDataEvent) {
|
||||||
|
pcs.firePropertyChange(SERVICE_HAS_DATA_EVT, serviceDataEvent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +116,7 @@ public class IngestManager {
|
|||||||
* @param images images to execute services on
|
* @param images images to execute services on
|
||||||
*/
|
*/
|
||||||
void execute(final Collection<IngestServiceAbstract> services, final Collection<Image> images) {
|
void execute(final Collection<IngestServiceAbstract> services, final Collection<Image> images) {
|
||||||
logger.log(Level.INFO, "Will enqueue number of images: " + images.size() );
|
logger.log(Level.INFO, "Will enqueue number of images: " + images.size());
|
||||||
/*if (!initialized) {
|
/*if (!initialized) {
|
||||||
//one time initialization of services
|
//one time initialization of services
|
||||||
|
|
||||||
@ -146,7 +150,7 @@ public class IngestManager {
|
|||||||
void execute(final Collection<IngestServiceAbstract> services, final Image image) {
|
void execute(final Collection<IngestServiceAbstract> services, final Image image) {
|
||||||
Collection<Image> images = new ArrayList<Image>();
|
Collection<Image> images = new ArrayList<Image>();
|
||||||
images.add(image);
|
images.add(image);
|
||||||
logger.log(Level.INFO, "Will enqueue image: " + image.getName() );
|
logger.log(Level.INFO, "Will enqueue image: " + image.getName());
|
||||||
execute(services, images);
|
execute(services, images);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +202,7 @@ public class IngestManager {
|
|||||||
//image services are now initialized per instance
|
//image services are now initialized per instance
|
||||||
quService.init(managerProxy);
|
quService.init(managerProxy);
|
||||||
newImageWorker.execute();
|
newImageWorker.execute();
|
||||||
IngestManager.firePropertyChange(SERVICE_STARTED_EVT, quService.getName());
|
IngestManager.fireServiceEvent(SERVICE_STARTED_EVT, quService.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,8 +754,7 @@ public class IngestManager {
|
|||||||
Integer curServiceErrorI = errors.get(source);
|
Integer curServiceErrorI = errors.get(source);
|
||||||
if (curServiceErrorI == null) {
|
if (curServiceErrorI == null) {
|
||||||
errors.put(source, 1);
|
errors.put(source, 1);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
errors.put(source, curServiceErrorI + 1);
|
errors.put(source, curServiceErrorI + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -777,7 +780,7 @@ public class IngestManager {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (IngestServiceFsContent s : fsContentServices) {
|
for (IngestServiceFsContent s : fsContentServices) {
|
||||||
IngestManager.firePropertyChange(SERVICE_STARTED_EVT, s.getName());
|
IngestManager.fireServiceEvent(SERVICE_STARTED_EVT, s.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -835,7 +838,7 @@ public class IngestManager {
|
|||||||
if (!this.isCancelled()) {
|
if (!this.isCancelled()) {
|
||||||
for (IngestServiceFsContent s : fsContentServices) {
|
for (IngestServiceFsContent s : fsContentServices) {
|
||||||
s.complete();
|
s.complete();
|
||||||
IngestManager.firePropertyChange(SERVICE_COMPLETED_EVT, s.getName());
|
IngestManager.fireServiceEvent(SERVICE_COMPLETED_EVT, s.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -868,7 +871,7 @@ public class IngestManager {
|
|||||||
private void handleInterruption() {
|
private void handleInterruption() {
|
||||||
for (IngestServiceFsContent s : fsContentServices) {
|
for (IngestServiceFsContent s : fsContentServices) {
|
||||||
s.stop();
|
s.stop();
|
||||||
IngestManager.firePropertyChange(SERVICE_STOPPED_EVT, s.getName());
|
IngestManager.fireServiceEvent(SERVICE_STOPPED_EVT, s.getName());
|
||||||
}
|
}
|
||||||
//empty queues
|
//empty queues
|
||||||
emptyFsContents();
|
emptyFsContents();
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2011 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.sleuthkit.autopsy.ingest;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* representation of an event fired off by services when they have posted new data
|
||||||
|
* of specific type
|
||||||
|
* additionally, new artifact ids can be provided
|
||||||
|
*/
|
||||||
|
public class ServiceDataEvent {
|
||||||
|
|
||||||
|
private String serviceName;
|
||||||
|
private ARTIFACT_TYPE artifactType;
|
||||||
|
private Collection<Long> artifactIDs;
|
||||||
|
|
||||||
|
public ServiceDataEvent(String serviceName, ARTIFACT_TYPE artifactType) {
|
||||||
|
this.serviceName = serviceName;
|
||||||
|
this.artifactType = artifactType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceDataEvent(String serviceName, ARTIFACT_TYPE artifactType, Collection<Long> artifactIDs) {
|
||||||
|
this(serviceName, artifactType);
|
||||||
|
this.artifactIDs = artifactIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get new artifact IDs associated with the event
|
||||||
|
* @return Collection of artifact ids or null if not provided
|
||||||
|
*/
|
||||||
|
public Collection<Long> getArtifactIDs() {
|
||||||
|
return artifactIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get artifact type of the new artifacts associated with the event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ARTIFACT_TYPE getArtifactType() {
|
||||||
|
return artifactType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get service name that created the artifacts and fired the event
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getServiceName() {
|
||||||
|
return serviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.keywordsearch;
|
package org.sleuthkit.autopsy.keywordsearch;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -40,6 +39,7 @@ import org.sleuthkit.autopsy.ingest.IngestManagerProxy;
|
|||||||
import org.sleuthkit.autopsy.ingest.IngestMessage;
|
import org.sleuthkit.autopsy.ingest.IngestMessage;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestMessage.MessageType;
|
import org.sleuthkit.autopsy.ingest.IngestMessage.MessageType;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestServiceFsContent;
|
import org.sleuthkit.autopsy.ingest.IngestServiceFsContent;
|
||||||
|
import org.sleuthkit.autopsy.ingest.ServiceDataEvent;
|
||||||
import org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException;
|
import org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||||
@ -443,12 +443,14 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent
|
|||||||
managerProxy.postMessage(IngestMessage.createMessage(++messageID, MessageType.INFO, instance, sb.toString()));
|
managerProxy.postMessage(IngestMessage.createMessage(++messageID, MessageType.INFO, instance, sb.toString()));
|
||||||
|
|
||||||
//write results to BB
|
//write results to BB
|
||||||
|
Collection<Long> newArtifacts = new ArrayList<Long>(); //new artifacts to report
|
||||||
for (FsContent hitFile : newResults) {
|
for (FsContent hitFile : newResults) {
|
||||||
Collection<BlackboardAttribute> attributes = new ArrayList<BlackboardAttribute>();
|
Collection<BlackboardAttribute> attributes = new ArrayList<BlackboardAttribute>();
|
||||||
if (query.isLiteral()) {
|
if (query.isLiteral()) {
|
||||||
BlackboardArtifact bba = null;
|
BlackboardArtifact bba = null;
|
||||||
try {
|
try {
|
||||||
bba = hitFile.newArtifact(ARTIFACT_TYPE.TSK_KEYWORD_HIT);
|
bba = hitFile.newArtifact(ARTIFACT_TYPE.TSK_KEYWORD_HIT);
|
||||||
|
newArtifacts.add(bba.getArtifactID());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.INFO, "Error adding bb artifact for keyword hit", e);
|
logger.log(Level.INFO, "Error adding bb artifact for keyword hit", e);
|
||||||
continue;
|
continue;
|
||||||
@ -510,6 +512,7 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent
|
|||||||
BlackboardArtifact bba = null;
|
BlackboardArtifact bba = null;
|
||||||
try {
|
try {
|
||||||
bba = hitFile.newArtifact(ARTIFACT_TYPE.TSK_KEYWORD_HIT);
|
bba = hitFile.newArtifact(ARTIFACT_TYPE.TSK_KEYWORD_HIT);
|
||||||
|
newArtifacts.add(bba.getArtifactID());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.INFO, "Error adding bb artifact for keyword hit", e);
|
logger.log(Level.INFO, "Error adding bb artifact for keyword hit", e);
|
||||||
continue;
|
continue;
|
||||||
@ -546,9 +549,7 @@ public final class KeywordSearchIngestService implements IngestServiceFsContent
|
|||||||
} //for each file hit
|
} //for each file hit
|
||||||
|
|
||||||
//update artifact browser
|
//update artifact browser
|
||||||
//TODO use has data evt
|
IngestManager.fireServiceDataEvent(new ServiceDataEvent(MODULE_NAME, ARTIFACT_TYPE.TSK_KEYWORD_HIT, newArtifacts));
|
||||||
IngestManager.firePropertyChange(IngestManager.SERVICE_STARTED_EVT, MODULE_NAME);
|
|
||||||
IngestManager.firePropertyChange(IngestManager.SERVICE_HAS_DATA_EVT, MODULE_NAME);
|
|
||||||
}
|
}
|
||||||
progress.progress(queryStr, ++numSearched);
|
progress.progress(queryStr, ++numSearched);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user