19 package org.sleuthkit.datamodel;
21 import com.google.common.annotations.Beta;
22 import com.google.common.collect.ImmutableSet;
23 import java.sql.PreparedStatement;
24 import java.sql.ResultSet;
25 import java.sql.SQLException;
26 import java.sql.Statement;
27 import java.text.MessageFormat;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Collection;
31 import java.util.Collections;
32 import java.util.HashMap;
33 import java.util.HashSet;
34 import java.util.List;
36 import java.util.Objects;
37 import java.util.Optional;
39 import java.util.concurrent.ConcurrentHashMap;
40 import java.util.logging.Level;
41 import java.util.logging.Logger;
42 import java.util.stream.Collectors;
55 private static final Logger LOGGER = Logger.getLogger(
Blackboard.class.getName());
69 static final int MIN_USER_DEFINED_TYPE_ID = 10000;
80 this.caseDb = Objects.requireNonNull(casedb,
"Cannot create Blackboard for null SleuthkitCase");
100 postArtifacts(Collections.singleton(artifact), moduleName, null);
139 postArtifacts(Collections.singleton(artifact), moduleName, ingestJobId);
162 throw new BlackboardException(String.format(
"Failed to add events to timeline for artifact '%s'", artifact), ex);
200 if (category == null) {
201 throw new BlackboardException(
"Category provided must be non-null");
204 if (typeNameToArtifactTypeMap.containsKey(typeName)) {
205 return typeNameToArtifactTypeMap.get(typeName);
214 CaseDbConnection connection = trans.getConnection();
215 s = connection.createStatement();
216 rs = connection.executeQuery(s,
"SELECT artifact_type_id FROM blackboard_artifact_types WHERE type_name = '" + typeName +
"'");
219 rs = connection.executeQuery(s,
"SELECT MAX(artifact_type_id) AS highest_id FROM blackboard_artifact_types");
222 maxID = rs.getInt(
"highest_id");
223 if (maxID < MIN_USER_DEFINED_TYPE_ID) {
224 maxID = MIN_USER_DEFINED_TYPE_ID;
229 connection.executeUpdate(s,
"INSERT INTO blackboard_artifact_types (artifact_type_id, type_name, display_name, category_type) VALUES ('" + maxID +
"', '" + typeName +
"', '" + displayName +
"', " + category.getID() +
" )");
231 this.typeIdToArtifactTypeMap.put(type.getTypeID(), type);
232 this.typeNameToArtifactTypeMap.put(type.getTypeName(), type);
242 throw new BlackboardException(
"Failed to get or add artifact type: " + typeName, ex);
252 LOGGER.log(Level.SEVERE,
"Error rolling back transaction", ex2);
254 throw new BlackboardException(
"Error adding artifact type: " + typeName, ex);
262 throw new BlackboardException(
"Error rolling back transaction", ex);
279 if (this.typeNameToAttributeTypeMap.containsKey(attrTypeName)) {
280 return this.typeNameToAttributeTypeMap.get(attrTypeName);
282 CaseDbConnection connection = null;
287 connection = caseDb.getConnection();
288 s = connection.createStatement();
289 rs = connection.executeQuery(s,
"SELECT attribute_type_id, type_name, display_name, value_type FROM blackboard_attribute_types WHERE type_name = '" + attrTypeName +
"'");
294 this.typeIdToAttributeTypeMap.put(type.getTypeID(), type);
295 this.typeNameToAttributeTypeMap.put(attrTypeName, type);
298 }
catch (SQLException ex) {
303 closeConnection(connection);
319 if (this.typeIdToAttributeTypeMap.containsKey(typeID)) {
320 return this.typeIdToAttributeTypeMap.get(typeID);
322 CaseDbConnection connection = null;
327 connection = caseDb.getConnection();
328 s = connection.createStatement();
329 rs = connection.executeQuery(s,
"SELECT attribute_type_id, type_name, display_name, value_type FROM blackboard_attribute_types WHERE attribute_type_id = " + typeID +
"");
330 BlackboardAttribute.Type type = null;
332 type =
new BlackboardAttribute.Type(rs.getInt(
"attribute_type_id"), rs.getString(
"type_name"),
333 rs.getString(
"display_name"), BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.fromType(rs.getLong(
"value_type")));
334 this.typeIdToAttributeTypeMap.put(typeID, type);
335 this.typeNameToAttributeTypeMap.put(type.getTypeName(), type);
338 }
catch (SQLException ex) {
339 throw new TskCoreException(
"Error getting attribute type id", ex);
343 closeConnection(connection);
359 if (this.typeNameToArtifactTypeMap.containsKey(artTypeName)) {
360 return this.typeNameToArtifactTypeMap.get(artTypeName);
362 CaseDbConnection connection = null;
367 connection = caseDb.getConnection();
368 s = connection.createStatement();
369 rs = connection.executeQuery(s,
"SELECT artifact_type_id, type_name, display_name, category_type FROM blackboard_artifact_types WHERE type_name = '" + artTypeName +
"'");
373 rs.getString(
"type_name"), rs.getString(
"display_name"),
375 this.typeIdToArtifactTypeMap.put(type.getTypeID(), type);
376 this.typeNameToArtifactTypeMap.put(artTypeName, type);
379 }
catch (SQLException ex) {
380 throw new TskCoreException(
"Error getting artifact type from the database", ex);
384 closeConnection(connection);
401 if (this.typeIdToArtifactTypeMap.containsKey(artTypeId)) {
402 return typeIdToArtifactTypeMap.get(artTypeId);
404 CaseDbConnection connection = null;
409 connection = caseDb.getConnection();
410 s = connection.createStatement();
411 rs = connection.executeQuery(s,
"SELECT artifact_type_id, type_name, display_name, category_type FROM blackboard_artifact_types WHERE artifact_type_id = " + artTypeId +
"");
415 rs.getString(
"type_name"), rs.getString(
"display_name"),
417 this.typeIdToArtifactTypeMap.put(artTypeId, type);
418 this.typeNameToArtifactTypeMap.put(type.getTypeName(), type);
421 throw new TskCoreException(
"No artifact type found matching id: " + artTypeId);
423 }
catch (SQLException ex) {
424 throw new TskCoreException(
"Error getting artifact type from the database", ex);
428 closeConnection(connection);
443 CaseDbConnection connection = null;
444 Statement statement = null;
450 rowId =
"attrs.CTID";
453 rowId =
"attrs.ROWID";
461 connection = caseDb.getConnection();
462 statement = connection.createStatement();
463 rs = connection.executeQuery(statement,
"SELECT attrs.artifact_id AS artifact_id, "
464 +
"attrs.source AS source, attrs.context AS context, attrs.attribute_type_id AS attribute_type_id, "
465 +
"attrs.value_type AS value_type, attrs.value_byte AS value_byte, "
466 +
"attrs.value_text AS value_text, attrs.value_int32 AS value_int32, "
467 +
"attrs.value_int64 AS value_int64, attrs.value_double AS value_double, "
468 +
"types.type_name AS type_name, types.display_name AS display_name "
469 +
"FROM blackboard_attributes AS attrs, blackboard_attribute_types AS types WHERE attrs.artifact_id = " + artifact.getArtifactID()
470 +
" AND attrs.attribute_type_id = types.attribute_type_id "
471 +
" ORDER BY " + rowId);
472 ArrayList<BlackboardAttribute> attributes =
new ArrayList<>();
475 attr.setParentDataSourceID(artifact.getDataSourceObjectID());
476 attributes.add(attr);
479 }
catch (SQLException ex) {
480 throw new TskCoreException(
"Error getting attributes for artifact, artifact id = " + artifact.getArtifactID(), ex);
483 closeStatement(statement);
484 closeConnection(connection);
500 public <T extends BlackboardArtifact>
void loadBlackboardAttributes(List<T> arts)
throws TskCoreException {
502 if (arts.isEmpty()) {
507 Map<Long, BlackboardArtifact> artifactMap =
new HashMap<>();
508 for (BlackboardArtifact art : arts) {
509 artifactMap.put(art.getArtifactID(), art);
513 Map<Long, List<BlackboardAttribute>> attributeMap =
new HashMap<>();
516 String idString = arts.stream().map(p -> Long.toString(p.getArtifactID())).collect(Collectors.joining(
", "));
521 rowId =
"attrs.CTID";
524 rowId =
"attrs.ROWID";
527 throw new TskCoreException(
"Unknown database type: " + caseDb.
getDatabaseType());
531 CaseDbConnection connection = null;
532 Statement statement = null;
536 connection = caseDb.getConnection();
537 statement = connection.createStatement();
538 rs = connection.executeQuery(statement,
"SELECT attrs.artifact_id AS artifact_id, "
539 +
"attrs.source AS source, attrs.context AS context, attrs.attribute_type_id AS attribute_type_id, "
540 +
"attrs.value_type AS value_type, attrs.value_byte AS value_byte, "
541 +
"attrs.value_text AS value_text, attrs.value_int32 AS value_int32, "
542 +
"attrs.value_int64 AS value_int64, attrs.value_double AS value_double, "
543 +
"types.type_name AS type_name, types.display_name AS display_name "
544 +
"FROM blackboard_attributes AS attrs, blackboard_attribute_types AS types WHERE attrs.artifact_id IN (" + idString +
") "
545 +
" AND attrs.attribute_type_id = types.attribute_type_id"
546 +
" ORDER BY " + rowId);
548 final BlackboardAttribute attr = createAttributeFromResultSet(rs);
549 attr.setParentDataSourceID(artifactMap.get(attr.getArtifactID()).getDataSourceObjectID());
552 if (!attributeMap.containsKey(attr.getArtifactID())) {
553 attributeMap.put(attr.getArtifactID(),
new ArrayList<>());
555 attributeMap.get(attr.getArtifactID()).add(attr);
559 for (Long artifactID : attributeMap.keySet()) {
560 artifactMap.get(artifactID).setAttributes(attributeMap.get(artifactID));
563 }
catch (SQLException ex) {
564 throw new TskCoreException(
"Error loading attributes", ex);
567 closeStatement(statement);
568 closeConnection(connection);
581 private BlackboardAttribute createAttributeFromResultSet(ResultSet rs)
throws SQLException {
582 int attributeTypeId = rs.getInt(
"attribute_type_id");
583 String attributeTypeName = rs.getString(
"type_name");
584 BlackboardAttribute.Type attributeType;
585 if (this.typeIdToAttributeTypeMap.containsKey(attributeTypeId)) {
586 attributeType = this.typeIdToAttributeTypeMap.get(attributeTypeId);
588 attributeType =
new BlackboardAttribute.Type(attributeTypeId, attributeTypeName,
589 rs.getString(
"display_name"),
590 BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.fromType(rs.getInt(
"value_type")));
591 this.typeIdToAttributeTypeMap.put(attributeTypeId, attributeType);
592 this.typeNameToAttributeTypeMap.put(attributeTypeName, attributeType);
595 return new BlackboardAttribute(
596 rs.getLong(
"artifact_id"),
598 rs.getString(
"source"),
599 rs.getString(
"context"),
600 rs.getInt(
"value_int32"),
601 rs.getLong(
"value_int64"),
602 rs.getDouble(
"value_double"),
603 rs.getString(
"value_text"),
604 rs.getBytes(
"value_byte"), caseDb
617 ArrayList<Attribute> getFileAttributes(
final AbstractFile file)
throws TskCoreException {
618 CaseDbConnection connection = null;
619 Statement statement = null;
623 connection = caseDb.getConnection();
624 statement = connection.createStatement();
625 rs = connection.executeQuery(statement,
"SELECT attrs.id as id, attrs.obj_id AS obj_id, "
626 +
"attrs.attribute_type_id AS attribute_type_id, "
627 +
"attrs.value_type AS value_type, attrs.value_byte AS value_byte, "
628 +
"attrs.value_text AS value_text, attrs.value_int32 AS value_int32, "
629 +
"attrs.value_int64 AS value_int64, attrs.value_double AS value_double, "
630 +
"types.type_name AS type_name, types.display_name AS display_name "
631 +
"FROM tsk_file_attributes AS attrs "
632 +
" INNER JOIN blackboard_attribute_types AS types "
633 +
" ON attrs.attribute_type_id = types.attribute_type_id "
634 +
" WHERE attrs.obj_id = " + file.getId());
636 ArrayList<Attribute> attributes =
new ArrayList<Attribute>();
638 int attributeTypeId = rs.getInt(
"attribute_type_id");
639 String attributeTypeName = rs.getString(
"type_name");
640 BlackboardAttribute.Type attributeType;
641 if (this.typeIdToAttributeTypeMap.containsKey(attributeTypeId)) {
642 attributeType = this.typeIdToAttributeTypeMap.get(attributeTypeId);
644 attributeType =
new BlackboardAttribute.Type(attributeTypeId, attributeTypeName,
645 rs.getString(
"display_name"),
646 BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.fromType(rs.getInt(
"value_type")));
647 this.typeIdToAttributeTypeMap.put(attributeTypeId, attributeType);
648 this.typeNameToAttributeTypeMap.put(attributeTypeName, attributeType);
651 final Attribute attr =
new Attribute(
653 rs.getLong(
"obj_id"),
655 rs.getInt(
"value_int32"),
656 rs.getLong(
"value_int64"),
657 rs.getDouble(
"value_double"),
658 rs.getString(
"value_text"),
659 rs.getBytes(
"value_byte"), caseDb
661 attributes.add(attr);
664 }
catch (SQLException ex) {
665 throw new TskCoreException(
"Error getting attributes for file, file id = " + file.getId(), ex);
668 closeStatement(statement);
669 closeConnection(connection);
683 void initBlackboardArtifactTypes(CaseDbConnection connection)
throws SQLException {
685 try (Statement statement = connection.createStatement()) {
692 ResultSet resultSet = connection.executeQuery(statement,
"SELECT artifact_type_id, type_name, display_name, category_type FROM blackboard_artifact_types");
693 while (resultSet.next()) {
694 BlackboardArtifact.Type type =
new BlackboardArtifact.Type(resultSet.getInt(
"artifact_type_id"),
695 resultSet.getString(
"type_name"), resultSet.getString(
"display_name"),
696 BlackboardArtifact.Category.fromID(resultSet.getInt(
"category_type")));
697 typeIdToArtifactTypeMap.put(type.getTypeID(), type);
698 typeNameToArtifactTypeMap.put(type.getTypeName(), type);
712 for (BlackboardArtifact.ARTIFACT_TYPE type : BlackboardArtifact.ARTIFACT_TYPE.values()) {
713 if (typeIdToArtifactTypeMap.containsKey(type.getTypeID())) {
717 statement.execute(
"INSERT INTO blackboard_artifact_types (artifact_type_id, type_name, display_name, category_type) VALUES (" + type.getTypeID() +
" , '" + type.getLabel() +
"', '" + type.getDisplayName() +
"' , " + type.getCategory().getID() +
") ON CONFLICT DO NOTHING");
719 statement.execute(
"INSERT OR IGNORE INTO blackboard_artifact_types (artifact_type_id, type_name, display_name, category_type) VALUES (" + type.getTypeID() +
" , '" + type.getLabel() +
"', '" + type.getDisplayName() +
"' , " + type.getCategory().getID() +
")");
721 typeIdToArtifactTypeMap.put(type.getTypeID(),
new BlackboardArtifact.Type(type));
722 typeNameToArtifactTypeMap.put(type.getLabel(),
new BlackboardArtifact.Type(type));
725 int newPrimaryKeyIndex = Collections.max(Arrays.asList(BlackboardArtifact.ARTIFACT_TYPE.values())).getTypeID() + 1;
726 statement.execute(
"ALTER SEQUENCE blackboard_artifact_types_artifact_type_id_seq RESTART WITH " + newPrimaryKeyIndex);
742 void initBlackboardAttributeTypes(CaseDbConnection connection)
throws SQLException {
744 try (Statement statement = connection.createStatement()) {
751 ResultSet resultSet = connection.executeQuery(statement,
"SELECT attribute_type_id, type_name, display_name, value_type FROM blackboard_attribute_types");
752 while (resultSet.next()) {
753 BlackboardAttribute.Type type =
new BlackboardAttribute.Type(resultSet.getInt(
"attribute_type_id"),
754 resultSet.getString(
"type_name"), resultSet.getString(
"display_name"),
755 BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.fromType(resultSet.getLong(
"value_type")));
756 typeIdToAttributeTypeMap.put(type.getTypeID(), type);
757 typeNameToAttributeTypeMap.put(type.getTypeName(), type);
771 for (BlackboardAttribute.ATTRIBUTE_TYPE type : BlackboardAttribute.ATTRIBUTE_TYPE.values()) {
772 if (typeIdToAttributeTypeMap.containsKey(type.getTypeID())) {
776 statement.execute(
"INSERT INTO blackboard_attribute_types (attribute_type_id, type_name, display_name, value_type) VALUES (" + type.getTypeID() +
", '" + type.getLabel() +
"', '" + type.getDisplayName() +
"', '" + type.getValueType().getType() +
"') ON CONFLICT DO NOTHING");
778 statement.execute(
"INSERT OR IGNORE INTO blackboard_attribute_types (attribute_type_id, type_name, display_name, value_type) VALUES (" + type.getTypeID() +
", '" + type.getLabel() +
"', '" + type.getDisplayName() +
"', '" + type.getValueType().getType() +
"')");
780 typeIdToAttributeTypeMap.put(type.getTypeID(),
new BlackboardAttribute.Type(type));
781 typeNameToAttributeTypeMap.put(type.getLabel(),
new BlackboardAttribute.Type(type));
784 int newPrimaryKeyIndex = Collections.max(Arrays.asList(BlackboardAttribute.ATTRIBUTE_TYPE.values())).getTypeID() + 1;
785 statement.execute(
"ALTER SEQUENCE blackboard_attribute_types_attribute_type_id_seq RESTART WITH " + newPrimaryKeyIndex);
815 String conclusion, String configuration, String justification, Collection<BlackboardAttribute> attributesList)
819 throw new BlackboardException(String.format(
"Artifact type (name = %s) is not of Analysis Result category. ", artifactType.getTypeName()));
825 conclusion, configuration, justification, attributesList, transaction);
827 return analysisResult;
832 LOGGER.log(Level.SEVERE,
"Failed to rollback transaction after exception. "
833 +
"Error invoking newAnalysisResult with dataSourceObjId: "
834 + (dataSourceObjId == null ?
"<null>" : dataSourceObjId)
835 +
", sourceObjId: " + objId, ex2);
864 String conclusion, String configuration, String justification, Collection<BlackboardAttribute> attributesList,
CaseDbTransaction transaction)
throws BlackboardException {
867 throw new BlackboardException(String.format(
"Artifact type (name = %s) is not of Analysis Result category. ", artifactType.getTypeName()));
872 AnalysisResult analysisResult = caseDb.newAnalysisResult(artifactType, objId, dataSourceObjId, score, conclusion, configuration, justification, transaction.getConnection());
875 if (attributesList != null && !attributesList.isEmpty()) {
880 Score aggregateScore = caseDb.
getScoringManager().updateAggregateScoreAfterAddition(objId, dataSourceObjId, analysisResult.
getScore(), transaction);
886 throw new BlackboardException(
"Failed to add analysis result.", ex);
914 if (transaction != null) {
935 List<AnalysisResult> analysisResults =
getAnalysisResultsWhere(
" artifacts.artifact_obj_id = " + artifactObjId, transaction.getConnection());
937 if (analysisResults.isEmpty()) {
938 throw new TskCoreException(String.format(
"Analysis Result not found for artifact obj id %d", artifactObjId));
960 CaseDbConnection connection = transaction.getConnection();
963 String deleteSQL =
"DELETE FROM blackboard_artifacts WHERE artifact_obj_id = ?";
965 PreparedStatement deleteStatement = connection.getPreparedStatement(deleteSQL, Statement.RETURN_GENERATED_KEYS);
966 deleteStatement.clearParameters();
967 deleteStatement.setLong(1, analysisResult.getId());
969 deleteStatement.executeUpdate();
972 transaction.registerDeletedAnalysisResult(analysisResult.getObjectID());
974 return caseDb.
getScoringManager().updateAggregateScoreAfterDeletion(analysisResult.getObjectID(), analysisResult.getDataSourceObjectID(), transaction);
976 }
catch (SQLException ex) {
977 throw new TskCoreException(String.format(
"Error deleting analysis result with artifact obj id %d", analysisResult.getId()), ex);
981 private final static String ANALYSIS_RESULT_QUERY_STRING_GENERIC =
"SELECT DISTINCT artifacts.artifact_id AS artifact_id, "
982 +
" artifacts.obj_id AS obj_id, artifacts.artifact_obj_id AS artifact_obj_id, artifacts.data_source_obj_id AS data_source_obj_id, artifacts.artifact_type_id AS artifact_type_id, "
983 +
" types.type_name AS type_name, types.display_name AS display_name, types.category_type as category_type,"
984 +
" artifacts.review_status_id AS review_status_id, "
985 +
" results.conclusion AS conclusion, results.significance AS significance, results.priority AS priority, "
986 +
" results.configuration AS configuration, results.justification AS justification "
987 +
" FROM blackboard_artifacts AS artifacts "
988 +
" JOIN blackboard_artifact_types AS types "
989 +
" ON artifacts.artifact_type_id = types.artifact_type_id"
990 +
" LEFT JOIN tsk_analysis_results AS results "
991 +
" ON artifacts.artifact_obj_id = results.artifact_obj_id ";
993 private final static String ANALYSIS_RESULT_QUERY_STRING_WITH_ATTRIBUTES
994 = ANALYSIS_RESULT_QUERY_STRING_GENERIC
995 +
" JOIN blackboard_attributes AS attributes "
996 +
" ON artifacts.artifact_id = attributes.artifact_id "
997 +
" WHERE types.category_type = " + BlackboardArtifact.Category.ANALYSIS_RESULT.getID();
999 private final static String ANALYSIS_RESULT_QUERY_STRING_WHERE
1000 = ANALYSIS_RESULT_QUERY_STRING_GENERIC
1001 +
" WHERE artifacts.review_status_id != " + BlackboardArtifact.ReviewStatus.REJECTED.getID()
1002 +
" AND types.category_type = " + BlackboardArtifact.Category.ANALYSIS_RESULT.getID();
1030 return getAnalysisResultsWhere(
" artifacts.artifact_type_id = " + artifactTypeId +
" AND artifacts.data_source_obj_id = " + dataSourceObjId);
1048 try (CaseDbConnection connection = caseDb.getConnection()) {
1049 String whereClause =
" artifacts.data_source_obj_id = " + dataSourceObjId;
1050 if (artifactTypeID != null) {
1051 whereClause +=
" AND artifacts.artifact_type_id = " + artifactTypeID;
1083 List<DataArtifact> getDataArtifactsBySource(
long sourceObjId)
throws TskCoreException {
1085 try (CaseDbConnection connection = caseDb.getConnection()) {
1132 String queryString =
"SELECT COUNT(*) AS count "
1133 +
" FROM blackboard_artifacts AS arts "
1134 +
" JOIN blackboard_artifact_types AS types "
1135 +
" ON arts.artifact_type_id = types.artifact_type_id"
1136 +
" WHERE types.category_type = " + category.getID()
1137 +
" AND arts.obj_id = " + sourceObjId;
1141 Statement statement = connection.createStatement();
1142 ResultSet resultSet = connection.executeQuery(statement, queryString);) {
1143 if (resultSet.next()) {
1144 return resultSet.getLong(
"count") > 0;
1147 }
catch (SQLException ex) {
1148 throw new TskCoreException(
"Error getting artifact types is use for data source." + ex.getMessage(), ex);
1166 List<AnalysisResult>
getAnalysisResults(
long sourceObjId, CaseDbConnection connection)
throws TskCoreException {
1185 throw new TskCoreException(String.format(
"Artifact type id %d is not in analysis result catgeory.", artifactTypeId));
1188 String whereClause =
" types.artifact_type_id = " + artifactTypeId
1189 +
" AND artifacts.obj_id = " + sourceObjId;
1206 try (CaseDbConnection connection = caseDb.getConnection()) {
1227 final String queryString = ANALYSIS_RESULT_QUERY_STRING_WHERE
1228 +
" AND " + whereClause;
1230 try (Statement statement = connection.createStatement();
1231 ResultSet resultSet = connection.executeQuery(statement, queryString);) {
1233 List<AnalysisResult> analysisResults = resultSetToAnalysisResults(resultSet);
1234 return analysisResults;
1235 }
catch (SQLException ex) {
1236 throw new TskCoreException(String.format(
"Error getting analysis results for WHERE clause = '%s'", whereClause), ex);
1251 String whereClause =
" artifacts.artifact_obj_id = " + artifactObjId;
1254 if (results.isEmpty()) {
1255 throw new TskCoreException(String.format(
"Error getting analysis result with id = '%d'", artifactObjId));
1257 if (results.size() > 1) {
1258 throw new TskCoreException(String.format(
"Multiple analysis results found with id = '%d'", artifactObjId));
1261 return results.get(0);
1279 private List<AnalysisResult> resultSetToAnalysisResults(ResultSet resultSet)
throws SQLException,
TskCoreException {
1280 ArrayList<AnalysisResult> analysisResults =
new ArrayList<>();
1282 while (resultSet.next()) {
1283 analysisResults.add(
new AnalysisResult(caseDb, resultSet.getLong(
"artifact_id"), resultSet.getLong(
"obj_id"),
1284 resultSet.getLong(
"artifact_obj_id"),
1285 resultSet.getObject(
"data_source_obj_id") != null ? resultSet.getLong(
"data_source_obj_id") : null,
1286 resultSet.getInt(
"artifact_type_id"), resultSet.getString(
"type_name"), resultSet.getString(
"display_name"),
1289 resultSet.getString(
"conclusion"), resultSet.getString(
"configuration"), resultSet.getString(
"justification")));
1292 return analysisResults;
1295 private final static String DATA_ARTIFACT_QUERY_STRING_GENERIC =
"SELECT DISTINCT artifacts.artifact_id AS artifact_id, "
1296 +
"artifacts.obj_id AS obj_id, artifacts.artifact_obj_id AS artifact_obj_id, artifacts.data_source_obj_id AS data_source_obj_id, artifacts.artifact_type_id AS artifact_type_id, "
1297 +
" types.type_name AS type_name, types.display_name AS display_name, types.category_type as category_type,"
1298 +
" artifacts.review_status_id AS review_status_id, "
1299 +
" data_artifacts.os_account_obj_id as os_account_obj_id "
1300 +
" FROM blackboard_artifacts AS artifacts "
1301 +
" JOIN blackboard_artifact_types AS types "
1302 +
" ON artifacts.artifact_type_id = types.artifact_type_id"
1303 +
" LEFT JOIN tsk_data_artifacts AS data_artifacts "
1304 +
" ON artifacts.artifact_obj_id = data_artifacts.artifact_obj_id ";
1306 private final static String DATA_ARTIFACT_QUERY_STRING_WITH_ATTRIBUTES
1307 = DATA_ARTIFACT_QUERY_STRING_GENERIC
1308 +
" JOIN blackboard_attributes AS attributes "
1309 +
" ON artifacts.artifact_id = attributes.artifact_id "
1310 +
" WHERE types.category_type = " + BlackboardArtifact.Category.DATA_ARTIFACT.getID();
1312 private final static String DATA_ARTIFACT_QUERY_STRING_WHERE
1313 = DATA_ARTIFACT_QUERY_STRING_GENERIC
1314 +
" WHERE artifacts.review_status_id != " + BlackboardArtifact.ReviewStatus.REJECTED.getID()
1315 +
" AND types.category_type = " + BlackboardArtifact.Category.DATA_ARTIFACT.getID();
1331 try (CaseDbConnection connection = caseDb.getConnection()) {
1332 String whereClause =
" artifacts.data_source_obj_id = " + dataSourceObjId;
1333 if (artifactTypeID != null) {
1334 whereClause +=
" AND artifacts.artifact_type_id = " + artifactTypeID;
1358 throw new TskCoreException(String.format(
"Artifact type id %d is not in data artifact catgeory.", artifactTypeID));
1362 try (CaseDbConnection connection = caseDb.getConnection()) {
1363 String whereClause =
"artifacts.data_source_obj_id = " + dataSourceObjId
1364 +
" AND artifacts.artifact_type_id = " + artifactTypeID;
1386 throw new TskCoreException(String.format(
"Artifact type id %d is not in data artifact catgeory.", artifactTypeID));
1390 try (CaseDbConnection connection = caseDb.getConnection()) {
1391 String whereClause =
" artifacts.artifact_type_id = " + artifactTypeID;
1411 try (CaseDbConnection connection = caseDb.getConnection()) {
1412 String whereClause =
" artifacts.artifact_obj_id = " + artifactObjId;
1415 if (artifacts.isEmpty()) {
1416 throw new TskCoreException(String.format(
"Error getting data artifact with id = '%d'", artifactObjId));
1418 if (artifacts.size() > 1) {
1419 throw new TskCoreException(String.format(
"Multiple data artifacts found with id = '%d'", artifactObjId));
1422 return artifacts.get(0);
1440 try (CaseDbConnection connection = caseDb.getConnection()) {
1461 final String queryString = DATA_ARTIFACT_QUERY_STRING_WHERE
1462 +
" AND " + whereClause +
" ";
1464 try (Statement statement = connection.createStatement();
1465 ResultSet resultSet = connection.executeQuery(statement, queryString);) {
1467 List<DataArtifact> dataArtifacts = resultSetToDataArtifacts(resultSet);
1468 return dataArtifacts;
1469 }
catch (SQLException ex) {
1470 throw new TskCoreException(String.format(
"Error getting data artifacts with queryString = %s", queryString), ex);
1489 private List<DataArtifact> resultSetToDataArtifacts(ResultSet resultSet)
throws SQLException, TskCoreException {
1490 ArrayList<DataArtifact> dataArtifacts =
new ArrayList<>();
1492 while (resultSet.next()) {
1494 Long osAccountObjId = resultSet.getLong(
"os_account_obj_id");
1495 if (resultSet.wasNull()) {
1496 osAccountObjId = null;
1499 dataArtifacts.add(
new DataArtifact(caseDb, resultSet.getLong(
"artifact_id"), resultSet.getLong(
"obj_id"),
1500 resultSet.getLong(
"artifact_obj_id"),
1501 resultSet.getObject(
"data_source_obj_id") != null ? resultSet.getLong(
"data_source_obj_id") : null,
1502 resultSet.getInt(
"artifact_type_id"), resultSet.getString(
"type_name"), resultSet.getString(
"display_name"),
1503 BlackboardArtifact.ReviewStatus.withID(resultSet.getInt(
"review_status_id")), osAccountObjId,
false));
1506 return dataArtifacts;
1528 if (typeNameToAttributeTypeMap.containsKey(typeName)) {
1529 return typeNameToAttributeTypeMap.get(typeName);
1535 String matchingAttrQuery =
"SELECT attribute_type_id, type_name, display_name, value_type "
1536 +
"FROM blackboard_attribute_types WHERE type_name = ?";
1538 PreparedStatement query = trans.getConnection().getPreparedStatement(matchingAttrQuery, Statement.RETURN_GENERATED_KEYS);
1539 query.clearParameters();
1540 query.setString(1, typeName);
1541 try (ResultSet rs = query.executeQuery()) {
1547 rs.getInt(
"attribute_type_id"),
1548 rs.getString(
"type_name"),
1549 rs.getString(
"display_name"),
1553 this.typeIdToAttributeTypeMap.put(foundType.getTypeID(), foundType);
1554 this.typeNameToAttributeTypeMap.put(foundType.getTypeName(), foundType);
1561 String insertStatement =
"INSERT INTO blackboard_attribute_types (attribute_type_id, type_name, display_name, value_type) VALUES (\n"
1563 +
"(SELECT MAX(q.attribute_type_id) FROM (SELECT attribute_type_id FROM blackboard_attribute_types UNION SELECT " + (MIN_USER_DEFINED_TYPE_ID - 1) +
") q) + 1,\n"
1567 PreparedStatement insertPreparedStatement = trans.getConnection().getPreparedStatement(insertStatement, Statement.RETURN_GENERATED_KEYS);
1568 insertPreparedStatement.clearParameters();
1569 insertPreparedStatement.setString(1, typeName);
1570 insertPreparedStatement.setString(2, displayName);
1571 insertPreparedStatement.setLong(3, valueType.getType());
1573 int numUpdated = insertPreparedStatement.executeUpdate();
1576 Integer attrId = null;
1578 if (numUpdated > 0) {
1579 try (ResultSet insertResult = insertPreparedStatement.getGeneratedKeys()) {
1580 if (insertResult.next()) {
1581 attrId = insertResult.getInt(1);
1586 if (attrId == null) {
1587 throw new BlackboardException(MessageFormat.format(
1588 "Error adding attribute type. Item with name {0} was not inserted successfully into the database.", typeName));
1595 this.typeIdToAttributeTypeMap.put(type.getTypeID(), type);
1596 this.typeNameToAttributeTypeMap.put(type.getTypeName(), type);
1599 throw new BlackboardException(
"Error adding attribute type: " + typeName, ex);
1602 if (trans != null) {
1607 LOGGER.log(Level.SEVERE,
"Error rolling back transaction", ex2);
1625 final String queryString =
"SELECT DISTINCT arts.artifact_type_id AS artifact_type_id, "
1626 +
"types.type_name AS type_name, "
1627 +
"types.display_name AS display_name, "
1628 +
"types.category_type AS category_type "
1629 +
"FROM blackboard_artifact_types AS types "
1630 +
"INNER JOIN blackboard_artifacts AS arts "
1631 +
"ON arts.artifact_type_id = types.artifact_type_id "
1632 +
"WHERE arts.data_source_obj_id = " + dataSourceObjId;
1636 Statement statement = connection.createStatement();
1637 ResultSet resultSet = connection.executeQuery(statement, queryString);) {
1640 while (resultSet.next()) {
1642 resultSet.getString(
"type_name"), resultSet.getString(
"display_name"),
1645 return uniqueArtifactTypes;
1646 }
catch (SQLException ex) {
1647 throw new TskCoreException(
"Error getting artifact types is use for data source." + ex.getMessage(), ex);
1666 return getArtifactsCountHelper(artifactTypeID,
1667 "blackboard_artifacts.data_source_obj_id = '" + dataSourceObjId +
"';");
1682 return getArtifactsCountHelper(artifactTypeID, null);
1698 String whereClause = String.format(
"artifacts.data_source_obj_id = %d", dataSourceObjId);
1699 return getArtifactsWhere(
getArtifactType(artifactTypeID), whereClause);
1714 public List<BlackboardArtifact>
getArtifacts(Collection<BlackboardArtifact.Type> artifactTypes,
1717 if (artifactTypes.isEmpty() || dataSourceObjIds.isEmpty()) {
1718 return new ArrayList<>();
1721 String analysisResultQuery =
"";
1722 String dataArtifactQuery =
"";
1726 if (!analysisResultQuery.isEmpty()) {
1727 analysisResultQuery +=
" OR ";
1729 analysisResultQuery +=
"types.artifact_type_id = " + type.getTypeID();
1731 if (!dataArtifactQuery.isEmpty()) {
1732 dataArtifactQuery +=
" OR ";
1734 dataArtifactQuery +=
"types.artifact_type_id = " + type.getTypeID();
1738 String dsQuery =
"";
1739 for (
long dsId : dataSourceObjIds) {
1740 if (!dsQuery.isEmpty()) {
1743 dsQuery +=
"artifacts.data_source_obj_id = " + dsId;
1746 List<BlackboardArtifact> artifacts =
new ArrayList<>();
1748 if (!analysisResultQuery.isEmpty()) {
1749 String fullQuery =
"( " + analysisResultQuery +
" ) AND (" + dsQuery +
") ";
1753 if (!dataArtifactQuery.isEmpty()) {
1754 String fullQuery =
"( " + dataArtifactQuery +
" ) AND (" + dsQuery +
") ";
1781 String query =
" AND artifacts.artifact_type_id = " + artifactType.getTypeID()
1782 +
" AND attributes.attribute_type_id = " + attributeType.getTypeID()
1783 + ((value == null || value.isEmpty()) ?
"" :
" AND attributes.value_text = '" + value +
"'")
1785 + (dataSourceObjId != null ?
" AND artifacts.data_source_obj_id = " + dataSourceObjId :
"");
1787 List<BlackboardArtifact> artifacts =
new ArrayList<>();
1791 ? ANALYSIS_RESULT_QUERY_STRING_WITH_ATTRIBUTES + query
1792 : DATA_ARTIFACT_QUERY_STRING_WITH_ATTRIBUTES + query);
1794 try (CaseDbConnection connection = caseDb.getConnection()) {
1795 try (Statement statement = connection.createStatement();
1796 ResultSet resultSet = connection.executeQuery(statement, finalQuery);) {
1799 artifacts.addAll(resultSetToAnalysisResults(resultSet));
1801 artifacts.addAll(resultSetToDataArtifacts(resultSet));
1803 }
catch (SQLException ex) {
1804 throw new TskCoreException(String.format(
"Error getting results with queryString = '%s'", finalQuery), ex);
1864 String dataSourceClause = dataSourceId == null
1866 :
" AND artifacts.data_source_obj_id = ? ";
1868 String kwsListClause = (kwsListName == null || kwsListName.isEmpty()
1869 ?
" WHERE r.set_name IS NULL "
1870 :
" WHERE r.set_name = ? ");
1872 String keywordClause = (keyword == null || keyword.isEmpty()
1874 :
" AND r.keyword = ? ");
1876 String searchTypeClause = (searchType == null
1878 :
" AND r.search_type = ? ");
1880 String regexClause = (regex == null || regex.isEmpty()
1882 :
" AND r.regexp_str = ? ");
1884 String query =
"SELECT r.* FROM ( "
1885 +
" SELECT DISTINCT artifacts.artifact_id AS artifact_id, "
1886 +
" artifacts.obj_id AS obj_id, "
1887 +
" artifacts.artifact_obj_id AS artifact_obj_id, "
1888 +
" artifacts.data_source_obj_id AS data_source_obj_id, "
1889 +
" artifacts.artifact_type_id AS artifact_type_id, "
1890 +
" types.type_name AS type_name, "
1891 +
" types.display_name AS display_name, "
1892 +
" types.category_type as category_type,"
1893 +
" artifacts.review_status_id AS review_status_id, "
1894 +
" results.conclusion AS conclusion, "
1895 +
" results.significance AS significance, "
1896 +
" results.priority AS priority, "
1897 +
" results.configuration AS configuration, "
1898 +
" results.justification AS justification, "
1899 +
" (SELECT value_text FROM blackboard_attributes attr WHERE attr.artifact_id = artifacts.artifact_id AND attr.attribute_type_id = "
1901 +
" (SELECT value_int32 FROM blackboard_attributes attr WHERE attr.artifact_id = artifacts.artifact_id AND attr.attribute_type_id = "
1903 +
" (SELECT value_text FROM blackboard_attributes attr WHERE attr.artifact_id = artifacts.artifact_id AND attr.attribute_type_id = "
1905 +
" (SELECT value_text FROM blackboard_attributes attr WHERE attr.artifact_id = artifacts.artifact_id AND attr.attribute_type_id = "
1907 +
" FROM blackboard_artifacts artifacts "
1908 +
" JOIN blackboard_artifact_types AS types "
1909 +
" ON artifacts.artifact_type_id = types.artifact_type_id "
1910 +
" LEFT JOIN tsk_analysis_results AS results "
1911 +
" ON artifacts.artifact_obj_id = results.artifact_obj_id "
1914 + dataSourceClause +
" ) r "
1920 List<BlackboardArtifact> artifacts =
new ArrayList<>();
1922 try (CaseDbConnection connection = caseDb.getConnection()) {
1925 PreparedStatement preparedStatement = connection.getPreparedStatement(query, Statement.RETURN_GENERATED_KEYS);
1926 preparedStatement.clearParameters();
1928 if (dataSourceId != null) {
1929 preparedStatement.setLong(++paramIdx, dataSourceId);
1932 if (!(kwsListName == null || kwsListName.isEmpty())) {
1933 preparedStatement.setString(++paramIdx, kwsListName);
1936 if (!(keyword == null || keyword.isEmpty())) {
1937 preparedStatement.setString(++paramIdx, keyword);
1940 if (searchType != null) {
1941 preparedStatement.setInt(++paramIdx, searchType.getType());
1944 if (!(regex == null || regex.isEmpty())) {
1945 preparedStatement.setString(++paramIdx, regex);
1948 try (ResultSet resultSet = connection.executeQuery(preparedStatement)) {
1949 artifacts.addAll(resultSetToAnalysisResults(resultSet));
1952 }
catch (SQLException ex) {
1953 throw new TskCoreException(String.format(
"Error getting keyword search results with queryString = '%s'", query), ex);
1974 private long getArtifactsCountHelper(
int artifactTypeID, String whereClause)
throws TskCoreException {
1975 String queryString =
"SELECT COUNT(*) AS count FROM blackboard_artifacts "
1976 +
"WHERE blackboard_artifacts.artifact_type_id = " + artifactTypeID
1979 if (whereClause != null) {
1980 queryString +=
" AND " + whereClause;
1984 try (SleuthkitCase.CaseDbConnection connection = caseDb.getConnection();
1985 Statement statement = connection.createStatement();
1986 ResultSet resultSet = connection.executeQuery(statement, queryString);) {
1988 if (resultSet.next()) {
1989 count = resultSet.getLong(
"count");
1992 }
catch (SQLException ex) {
1993 throw new TskCoreException(
"Error getting artifact types is use for data source." + ex.getMessage(), ex);
2013 List<BlackboardArtifact> existingArtifacts = content.getArtifacts(artifactType.getTypeID());
2015 if (attributesMatch(artifact.getAttributes(), attributes)) {
2051 private boolean attributesMatch(Collection<BlackboardAttribute> fileAttributesList, Collection<BlackboardAttribute> expectedAttributesList) {
2053 boolean match =
false;
2056 if (attributeType.getTypeID() != expectedAttribute.getAttributeType().getTypeID()) {
2060 Object fileAttributeValue;
2061 Object expectedAttributeValue;
2062 switch (attributeType.getValueType()) {
2064 fileAttributeValue = fileAttribute.getValueBytes();
2065 expectedAttributeValue = expectedAttribute.getValueBytes();
2068 fileAttributeValue = fileAttribute.getValueDouble();
2069 expectedAttributeValue = expectedAttribute.getValueDouble();
2072 fileAttributeValue = fileAttribute.getValueInt();
2073 expectedAttributeValue = expectedAttribute.getValueInt();
2077 fileAttributeValue = fileAttribute.getValueLong();
2078 expectedAttributeValue = expectedAttribute.getValueLong();
2082 fileAttributeValue = fileAttribute.getValueString();
2083 expectedAttributeValue = expectedAttribute.getValueString();
2086 fileAttributeValue = fileAttribute.getDisplayString();
2087 expectedAttributeValue = expectedAttribute.getDisplayString();
2095 if (fileAttributeValue instanceof byte[]) {
2096 if (Arrays.equals((byte[]) fileAttributeValue, (byte[]) expectedAttributeValue)) {
2100 }
else if (fileAttributeValue.equals(expectedAttributeValue)) {
2124 public static final class BlackboardException
extends Exception {
2126 private static final long serialVersionUID = 1L;
2133 BlackboardException(String message) {
2144 BlackboardException(String message, Throwable cause) {
2145 super(message, cause);
2166 Collection<BlackboardAttribute> attributes, Long osAccountId)
throws TskCoreException {
2169 throw new TskCoreException(String.format(
"Artifact type (name = %s) is not of Data Artifact category. ", artifactType.getTypeName()));
2175 attributes, osAccountId, transaction);
2177 return dataArtifact;
2182 LOGGER.log(Level.SEVERE,
"Failed to rollback transaction after exception. "
2183 +
"Error invoking newDataArtifact with dataSourceObjId: " + dataSourceObjId +
", sourceObjId: " + sourceObjId, ex2);
2213 throw new TskCoreException(String.format(
"Artifact type (name = %s) is not of Data Artifact category. ", artifactType.getTypeName()));
2217 CaseDbConnection connection = transaction.getConnection();
2219 PreparedStatement statement = caseDb.createInsertArtifactStatement(artifactType.getTypeID(), sourceObjId, artifact_obj_id, dataSourceObjId, connection);
2221 connection.executeUpdate(statement);
2222 try (ResultSet resultSet = statement.getGeneratedKeys()) {
2225 sourceObjId, artifact_obj_id, dataSourceObjId, artifactType.getTypeID(),
2227 osAccountObjId,
true);
2230 if (osAccountObjId != null) {
2231 String insertDataArtifactSQL =
"INSERT INTO tsk_data_artifacts (artifact_obj_id, os_account_obj_id) VALUES (?, ?)";
2233 statement = connection.getPreparedStatement(insertDataArtifactSQL, Statement.NO_GENERATED_KEYS);
2234 statement.clearParameters();
2236 statement.setLong(1, artifact_obj_id);
2237 statement.setLong(2, osAccountObjId);
2238 connection.executeUpdate(statement);
2245 if (Objects.nonNull(attributes) && !attributes.isEmpty()) {
2249 return dataArtifact;
2251 }
catch (SQLException ex) {
2252 throw new TskCoreException(String.format(
"Error creating a data artifact with type id = %d, objId = %d, and data source oj id = %d ", artifactType.getTypeID(), sourceObjId, dataSourceObjId), ex);
2268 String whereClause = String.format(
"artifacts.obj_id = %d", sourceObjId);
2269 return getArtifactsWhere(artifactType, whereClause);
2281 List<BlackboardArtifact> getArtifactsByType(BlackboardArtifact.Type artifactType) throws TskCoreException {
2282 List<BlackboardArtifact> artifacts =
new ArrayList<>();
2283 if (artifactType.getCategory() == BlackboardArtifact.Category.ANALYSIS_RESULT) {
2308 private List<BlackboardArtifact> getArtifactsWhere(BlackboardArtifact.Type artifactType, String whereClause)
throws TskCoreException {
2309 List<BlackboardArtifact> artifacts =
new ArrayList<>();
2310 String whereWithType = whereClause +
" AND artifacts.artifact_type_id = " + artifactType.getTypeID();
2312 if (artifactType.getCategory() == BlackboardArtifact.Category.ANALYSIS_RESULT) {
2328 private final String moduleName;
2330 private final ImmutableSet<BlackboardArtifact> artifacts;
2331 private final Long ingestJobId;
2344 private ArtifactsPostedEvent(Collection<BlackboardArtifact> artifacts, String moduleName, Long ingestJobId)
throws BlackboardException {
2345 Set<Integer> typeIDS = artifacts.stream()
2347 .collect(Collectors.toSet());
2349 for (Integer typeID : typeIDS) {
2352 }
catch (TskCoreException tskCoreException) {
2353 throw new BlackboardException(
"Error getting artifact type by id.", tskCoreException);
2356 artifactTypes = ImmutableSet.copyOf(types);
2357 this.artifacts = ImmutableSet.copyOf(artifacts);
2358 this.moduleName = moduleName;
2359 this.ingestJobId = ingestJobId;
2368 return ImmutableSet.copyOf(artifacts);
2379 Set<BlackboardArtifact> tempSet = artifacts.stream()
2380 .filter(artifact -> artifact.getArtifactTypeID() == artifactType.getTypeID())
2381 .collect(Collectors.toSet());
2382 return ImmutableSet.copyOf(tempSet);
2400 return ImmutableSet.copyOf(artifactTypes);
2410 return Optional.ofNullable(ingestJobId);
static Priority fromID(int id)
List< BlackboardArtifact > getArtifacts(Collection< BlackboardArtifact.Type > artifactTypes, Collection< Long > dataSourceObjIds)
static Significance fromID(int id)
AnalysisResult getAnalysisResultById(long artifactObjId)
void postArtifact(BlackboardArtifact artifact, String moduleName)
CaseDbTransaction beginTransaction()
List< DataArtifact > getDataArtifacts(int artifactTypeID, long dataSourceObjId)
List< DataArtifact > getDataArtifacts(long dataSourceObjId, Integer artifactTypeID)
boolean hasAnalysisResults(long sourceObjId)
void postArtifacts(Collection< BlackboardArtifact > artifacts, String moduleName)
static final Type TSK_KEYWORD_HIT
static Category fromID(int id)
void addAttributes(Collection< BlackboardAttribute > attributes)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, long sourceObjId, Long dataSourceObjId, Collection< BlackboardAttribute > attributes, Long osAccountId)
ArrayList< BlackboardAttribute > getBlackboardAttributes(final BlackboardArtifact artifact)
DataArtifact getDataArtifactById(long artifactObjId)
Collection< BlackboardArtifact > getArtifacts()
BlackboardArtifact.Type getOrAddArtifactType(String typeName, String displayName, BlackboardArtifact.Category category)
Score deleteAnalysisResult(AnalysisResult analysisResult)
void postArtifacts(Collection< BlackboardArtifact > artifacts, String moduleName, Long ingestJobId)
List< AnalysisResult > getAnalysisResults(long sourceObjId)
Collection< BlackboardArtifact > getArtifacts(BlackboardArtifact.Type artifactType)
List< BlackboardArtifact > getExactMatchKeywordSearchResults(String keyword, TskData.KeywordSearchQueryType searchType, String kwsListName, Long dataSourceId)
List< DataArtifact > getDataArtifacts(int artifactTypeID)
List< AnalysisResult > getAnalysisResults(long dataSourceObjId, Integer artifactTypeID)
AnalysisResultAdded newAnalysisResult(BlackboardArtifact.Type artifactType, long objId, Long dataSourceObjId, Score score, String conclusion, String configuration, String justification, Collection< BlackboardAttribute > attributesList, CaseDbTransaction transaction)
List< AnalysisResult > getAnalysisResultsWhere(String whereClause)
List< BlackboardArtifact > getArtifacts(int artifactTypeID, long dataSourceObjId)
synchronized BlackboardAttribute.Type getOrAddAttributeType(String typeName, BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE valueType, String displayName)
Score deleteAnalysisResult(long artifactObjId, CaseDbTransaction transaction)
TimelineManager getTimelineManager()
void releaseSingleUserCaseReadLock()
static final Type TSK_KEYWORD
boolean artifactExists(Content content, BlackboardArtifact.Type artifactType, Collection< BlackboardAttribute > attributes)
static final Type TSK_KEYWORD_REGEXP
BlackboardArtifact.Type getArtifactType(String artTypeName)
List< AnalysisResult > getAnalysisResults(long sourceObjId, int artifactTypeId)
void acquireSingleUserCaseWriteLock()
OsAccountInstance newOsAccountInstance(OsAccount osAccount, DataSource dataSource, OsAccountInstance.OsAccountInstanceType instanceType)
void postArtifact(BlackboardArtifact artifact, String moduleName, Long ingestJobId)
void releaseSingleUserCaseWriteLock()
List< BlackboardArtifact > getArtifacts(BlackboardArtifact.Type artifactType, BlackboardAttribute.Type attributeType, String value, Long dataSourceObjId, boolean showRejected)
static TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE fromType(long typeId)
DataArtifact newDataArtifact(BlackboardArtifact.Type artifactType, long sourceObjId, Long dataSourceObjId, Collection< BlackboardAttribute > attributes, Long osAccountObjId, final CaseDbTransaction transaction)
List< AnalysisResult > getAnalysisResultsByType(int artifactTypeId, long dataSourceObjId)
Collection< BlackboardArtifact.Type > getArtifactTypes()
List< DataArtifact > getDataArtifactsWhere(String whereClause)
AnalysisResultAdded newAnalysisResult(BlackboardArtifact.Type artifactType, long objId, Long dataSourceObjId, Score score, String conclusion, String configuration, String justification, Collection< BlackboardAttribute > attributesList)
BlackboardArtifact.Type getOrAddArtifactType(String typeName, String displayName)
boolean hasDataArtifacts(long sourceObjId)
List< BlackboardArtifact > getKeywordSearchResults(String keyword, String regex, TskData.KeywordSearchQueryType searchType, String kwsListName, Long dataSourceId)
static final Type TSK_SET_NAME
OsAccountManager getOsAccountManager()
void acquireSingleUserCaseReadLock()
long getArtifactsCount(int artifactTypeID, long dataSourceObjId)
BlackboardAttribute.Type getAttributeType(String attrTypeName)
Optional< Long > getIngestJobId()
List< BlackboardArtifact.Type > getArtifactTypesInUse(long dataSourceObjId)
boolean artifactExists(Content content, BlackboardArtifact.ARTIFACT_TYPE artifactType, Collection< BlackboardAttribute > attributes)
static ReviewStatus withID(int id)
BlackboardArtifact.Type getArtifactType(int artTypeId)
long getArtifactsCount(int artifactTypeID)
List< AnalysisResult > getAnalysisResultsByType(int artifactTypeId)
ScoringManager getScoringManager()