mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #6595 from rcordovano/update-custom-artifact-test-module
Update custom artifacts test module to post to Blackboard
This commit is contained in:
commit
71801239bb
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2018 Basis Technology Corp.
|
* Copyright 2017-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -21,8 +21,8 @@ package org.sleuthkit.autopsy.test;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.xml.bind.DatatypeConverter;
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
|
||||||
import org.sleuthkit.datamodel.Blackboard;
|
import org.sleuthkit.datamodel.Blackboard;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardAttribute;
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
@ -67,8 +67,8 @@ final class CustomArtifactType {
|
|||||||
*
|
*
|
||||||
* @throws BlackboardException If there is an error adding any of the types.
|
* @throws BlackboardException If there is an error adding any of the types.
|
||||||
*/
|
*/
|
||||||
static void addToCaseDatabase() throws Blackboard.BlackboardException, NoCurrentCaseException {
|
static void addToCaseDatabase() throws Blackboard.BlackboardException {
|
||||||
Blackboard blackboard = Case.getCurrentCaseThrows().getServices().getArtifactsBlackboard();
|
Blackboard blackboard = Case.getCurrentCase().getServices().getArtifactsBlackboard();
|
||||||
artifactType = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAME, ARTIFACT_DISPLAY_NAME);
|
artifactType = blackboard.getOrAddArtifactType(ARTIFACT_TYPE_NAME, ARTIFACT_DISPLAY_NAME);
|
||||||
intAttrType = blackboard.getOrAddAttributeType(INT_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER, INT_ATTR_DISPLAY_NAME);
|
intAttrType = blackboard.getOrAddAttributeType(INT_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER, INT_ATTR_DISPLAY_NAME);
|
||||||
doubleAttrType = blackboard.getOrAddAttributeType(DOUBLE_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE, DOUBLE_ATTR_DISPLAY_NAME);
|
doubleAttrType = blackboard.getOrAddAttributeType(DOUBLE_ATTR_TYPE_NAME, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE, DOUBLE_ATTR_DISPLAY_NAME);
|
||||||
@ -80,21 +80,25 @@ final class CustomArtifactType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and instance of the custom artifact type.
|
* Creates an instance of the custom artifact type and posts it to the
|
||||||
|
* blackboard.
|
||||||
*
|
*
|
||||||
* @param source The artifact source content.
|
* @param source The artifact source content.
|
||||||
*
|
*
|
||||||
* @return A BlackboardArtifact object.
|
* @return A BlackboardArtifact object.
|
||||||
*
|
*
|
||||||
* @throws TskCoreException If there is an error creating the artifact.
|
* @throws TskCoreException If there is an error creating the
|
||||||
|
* artifact.
|
||||||
|
* @throws Blackboard.BlackboardException If there is an error posting the
|
||||||
|
* artifact to the blackboard.
|
||||||
*/
|
*/
|
||||||
static BlackboardArtifact createInstance(Content source) throws TskCoreException {
|
static BlackboardArtifact createAndPostInstance(Content source) throws TskCoreException, Blackboard.BlackboardException {
|
||||||
BlackboardArtifact artifact = source.newArtifact(artifactType.getTypeID());
|
BlackboardArtifact artifact = source.newArtifact(artifactType.getTypeID());
|
||||||
List<BlackboardAttribute> attributes = new ArrayList<>();
|
List<BlackboardAttribute> attributes = new ArrayList<>();
|
||||||
attributes.add(new BlackboardAttribute(intAttrType, MODULE_NAME, 0));
|
attributes.add(new BlackboardAttribute(intAttrType, MODULE_NAME, 0));
|
||||||
attributes.add(new BlackboardAttribute(doubleAttrType, MODULE_NAME, 0.0));
|
attributes.add(new BlackboardAttribute(doubleAttrType, MODULE_NAME, 0.0));
|
||||||
attributes.add(new BlackboardAttribute(longAttributeType, MODULE_NAME, 0L));
|
attributes.add(new BlackboardAttribute(longAttributeType, MODULE_NAME, 0L));
|
||||||
attributes.add(new BlackboardAttribute(dateTimeAttrType, MODULE_NAME, 60L));
|
attributes.add(new BlackboardAttribute(dateTimeAttrType, MODULE_NAME, DateTime.now().getMillis()/1000));
|
||||||
attributes.add(new BlackboardAttribute(bytesAttrType, MODULE_NAME, DatatypeConverter.parseHexBinary("ABCD")));
|
attributes.add(new BlackboardAttribute(bytesAttrType, MODULE_NAME, DatatypeConverter.parseHexBinary("ABCD")));
|
||||||
attributes.add(new BlackboardAttribute(stringAttrType, MODULE_NAME, "Zero"));
|
attributes.add(new BlackboardAttribute(stringAttrType, MODULE_NAME, "Zero"));
|
||||||
attributes.add(new BlackboardAttribute(jsonAttrType, MODULE_NAME, "{\"fruit\": \"Apple\",\"size\": \"Large\",\"color\": \"Red\"}"));
|
attributes.add(new BlackboardAttribute(jsonAttrType, MODULE_NAME, "{\"fruit\": \"Apple\",\"size\": \"Large\",\"color\": \"Red\"}"));
|
||||||
@ -109,6 +113,9 @@ final class CustomArtifactType {
|
|||||||
attr.addSource(ADDITIONAL_MODULE_NAME);
|
attr.addSource(ADDITIONAL_MODULE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Blackboard blackboard = Case.getCurrentCase().getServices().getArtifactsBlackboard();
|
||||||
|
blackboard.postArtifact(artifact, MODULE_NAME);
|
||||||
|
|
||||||
return artifact;
|
return artifact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2018 Basis Technology Corp.
|
* Copyright 2017-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -20,7 +20,6 @@ package org.sleuthkit.autopsy.test;
|
|||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.ingest.DataSourceIngestModuleAdapter;
|
import org.sleuthkit.autopsy.ingest.DataSourceIngestModuleAdapter;
|
||||||
import org.sleuthkit.autopsy.ingest.DataSourceIngestModuleProgress;
|
import org.sleuthkit.autopsy.ingest.DataSourceIngestModuleProgress;
|
||||||
@ -54,7 +53,7 @@ public class CustomArtifactsCreatorDataSourceIngestModule extends DataSourceInge
|
|||||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||||
try {
|
try {
|
||||||
CustomArtifactType.addToCaseDatabase();
|
CustomArtifactType.addToCaseDatabase();
|
||||||
} catch (Blackboard.BlackboardException | NoCurrentCaseException ex) {
|
} catch (Blackboard.BlackboardException ex) {
|
||||||
throw new IngestModuleException(Bundle.CustomArtifactsCreatorDataSourceIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
|
throw new IngestModuleException(Bundle.CustomArtifactsCreatorDataSourceIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,8 +70,8 @@ public class CustomArtifactsCreatorDataSourceIngestModule extends DataSourceInge
|
|||||||
@Override
|
@Override
|
||||||
public ProcessResult process(Content dataSource, DataSourceIngestModuleProgress progressBar) {
|
public ProcessResult process(Content dataSource, DataSourceIngestModuleProgress progressBar) {
|
||||||
try {
|
try {
|
||||||
CustomArtifactType.createInstance(dataSource);
|
CustomArtifactType.createAndPostInstance(dataSource);
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException | Blackboard.BlackboardException ex) {
|
||||||
logger.log(Level.SEVERE, String.format("Failed to process data source (obj_id = %d)", dataSource.getId()), ex);
|
logger.log(Level.SEVERE, String.format("Failed to process data source (obj_id = %d)", dataSource.getId()), ex);
|
||||||
return ProcessResult.ERROR;
|
return ProcessResult.ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2018 Basis Technology Corp.
|
* Copyright 2017-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -20,7 +20,6 @@ package org.sleuthkit.autopsy.test;
|
|||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.ingest.FileIngestModuleAdapter;
|
import org.sleuthkit.autopsy.ingest.FileIngestModuleAdapter;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestJobContext;
|
import org.sleuthkit.autopsy.ingest.IngestJobContext;
|
||||||
@ -53,7 +52,7 @@ final class CustomArtifactsCreatorFileIngestModule extends FileIngestModuleAdapt
|
|||||||
public void startUp(IngestJobContext context) throws IngestModuleException {
|
public void startUp(IngestJobContext context) throws IngestModuleException {
|
||||||
try {
|
try {
|
||||||
CustomArtifactType.addToCaseDatabase();
|
CustomArtifactType.addToCaseDatabase();
|
||||||
} catch (Blackboard.BlackboardException | NoCurrentCaseException ex) {
|
} catch (Blackboard.BlackboardException ex) {
|
||||||
throw new IngestModuleException(Bundle.CustomArtifactsCreatorFileIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
|
throw new IngestModuleException(Bundle.CustomArtifactsCreatorFileIngestModule_exceptionMessage_errorCreatingCustomType(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,8 +71,8 @@ final class CustomArtifactsCreatorFileIngestModule extends FileIngestModuleAdapt
|
|||||||
return ProcessResult.OK;
|
return ProcessResult.OK;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
CustomArtifactType.createInstance(file);
|
CustomArtifactType.createAndPostInstance(file);
|
||||||
} catch (TskCoreException ex) {
|
} catch (TskCoreException | Blackboard.BlackboardException ex) {
|
||||||
logger.log(Level.SEVERE, String.format("Failed to process file (obj_id = %d)", file.getId()), ex);
|
logger.log(Level.SEVERE, String.format("Failed to process file (obj_id = %d)", file.getId()), ex);
|
||||||
return ProcessResult.ERROR;
|
return ProcessResult.ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2011-2017 Basis Technology Corp.
|
* Copyright 2017 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user