Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-m committed May 21, 2012
2 parents b2b2a67 + a5a4c7a commit b9968a7
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 33 deletions.
17 changes: 10 additions & 7 deletions framework/File/TskFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ void TskFile::setStatus(TskImgDB::FILE_STATUS status)
* Create a new artifact with the given type id
* @param artifactTypeID type id
* @returns the new artifact
* @throws error if the artifact type does not exist
*/
TskBlackboardArtifact TskFile::createArtifact(int artifactTypeID){
return TskServices::Instance().getBlackboard().createArtifact(m_id, artifactTypeID);
Expand All @@ -275,6 +276,7 @@ TskBlackboardArtifact TskFile::createArtifact(int artifactTypeID){
* Create a new artifact with the given type
* @param type artifact type
* @returns the new artifact
* @throws error if the artifact type does not exist
*/
TskBlackboardArtifact TskFile::createArtifact(TSK_ARTIFACT_TYPE type){
return TskServices::Instance().getBlackboard().createArtifact(m_id, type);
Expand All @@ -284,6 +286,7 @@ TskBlackboardArtifact TskFile::createArtifact(TSK_ARTIFACT_TYPE type){
* Create a new artifact with the given type name
* @param artifactTypeName artifact type name
* @returns the new artifact
* @throws error if the artifact type does not exist
*/
TskBlackboardArtifact TskFile::createArtifact(string artifactTypeName){
return TskServices::Instance().getBlackboard().createArtifact(m_id, artifactTypeName);
Expand All @@ -292,7 +295,7 @@ TskBlackboardArtifact TskFile::createArtifact(string artifactTypeName){
/**
* Get all artifacts associated with this file with the given type name
* @param artifactTypeName type name
* @returns all matching artifacts
* @returns all matching artifacts will return an empty vector if there are no matches
*/
vector<TskBlackboardArtifact> TskFile::getArtifacts(string artifactTypeName){
return TskServices::Instance().getBlackboard().getArtifacts(m_id, artifactTypeName);
Expand All @@ -301,7 +304,7 @@ vector<TskBlackboardArtifact> TskFile::getArtifacts(string artifactTypeName){
/**
* Get all artifacts associated with this file with the given type id
* @param artifactTypeID type id
* @returns all matching artifacts
* @returns all matching artifacts will return an empty vector if there are no matches
*/
vector<TskBlackboardArtifact> TskFile::getArtifacts(int artifactTypeID){
return TskServices::Instance().getBlackboard().getArtifacts(m_id, artifactTypeID);
Expand All @@ -310,7 +313,7 @@ vector<TskBlackboardArtifact> TskFile::getArtifacts(int artifactTypeID){
/**
* Get all artifacts associated with this file with the given type
* @param type artifact type
* @returns all matching artifacts
* @returns all matching artifacts will return an empty vector if there are no matches
*/
vector<TskBlackboardArtifact> TskFile::getArtifacts(TSK_ARTIFACT_TYPE type){
return TskServices::Instance().getBlackboard().getArtifacts(m_id, type);
Expand All @@ -329,7 +332,7 @@ vector<TskBlackboardArtifact> TskFile::getAllArtifacts(){
/**
* Get all artifacts associated with this file with the given type name
* @param attributeTypeName type name
* @returns all matching artifacts
* @returns all matching attributes will return an empty vector if there are no matches
*/
vector<TskBlackboardAttribute> TskFile::getAttributes(string attributeTypeName){
stringstream str;
Expand All @@ -340,7 +343,7 @@ vector<TskBlackboardAttribute> TskFile::getAttributes(string attributeTypeName){
/**
* Get all artifacts associated with this file with the given type id
* @param attributeTypeID type id
* @returns all matching artifacts
* @returns all matching attributes will return an empty vector if there are no matches
*/
vector<TskBlackboardAttribute> TskFile::getAttributes(int attributeTypeID){
stringstream str;
Expand All @@ -351,7 +354,7 @@ vector<TskBlackboardAttribute> TskFile::getAttributes(int attributeTypeID){
/**
* Get all artifacts associated with this file with the given type
* @param type artifact type
* @returns all matching artifacts
* @returns all matching attributes will return an empty vector if there are no matches
*/
vector<TskBlackboardAttribute> TskFile::getAttributes(TSK_ATTRIBUTE_TYPE type){
stringstream str;
Expand All @@ -371,7 +374,7 @@ vector<TskBlackboardAttribute> TskFile::getAllAttributes(){

/**
* Get the general info artifact for this file
* @returns all matching artifacts
* @returns the general info artifact or creates it if it has not already been made
*/
TskBlackboardArtifact TskFile::getGenInfo(){
TskBlackboard& blackboard = TskServices::Instance().getBlackboard();
Expand Down
49 changes: 32 additions & 17 deletions framework/Services/TskBlackboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,101 +152,107 @@ class TSK_FRAMEWORK_API TskBlackboard
/**
* Get the artifact with the given id
* @param artifactID id
* @returns the artifact
* @returns the artifact throws an error if no artifact matches that id.
*/
virtual TskBlackboardArtifact getBlackboardArtifact(const long artifactID) = 0;

/**
* Get all artifacts that match the given condition
* @param condition condition (implementation specific) to use for matching
* @returns vector of matching artifacts
* @returns vector of matching artifacts can return an empty vector if there are no matches
* @throws error if a bad condition string is supplied
*/
virtual vector<TskBlackboardArtifact> getMatchingArtifacts(const string& condition)const = 0;
/**
* Get all artifacts with the given type name and file id
* @param file_id associated file id
* @param artifactTypeName type name
* @returns vector of matching artifacts
* @returns vector of matching artifacts can return an empty vector if there are no matches
*/
virtual vector<TskBlackboardArtifact> getArtifacts(const uint64_t file_id, const string& artifactTypeName)const = 0;
/**
* Get all artifacts with the given type id and file id
* @param file_id associated file id
* @param artifactTypeID type id
* @returns vector of matching artifacts
* @returns vector of matching artifacts can return an empty vector if there are no matches
*/
virtual vector<TskBlackboardArtifact> getArtifacts(const uint64_t file_id, int artifactTypeID)const = 0;
/**
* Get all artifacts with the given type and file id
* @param file_id associated file id
* @param artifactType name
* @returns vector of matching artifacts
* @returns vector of matching artifacts can return an empty vector if there are no matches
*/
virtual vector<TskBlackboardArtifact> getArtifacts(const uint64_t file_id, TSK_ARTIFACT_TYPE artifactType)const = 0;
/**
* Get all artifacts with the given type
* @param artifactType type
* @returns vector of matching artifacts
* @returns vector of matching artifacts can return an empty vector if there are no matches
*/
virtual vector<TskBlackboardArtifact> getArtifacts(const TSK_ARTIFACT_TYPE artifactType)const = 0;

/**
* Get all attributes that match the given condition
* @param condition (implementation specific) to use for matching
* @returns vector of matching attributes
* @returns vector of matching attributes can return an empty vector if there are no matches
* @throws error if a bad condition string is supplied
*/
virtual vector<TskBlackboardAttribute> getMatchingAttributes(const string& condition)const = 0;

/**
* Get all attributes with the given type name and file id
* @param file_id associated file id
* @param attributeTypeName type name
* @returns vector of matching attributes
* @returns vector of matching attributes can return an empty vector if there are no matches
*/
virtual vector<TskBlackboardAttribute> getAttributes(const uint64_t file_id, const string& attributeTypeName)const = 0;

/**
* Get all attributes with the given type and file id
* @param file_id associated file id
* @param attributeTypeID Type of attribute to return
* @returns vector of matching attributes
* @returns vector of matching attributes can return an empty vector if there are no matches
*/
virtual vector<TskBlackboardAttribute> getAttributes(const uint64_t file_id, int attributeTypeID)const = 0;

/** Get all attributes with the given type and file id
* @param file_id associated file id
* @param attributeType name
* @returns vector of matching attributes
* @returns vector of matching attributes can return an empty vector if there are no matches
*/
virtual vector<TskBlackboardAttribute> getAttributes(const uint64_t file_id, TSK_ATTRIBUTE_TYPE attributeType)const = 0;
/**
* Get all attributes with the given type
* @param attributeType type
* @returns vector of matching attributes
* @returns vector of matching attributes can return an empty vector if there are no matches
*/
virtual vector<TskBlackboardAttribute> getAttributes(const TSK_ATTRIBUTE_TYPE attributeType)const = 0;


/**
* Create a new blackboard artifact with the given type id and file id
* @param artifactTypeID artifact type id
* @param file_id associated file id
* @param artifactTypeID artifact type id
* @param file_id associated file id
* @returns the new artifact
* @throws error if the artifact type does not exist
*/
virtual TskBlackboardArtifact createArtifact(const uint64_t file_id, const int artifactTypeID) = 0;

/**
* Create a new blackboard artifact with the given type and file id
* @param file_id associated file id
* @param artifactType artifact type
* @param artifactType artifact type
* @returns the new artifact
* @throws error if the artifact type does not exist
*/
virtual TskBlackboardArtifact createArtifact(const uint64_t file_id, const TSK_ARTIFACT_TYPE artifactType) = 0;

/**
* Add a new artifact type with the given name and file id
* @param file_id associated file id
* @param artifactTypeName System name of artifact type
* @param artifactTypeName System name of artifact type
* @returns the new artifact
* @throws error if the artifact type does not exist
*/
virtual TskBlackboardArtifact createArtifact(const uint64_t file_id, const string& artifactTypeName) = 0;

Expand All @@ -255,33 +261,37 @@ class TSK_FRAMEWORK_API TskBlackboard
* @param file_id file id for the file to add the attribute to
* @param attr and attribute populated with values. this attribute will have
* its artifact_id and obj_id set by this method.
* @throws error if no file with the given id exists or if a bad attribute is passed in.
*/
virtual void createGenInfoAttribute(const uint64_t file_id, TskBlackboardAttribute& attr) = 0;

/**
* Search the entire blackboard for all attribute types associated with any
* artifact of the given type.
* @param artifactTypeId artifact type to search
* @returns a vector of attribute ids
* @returns a vector of attribute ids can return an empty vector if no types are found
*/
virtual vector<int> findAttributeTypes(int artifactTypeId) = 0;

/**
* Convert attribute type id to display name
* @param attributeTypeID attribute type id
* @returns display name
* @throws error if no type exists for that id
*/
static string attrTypeIDToTypeDisplayName(const int attributeTypeID);
/**
* Convert attribute type name to id
* @param attributeTypeString attribute type name
* @returns attribute type id
* @throws error if no type exists with that name
*/
static int attrTypeNameToTypeID(const string& attributeTypeString);
/**
* Convert attribute type id to name
* @param attributeTypeID id
* @returns attribute type name
* @throws error if no type exists with that name
*/
static string attrTypeIDToTypeName(const int attributeTypeID);

Expand All @@ -290,25 +300,29 @@ class TSK_FRAMEWORK_API TskBlackboard
* @param attributeTypeName name for the new attribute type. should be unique
* @param displayName name to display for this type. need not be unique
* @returns the new attribute type id generated for the type.
* @throws error if a type with that name already exists
*/
static int addAttributeType(const string& attributeTypeName, const string& displayName);

/**
* Convert artifact type id to display name
* @param artifactTypeID artifact type id
* @returns display name
* @throws error if no type exists with that id
*/
static string artTypeIDToDisplayName(const int artifactTypeID);
/**
* Convert artifact type name to id
* @param artifactTypeString artifact type name
* @returns artifact type id
* @throws error if no type exists with that name
*/
static int artTypeNameToTypeID(const string& artifactTypeString);
/**
* Convert artifact type id to name
* @param artifactTypeID id
* @returns artifact type name
* @throws error if no type exists with that id
*/
static string artTypeIDToTypeName(const int artifactTypeID);

Expand All @@ -317,6 +331,7 @@ class TSK_FRAMEWORK_API TskBlackboard
* @param artifactTypeName name for the new attribute type. should be unique
* @param displayName name to display for this type. need not be unique
* @returns the new artifact type id generated for the type.
* @throws error if a type with that name already exists
*/
static int addArtifactType(const string& artifactTypeName, const string& displayName);

Expand All @@ -337,7 +352,7 @@ class TSK_FRAMEWORK_API TskBlackboard
virtual ~TskBlackboard() {};

private:

};


Expand Down
1 change: 1 addition & 0 deletions framework/Services/TskBlackboardArtifact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ string TskBlackboardArtifact::getDisplayName()const{
/**
* Add an attribute to this artifact
* @param attr attribute to be added
* @throws error if the given attribute has a bad type
*/
void TskBlackboardArtifact::addAttribute(TskBlackboardAttribute& attr){
attr.setArtifactID(m_artifactID);
Expand Down
20 changes: 16 additions & 4 deletions framework/Services/TskDBBlackboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ int TskDBBlackboard::addAttributeType(const string& attributeTypeName, const str
}

void TskDBBlackboard::addBlackboardAttribute(TskBlackboardAttribute& attr){
IMGDB().addBlackboardAttribute(attr);
if(attrTypeIDToTypeName(attr.getAttributeTypeID()).compare("") != 0)
IMGDB().addBlackboardAttribute(attr);
else
throw new TskException("No attribute type for the id of the given attribute");
}

string TskDBBlackboard::attrTypeIDToTypeDisplayName(const int attributeTypeID){
Expand Down Expand Up @@ -178,15 +181,24 @@ vector<TskBlackboardAttribute> TskDBBlackboard::getMatchingAttributes(const stri
}

TskBlackboardArtifact TskDBBlackboard::createArtifact(const uint64_t file_id, const int artifactTypeID){
return IMGDB().createBlackboardArtifact(file_id, artifactTypeID);
if(artTypeIDToTypeName(artifactTypeID).compare("") != 0)
return IMGDB().createBlackboardArtifact(file_id, artifactTypeID);
else
throw new TskException("No Artifact type exists with that ID");
}

TskBlackboardArtifact TskDBBlackboard::createArtifact(const uint64_t file_id, const TSK_ARTIFACT_TYPE artifactType){
return IMGDB().createBlackboardArtifact(file_id, artifactType);
if(artTypeIDToTypeName(artifactType).compare("") != 0)
return IMGDB().createBlackboardArtifact(file_id, artifactType);
else
throw new TskException("No Artifact type exists with that name");
}

TskBlackboardArtifact TskDBBlackboard::createArtifact(const uint64_t file_id, const string& artifactTypeName){
return IMGDB().createBlackboardArtifact(file_id, attrTypeNameToTypeID(artifactTypeName));
if(artTypeNameToTypeID(artifactTypeName))
return IMGDB().createBlackboardArtifact(file_id, attrTypeNameToTypeID(artifactTypeName));
else
throw new TskException("Artifact type does not exist. Bad enum value.");
}

void TskDBBlackboard::createGenInfoAttribute(const uint64_t file_id, TskBlackboardAttribute& attr){
Expand Down
1 change: 0 additions & 1 deletion framework/Services/TskDBBlackboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class TSK_FRAMEWORK_API TskDBBlackboard : public TskBlackboard

TskImgDB * m_pImgDB;


private:

};
Expand Down
8 changes: 4 additions & 4 deletions framework/ValidatePipeline/ValidatePipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ static char *progname;

static void usage()
{
fprintf(stderr, "Usage: %s system_configfile pipeline_configfile \n", progname);
fprintf(stderr, "\tsystem_configfile: Framework config file that identifies where module directory, etc. is found.\n");
fprintf(stderr, "\tpipeline_configfile: Pipeline config file to validate.\n");
fprintf(stderr, "Usage: %s framework_config_file pipeline_config_file \n", progname);
fprintf(stderr, "\tframework_config_file: Framework config file that identifies where module directory, etc. is found.\n");
fprintf(stderr, "\tpipeline_config_file: Pipeline config file to validate.\n");
}

ValidatePipeline::ValidatePipeline()
Expand All @@ -71,7 +71,7 @@ bool ValidatePipeline::isValid(const char *a_configPath) const
bool result = false;
std::ifstream in(a_configPath);
if (!in) {
fprintf(stdout, "Error opening config file: %s\n", a_configPath);
fprintf(stdout, "Error opening pipeline config file: %s\n", a_configPath);
} else {
try {
Poco::XML::InputSource src(in);
Expand Down
Loading

0 comments on commit b9968a7

Please sign in to comment.