Skip to content
Snippets Groups Projects
Commit e79bf655 authored by Raman Arora's avatar Raman Arora
Browse files

5912: Modify the artifact creation helpers in blackboard utils to allow...

5912: Modify the artifact creation helpers in blackboard utils to allow Content as the artifact source.

 - Artifacts helper should use Content as artifact source to be more generic and more widely usable, rather than AbstractFile.
parent 17fca366
No related branches found
No related tags found
No related merge requests found
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
import java.util.Collection; import java.util.Collection;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase;
/** /**
...@@ -31,29 +31,29 @@ ...@@ -31,29 +31,29 @@
class ArtifactHelperBase { class ArtifactHelperBase {
private final SleuthkitCase caseDb; private final SleuthkitCase caseDb;
private final AbstractFile srcAbstractFile; // artifact source private final Content srcContent; // artifact source
private final String moduleName; // module creating the artifacts private final String moduleName; // module creating the artifacts
/** /**
* Creates an artifact helper. * Creates an artifact helper.
* *
* @param caseDb Sleuthkit case db * @param caseDb Sleuthkit case db
* @param moduleName name module using the helper * @param moduleName name module using the helper
* @param srcFile source file * @param srcContent source content
*/ */
ArtifactHelperBase(SleuthkitCase caseDb, String moduleName, AbstractFile srcFile) { ArtifactHelperBase(SleuthkitCase caseDb, String moduleName, Content srcContent) {
this.moduleName = moduleName; this.moduleName = moduleName;
this.srcAbstractFile = srcFile; this.srcContent = srcContent;
this.caseDb = caseDb; this.caseDb = caseDb;
} }
/** /**
* Returns the source abstract file. * Returns the source content.
* *
* @return Source abstract file. * @return Source content.
*/ */
AbstractFile getAbstractFile() { Content getContent() {
return this.srcAbstractFile; return this.srcContent;
} }
/** /**
......
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.Blackboard.BlackboardException; import org.sleuthkit.datamodel.Blackboard.BlackboardException;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
...@@ -39,11 +39,11 @@ public final class ArtifactsHelper extends ArtifactHelperBase { ...@@ -39,11 +39,11 @@ public final class ArtifactsHelper extends ArtifactHelperBase {
* *
* @param caseDb Sleuthkit case database. * @param caseDb Sleuthkit case database.
* @param moduleName Name of module using the helper. * @param moduleName Name of module using the helper.
* @param srcFile Source file for the artifacts. * @param srcContent Source content for the artifacts.
* *
*/ */
public ArtifactsHelper(SleuthkitCase caseDb, String moduleName, AbstractFile srcFile) { public ArtifactsHelper(SleuthkitCase caseDb, String moduleName, Content srcContent) {
super(caseDb, moduleName, srcFile); super(caseDb, moduleName, srcContent);
} }
/** /**
...@@ -95,7 +95,7 @@ public BlackboardArtifact addGPSLocation(double latitude, double longitude, long ...@@ -95,7 +95,7 @@ public BlackboardArtifact addGPSLocation(double latitude, double longitude, long
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create artifact // create artifact
gpsTrackpointArtifact = getAbstractFile().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT); gpsTrackpointArtifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE, getModuleName(), latitude)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE, getModuleName(), latitude));
...@@ -154,7 +154,7 @@ public BlackboardArtifact addInstalledProgram(String programName, long dateInsta ...@@ -154,7 +154,7 @@ public BlackboardArtifact addInstalledProgram(String programName, long dateInsta
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create artifact // create artifact
installedProgramArtifact = getAbstractFile().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INSTALLED_PROG); installedProgramArtifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_INSTALLED_PROG);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME, getModuleName(), programName));
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
import org.sleuthkit.datamodel.Blackboard.BlackboardException; import org.sleuthkit.datamodel.Blackboard.BlackboardException;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.DataSource;
import org.sleuthkit.datamodel.Relationship; import org.sleuthkit.datamodel.Relationship;
import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase;
...@@ -138,7 +139,7 @@ public String getDisplayName() { ...@@ -138,7 +139,7 @@ public String getDisplayName() {
* *
* @param caseDb Sleuthkit case db. * @param caseDb Sleuthkit case db.
* @param moduleName Name of module using the helper. * @param moduleName Name of module using the helper.
* @param srcFile Source file being processed by the module. * @param srcContent Source content being processed by the module.
* @param accountsType Account type {@link Account.Type} created by this * @param accountsType Account type {@link Account.Type} created by this
* module. * module.
* *
...@@ -146,13 +147,13 @@ public String getDisplayName() { ...@@ -146,13 +147,13 @@ public String getDisplayName() {
* account. * account.
*/ */
public CommunicationArtifactsHelper(SleuthkitCase caseDb, public CommunicationArtifactsHelper(SleuthkitCase caseDb,
String moduleName, AbstractFile srcFile, Account.Type accountsType) throws TskCoreException { String moduleName, Content srcContent, Account.Type accountsType) throws TskCoreException {
super(caseDb, moduleName, srcFile); super(caseDb, moduleName, srcContent);
this.moduleAccountsType = accountsType; this.moduleAccountsType = accountsType;
this.selfAccountType = Account.Type.DEVICE; this.selfAccountType = Account.Type.DEVICE;
this.selfAccountId = ((DataSource) getAbstractFile().getDataSource()).getDeviceId(); this.selfAccountId = ((DataSource) getContent().getDataSource()).getDeviceId();
} }
/** /**
...@@ -166,7 +167,7 @@ public CommunicationArtifactsHelper(SleuthkitCase caseDb, ...@@ -166,7 +167,7 @@ public CommunicationArtifactsHelper(SleuthkitCase caseDb,
* *
* @param caseDb Sleuthkit case db. * @param caseDb Sleuthkit case db.
* @param moduleName Name of module using the helper. * @param moduleName Name of module using the helper.
* @param srcFile Source file being processed by the module. * @param srcContent Source content being processed by the module.
* @param accountsType Account type {@link Account.Type} created by this * @param accountsType Account type {@link Account.Type} created by this
* module. * module.
* @param selfAccountType Self account type to be created for this module. * @param selfAccountType Self account type to be created for this module.
...@@ -174,9 +175,9 @@ public CommunicationArtifactsHelper(SleuthkitCase caseDb, ...@@ -174,9 +175,9 @@ public CommunicationArtifactsHelper(SleuthkitCase caseDb,
* *
* @throws TskCoreException If there is an error creating the self account * @throws TskCoreException If there is an error creating the self account
*/ */
public CommunicationArtifactsHelper(SleuthkitCase caseDb, String moduleName, AbstractFile srcFile, Account.Type accountsType, Account.Type selfAccountType, String selfAccountId) throws TskCoreException { public CommunicationArtifactsHelper(SleuthkitCase caseDb, String moduleName, Content srcContent, Account.Type accountsType, Account.Type selfAccountType, String selfAccountId) throws TskCoreException {
super(caseDb, moduleName, srcFile); super(caseDb, moduleName, srcContent);
this.moduleAccountsType = accountsType; this.moduleAccountsType = accountsType;
this.selfAccountType = selfAccountType; this.selfAccountType = selfAccountType;
...@@ -272,7 +273,7 @@ public BlackboardArtifact addContact(String contactName, ...@@ -272,7 +273,7 @@ public BlackboardArtifact addContact(String contactName,
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create TSK_CONTACT artifact // create TSK_CONTACT artifact
contactArtifact = getAbstractFile().newArtifact(ARTIFACT_TYPE.TSK_CONTACT); contactArtifact = getContent().newArtifact(ARTIFACT_TYPE.TSK_CONTACT);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), contactName)); attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), contactName));
...@@ -351,7 +352,7 @@ private void createContactMethodAccountAndRelationship(Account.Type accountType, ...@@ -351,7 +352,7 @@ private void createContactMethodAccountAndRelationship(Account.Type accountType,
* instance. * instance.
*/ */
private AccountFileInstance createAccountInstance(Account.Type accountType, String accountUniqueID) throws TskCoreException { private AccountFileInstance createAccountInstance(Account.Type accountType, String accountUniqueID) throws TskCoreException {
return getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(accountType, accountUniqueID, getModuleName(), getAbstractFile()); return getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(accountType, accountUniqueID, getModuleName(), getContent());
} }
/** /**
...@@ -497,7 +498,7 @@ public BlackboardArtifact addMessage(String messageType, ...@@ -497,7 +498,7 @@ public BlackboardArtifact addMessage(String messageType,
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create TSK_MESSAGE artifact // create TSK_MESSAGE artifact
msgArtifact = getAbstractFile().newArtifact(ARTIFACT_TYPE.TSK_MESSAGE); msgArtifact = getContent().newArtifact(ARTIFACT_TYPE.TSK_MESSAGE);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_MESSAGE_TYPE, getModuleName(), messageType)); attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_MESSAGE_TYPE, getModuleName(), messageType));
...@@ -694,7 +695,7 @@ public BlackboardArtifact addCalllog(CommunicationDirection direction, ...@@ -694,7 +695,7 @@ public BlackboardArtifact addCalllog(CommunicationDirection direction,
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// Create TSK_CALLLOG artifact // Create TSK_CALLLOG artifact
callLogArtifact = getAbstractFile().newArtifact(ARTIFACT_TYPE.TSK_CALLLOG); callLogArtifact = getContent().newArtifact(ARTIFACT_TYPE.TSK_CALLLOG);
// Add basic attributes // Add basic attributes
addAttributeIfNotZero(ATTRIBUTE_TYPE.TSK_DATETIME_START, startDateTime, attributes); addAttributeIfNotZero(ATTRIBUTE_TYPE.TSK_DATETIME_START, startDateTime, attributes);
...@@ -877,7 +878,7 @@ private void addMessageReadStatusIfKnown(MessageReadStatus readStatus, Collectio ...@@ -877,7 +878,7 @@ private void addMessageReadStatusIfKnown(MessageReadStatus readStatus, Collectio
*/ */
private synchronized AccountFileInstance getSelfAccountInstance() throws TskCoreException { private synchronized AccountFileInstance getSelfAccountInstance() throws TskCoreException {
if (selfAccountInstance == null) { if (selfAccountInstance == null) {
selfAccountInstance = getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(selfAccountType, selfAccountId, this.getModuleName(), getAbstractFile()); selfAccountInstance = getSleuthkitCase().getCommunicationsManager().createAccountFileInstance(selfAccountType, selfAccountId, this.getModuleName(), getContent());
} }
return selfAccountInstance; return selfAccountInstance;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import org.sleuthkit.datamodel.Blackboard.BlackboardException; import org.sleuthkit.datamodel.Blackboard.BlackboardException;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
import org.sleuthkit.datamodel.Content;
import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.SleuthkitCase;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
...@@ -46,11 +47,11 @@ public final class WebBrowserArtifactsHelper extends ArtifactHelperBase { ...@@ -46,11 +47,11 @@ public final class WebBrowserArtifactsHelper extends ArtifactHelperBase {
* *
* @param caseDb Sleuthkit case db. * @param caseDb Sleuthkit case db.
* @param moduleName Name of module using the helper. * @param moduleName Name of module using the helper.
* @param srcFile Source file being processed by the module. * @param srcContent Source content being processed by the module.
* *
*/ */
public WebBrowserArtifactsHelper(SleuthkitCase caseDb, String moduleName, AbstractFile srcFile) { public WebBrowserArtifactsHelper(SleuthkitCase caseDb, String moduleName, Content srcContent) {
super(caseDb, moduleName, srcFile); super(caseDb, moduleName, srcContent);
} }
/** /**
...@@ -94,7 +95,7 @@ public BlackboardArtifact addWebBookmark(String url, String title, long creation ...@@ -94,7 +95,7 @@ public BlackboardArtifact addWebBookmark(String url, String title, long creation
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create artifact // create artifact
bookMarkArtifact = getAbstractFile().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK); bookMarkArtifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_BOOKMARK);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL, getModuleName(), url)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL, getModuleName(), url));
...@@ -164,7 +165,7 @@ public BlackboardArtifact addWebCookie(String url, ...@@ -164,7 +165,7 @@ public BlackboardArtifact addWebCookie(String url,
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create artifact // create artifact
cookieArtifact = getAbstractFile().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE); cookieArtifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_COOKIE);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL, getModuleName(), url)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL, getModuleName(), url));
...@@ -226,7 +227,7 @@ public BlackboardArtifact addWebDownload(String url, long startTime, String path ...@@ -226,7 +227,7 @@ public BlackboardArtifact addWebDownload(String url, long startTime, String path
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// reate artifact // reate artifact
webDownloadArtifact = getAbstractFile().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD); webDownloadArtifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_DOWNLOAD);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH, getModuleName(), path)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH, getModuleName(), path));
...@@ -297,7 +298,7 @@ public BlackboardArtifact addWebFormAddress(String personName, String email, ...@@ -297,7 +298,7 @@ public BlackboardArtifact addWebFormAddress(String personName, String email,
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create artifact // create artifact
webFormAddressArtifact = getAbstractFile().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_FORM_ADDRESS); webFormAddressArtifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_FORM_ADDRESS);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), personName)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), personName));
...@@ -365,7 +366,7 @@ public BlackboardArtifact addWebFormAutofill(String name, String value, ...@@ -365,7 +366,7 @@ public BlackboardArtifact addWebFormAutofill(String name, String value,
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create artifact // create artifact
webFormAutofillArtifact = getAbstractFile().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_FORM_AUTOFILL); webFormAutofillArtifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_FORM_AUTOFILL);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), name)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME, getModuleName(), name));
...@@ -431,7 +432,7 @@ public BlackboardArtifact addWebHistory(String url, long accessTime, ...@@ -431,7 +432,7 @@ public BlackboardArtifact addWebHistory(String url, long accessTime,
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
// create artifact // create artifact
webHistoryArtifact = getAbstractFile().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY); webHistoryArtifact = getContent().newArtifact(BlackboardArtifact.ARTIFACT_TYPE.TSK_WEB_HISTORY);
// construct attributes // construct attributes
attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL, getModuleName(), url)); attributes.add(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL, getModuleName(), url));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment