Merge pull request #7258 from wschaeferB/7917-OColumnChanges

7917 o column changes
This commit is contained in:
Richard Cordovano 2021-09-20 18:11:15 -04:00 committed by GitHub
commit cb9a4c01c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 305 additions and 466 deletions

View File

@ -67,7 +67,7 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction {
addToDatabase = true;
final List<CorrelationAttributeInstance> md5CorrelationAttr = CorrelationAttributeUtil.makeCorrAttrsForSearch(file);
if (!md5CorrelationAttr.isEmpty()) {
//for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistancy with other makeCorrAttrsForSearch methods per 7852
//for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistency with other makeCorrAttrsForSearch methods per 7852
correlationAttributeInstance = md5CorrelationAttr.get(0);
} else {
correlationAttributeInstance = null;

View File

@ -109,7 +109,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public void newDbInfo(String name, String value) throws CentralRepoException;
void newDbInfo(String name, String value) throws CentralRepoException;
/**
* Set the data source object id for a specific entry in the data_sources
@ -130,7 +130,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public String getDbInfo(String name) throws CentralRepoException;
String getDbInfo(String name) throws CentralRepoException;
/**
* Update the value for a name in the name/value db_info table.
@ -140,7 +140,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public void updateDbInfo(String name, String value) throws CentralRepoException;
void updateDbInfo(String name, String value) throws CentralRepoException;
/**
* Creates new Case in the database
@ -170,7 +170,9 @@ public interface CentralRepository {
* user is not found in the examiner table.
*
* @param examinerLoginName user name to look for.
*
* @return CentralRepoExaminer for the given user name.
*
* @throws CentralRepoException If there is an error in looking up or
* inserting the user in the examiners table.
*/
@ -373,6 +375,22 @@ public interface CentralRepository {
*/
Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException;
/**
* Gets the count of cases that have an instance of a given correlation
* attribute.
*
* This count will ignore the specified instance of the correlation
* attribute and any other instances of this correlation attribute existing
* on the same object.
*
* @param instance The instance having its cases with other occurrences
* counted.
*
* @return Number of cases with additional instances of this
* CorrelationAttributeInstance.
*/
Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException;
/**
* Retrieves number of data sources in the database.
*
@ -449,7 +467,8 @@ public interface CentralRepository {
* @param type The type of instance.
* @param correlationCase The case tied to the instance.
* @param correlationDataSource The data source tied to the instance.
* @param objectID The object id of the file tied to the instance.
* @param objectID The object id of the file tied to the
* instance.
*
* @return The correlation attribute if it exists; otherwise null.
*
@ -512,7 +531,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public void deleteReferenceSet(int referenceSetID) throws CentralRepoException;
void deleteReferenceSet(int referenceSetID) throws CentralRepoException;
/**
* Check whether a reference set with the given parameters exists in the
@ -527,7 +546,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public boolean referenceSetIsValid(int referenceSetID, String referenceSetName, String version) throws CentralRepoException;
boolean referenceSetIsValid(int referenceSetID, String referenceSetName, String version) throws CentralRepoException;
/**
* Check whether a reference set with the given name/version is in the
@ -541,7 +560,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public boolean referenceSetExists(String referenceSetName, String version) throws CentralRepoException;
boolean referenceSetExists(String referenceSetName, String version) throws CentralRepoException;
/**
* Check if the given file hash is in this reference set. Only searches the
@ -554,7 +573,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public boolean isFileHashInReferenceSet(String hash, int referenceSetID) throws CentralRepoException, CorrelationAttributeNormalizationException;
boolean isFileHashInReferenceSet(String hash, int referenceSetID) throws CentralRepoException, CorrelationAttributeNormalizationException;
/**
* Retrieves the given file HashHitInfo if the given file hash is in this
@ -580,7 +599,7 @@ public interface CentralRepository {
*
* @return true if the hash is found in the reference set
*/
public boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws CentralRepoException, CorrelationAttributeNormalizationException;
boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws CentralRepoException, CorrelationAttributeNormalizationException;
/**
* Is the artifact known as bad according to the reference entries?
@ -690,7 +709,8 @@ public interface CentralRepository {
* Add a new reference instance
*
* @param eamGlobalFileInstance The reference instance to add
* @param correlationType Correlation Type that this Reference Instance is
* @param correlationType Correlation Type that this Reference
* Instance is
*
* @throws CentralRepoException
*/
@ -788,7 +808,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public void upgradeSchema() throws CentralRepoException, SQLException, IncompatibleCentralRepoException;
void upgradeSchema() throws CentralRepoException, SQLException, IncompatibleCentralRepoException;
/**
* Gets an exclusive lock (if applicable). Will return the lock if
@ -801,7 +821,7 @@ public interface CentralRepository {
* @throws CentralRepoException if the coordination service is running but
* we fail to get the lock
*/
public CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException;
CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException;
/**
* Process the Artifact instance in the EamDb
@ -832,7 +852,7 @@ public interface CentralRepository {
*
* @throws CentralRepoException
*/
public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException;
void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException;
/**
* Executes an INSERT/UPDATE/DELETE sql as a prepared statement, on the
@ -861,7 +881,9 @@ public interface CentralRepository {
* Get account type by type name.
*
* @param accountTypeName account type name to look for
*
* @return CR account type (if found)
*
* @throws CentralRepoException
*/
Optional<CentralRepoAccountType> getAccountTypeByName(String accountTypeName) throws CentralRepoException;
@ -881,9 +903,11 @@ public interface CentralRepository {
*
* @param crAccountType CR account type to look for or create
* @param accountUniqueID type specific unique account id
*
* @return CR account
*
* @throws CentralRepoException If there is an error accessing Central Repository.
* @throws CentralRepoException If there is an error accessing Central
* Repository.
* @throws InvalidAccountIDException If the account identifier is not valid.
*/
CentralRepoAccount getOrCreateAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws InvalidAccountIDException, CentralRepoException;
@ -897,7 +921,8 @@ public interface CentralRepository {
*
* @return CR account, if found, null otherwise.
*
* @throws CentralRepoException If there is an error accessing Central Repository.
* @throws CentralRepoException If there is an error accessing Central
* Repository.
* @throws InvalidAccountIDException If the account identifier is not valid.
*/
CentralRepoAccount getAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws InvalidAccountIDException, CentralRepoException;

View File

@ -617,7 +617,7 @@ public class CorrelationAttributeUtil {
*/
public static CorrelationAttributeInstance getCorrAttrForFile(AbstractFile file) {
if (!isSupportedAbstractFileType(file)) {
if (!CentralRepository.isEnabled() || !isSupportedAbstractFileType(file)) {
return null;
}

View File

@ -269,4 +269,5 @@ final class PostgresCentralRepo extends RdbmsCentralRepo {
return columnExists;
}
}

View File

@ -1,7 +1,7 @@
/*
* Central Repository
*
* Copyright 2015-2020 Basis Technology Corp.
* Copyright 2015-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -212,8 +212,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting value for name.", ex);
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -505,8 +505,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting case details.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -565,8 +565,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting case details.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -602,8 +602,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting all cases.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -787,8 +787,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting data source.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -851,8 +851,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting data source.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -885,8 +885,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting all data sources.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -1099,7 +1099,6 @@ abstract class RdbmsCentralRepo implements CentralRepository {
throw new CentralRepoException(String.format("Cannot add account to currently selected CR database platform %s", CentralRepoDbManager.getSavedDbChoice().getDbPlatform())); //NON-NLS
}
try (Connection connection = connect();
PreparedStatement preparedStatement = connection.prepareStatement(insertSQL);) {
@ -1193,7 +1192,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
* @return CentralRepoAccount for the give type/id. May return null if not
* found.
*
* @throws CentralRepoException If there is an error accessing Central Repository.
* @throws CentralRepoException If there is an error accessing Central
* Repository.
* @throws InvalidAccountIDException If the account identifier is not valid.
*/
@Override
@ -1390,8 +1390,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting artifact instances by artifactType and artifactValue.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
return artifactInstances;
@ -1432,8 +1432,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting count of artifact instances by artifactType and artifactValue.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -1488,14 +1488,65 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error counting unique caseDisplayName/dataSource tuples having artifactType and artifactValue.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
return instanceCount;
}
@Override
public Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException {
Long instanceCount = 0L;
if (instance != null) {
Long sourceObjID = instance.getFileObjectId();
//The CorrelationAttributeInstance will have a CorrelationCase, however that correlation case's ID will be null if the case is not in the CR.
int correlationCaseId = instance.getCorrelationCase().getID();
String normalizedValue = CorrelationAttributeNormalizer.normalize(instance.getCorrelationType(), instance.getCorrelationValue());
Connection conn = connect();
PreparedStatement preparedStatement = null;
String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(instance.getCorrelationType());
ResultSet resultSet = null;
try {
if (correlationCaseId > 0 && sourceObjID != null) {
//The CorrelationCase is in the Central repository.
String sql
= "SELECT count(*) FROM (SELECT DISTINCT case_id FROM " //Get distinct cases with a matching value in the corresponding table from the central repository.
+ tableName
+ " WHERE value=? AND NOT (file_obj_id=? AND case_id=?)) AS " //Check the file_obj_id AND case_id to ensure we ignore the currently selected instance.
+ tableName
+ "_other_case_count";
preparedStatement = conn.prepareStatement(sql);
preparedStatement.setString(1, normalizedValue);
preparedStatement.setLong(2, sourceObjID);
preparedStatement.setInt(3, correlationCaseId);
} else {
//The CorrelationCase is NOT in the central repository.
String sql
= "SELECT count(*) FROM (SELECT DISTINCT case_id FROM " //Get all distinct cases with a matching value in the corresponding table from the central repository.
+ tableName
+ " WHERE value=? AS "
+ tableName
+ "_other_case_count";
preparedStatement = conn.prepareStatement(sql);
preparedStatement.setString(1, normalizedValue);
}
resultSet = preparedStatement.executeQuery();
resultSet.next();
instanceCount = resultSet.getLong(1);
} catch (SQLException ex) {
throw new CentralRepoException("Error counting unique caseDisplayName/dataSource tuples having artifactType and artifactValue.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
return instanceCount;
}
@Override
public Long getCountUniqueDataSources() throws CentralRepoException {
Connection conn = connect();
@ -1514,8 +1565,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error counting data sources.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -1561,8 +1612,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error counting artifact instances by caseName/dataSource.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -1888,8 +1939,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -1959,8 +2010,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -2046,9 +2097,9 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting/setting artifact instance knownStatus=" + knownStatus.getName(), ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedUpdate);
CentralRepoDbUtil.closeStatement(preparedQuery);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2088,8 +2139,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting count of notable artifact instances.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -2143,8 +2194,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -2195,8 +2246,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -2339,8 +2390,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error determining if value (" + normalizeValued + ") is in reference set " + referenceSetID, ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2378,8 +2429,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error determining if value (" + normalizeValued + ") is in reference set " + referenceSetID, ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -2422,8 +2473,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error determining if artifact is notable by reference.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
@ -2463,8 +2514,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting all artifact instances from instances table", ex);
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2509,8 +2560,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting all artifact instances from instances table", ex);
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2548,8 +2599,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error running query", ex);
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2582,8 +2633,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
throw new CentralRepoException("Query callback is null");
}
try ( Connection conn = connect();) {
try (Connection conn = connect();) {
PreparedStatement preparedStatement = conn.prepareStatement(sql);
// fill in the params
@ -2635,8 +2685,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error inserting new organization.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(generatedKeys);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2668,8 +2718,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting all organizations.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2701,8 +2751,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting organization by id.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2853,9 +2903,9 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error executing query when attempting to delete organization by id.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(checkIfUsedStatement);
CentralRepoDbUtil.closeStatement(deleteOrgStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2917,9 +2967,9 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error inserting new global set.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeStatement(preparedStatement2);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2954,8 +3004,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting reference set by id.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -2993,8 +3043,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting reference sets.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeConnection(conn);
}
return results;
@ -3071,8 +3121,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
throw new CentralRepoException("Error testing whether reference set exists (name: " + referenceSetName
+ " version: " + version, ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -3162,8 +3212,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting reference instances by type and value.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement1);
CentralRepoDbUtil.closeConnection(conn);
}
@ -3243,9 +3293,9 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error inserting new correlation type.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeStatement(preparedStatementQuery);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeConnection(conn);
}
return typeId;
@ -3297,9 +3347,9 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error inserting new correlation type.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeStatement(preparedStatementQuery);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeConnection(conn);
}
return typeId;
@ -3345,8 +3395,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting enabled correlation types.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -3380,8 +3430,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting supported correlation types.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}
@ -3474,8 +3524,8 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} catch (SQLException ex) {
throw new CentralRepoException("Error getting correlation type by id.", ex); // NON-NLS
} finally {
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeStatement(preparedStatement);
CentralRepoDbUtil.closeConnection(conn);
}
}

View File

@ -625,6 +625,16 @@ final class SqliteCentralRepo extends RdbmsCentralRepo {
}
}
@Override
public Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException {
try {
acquireSharedLock();
return super.getCountCasesWithOtherInstances(instance);
} finally {
releaseSharedLock();
}
}
@Override
public Long getCountUniqueDataSources() throws CentralRepoException {
try {

View File

@ -322,7 +322,7 @@ public final class CaseEventListener implements PropertyChangeListener {
private void setContentKnownStatus(AbstractFile af, TskData.FileKnown knownStatus) {
final List<CorrelationAttributeInstance> md5CorrelationAttr = CorrelationAttributeUtil.makeCorrAttrsForSearch(af);
if (!md5CorrelationAttr.isEmpty()) {
//for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistancy with other makeCorrAttrsForSearch methods per 7852
//for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistency with other makeCorrAttrsForSearch methods per 7852
// send update to Central Repository db
try {
dbManager.setAttributeInstanceKnownStatus(md5CorrelationAttr.get(0), knownStatus);
@ -436,7 +436,6 @@ public final class CaseEventListener implements PropertyChangeListener {
}
} catch (TskCoreException ex) {
LOGGER.log(Level.SEVERE, "Failed to obtain tags manager for case.", ex);
return;
}
}
@ -569,9 +568,9 @@ public final class CaseEventListener implements PropertyChangeListener {
if (!hasTagWithConflictingKnownStatus) {
Content taggedContent = contentTag.getContent();
if (taggedContent instanceof AbstractFile) {
final List<CorrelationAttributeInstance> eamArtifact = CorrelationAttributeUtil.makeCorrAttrsForSearch((AbstractFile) taggedContent);
final List<CorrelationAttributeInstance> eamArtifact = CorrelationAttributeUtil.makeCorrAttrsForSearch(taggedContent);
if (!eamArtifact.isEmpty()) {
//for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistancy with other makeCorrAttrsForSearch methods per 7852
//for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistency with other makeCorrAttrsForSearch methods per 7852
CentralRepository.getInstance().setAttributeInstanceKnownStatus(eamArtifact.get(0), tagName.getKnownStatus());
}
}

View File

@ -182,9 +182,13 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
Pair<Score, String> scorePropAndDescr = getScorePropertyAndDescription(tags);
Score value = scorePropAndDescr.getLeft();
String descr = scorePropAndDescr.getRight();
CorrelationAttributeInstance attribute = getCorrelationAttributeInstance();
List<CorrelationAttributeInstance> listWithJustFileAttr = new ArrayList<>();
CorrelationAttributeInstance corrInstance = CorrelationAttributeUtil.getCorrAttrForFile(content);
if (corrInstance != null) {
listWithJustFileAttr.add(corrInstance);
}
updateSheet(new NodeProperty<>(SCORE.toString(), SCORE.toString(), descr, value),
new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, attribute))
new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, listWithJustFileAttr))
);
}
} else if (eventType.equals(Case.Events.CONTENT_TAG_DELETED.toString())) {
@ -194,17 +198,25 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
Pair<Score, String> scorePropAndDescr = getScorePropertyAndDescription(tags);
Score value = scorePropAndDescr.getLeft();
String descr = scorePropAndDescr.getRight();
CorrelationAttributeInstance attribute = getCorrelationAttributeInstance();
List<CorrelationAttributeInstance> listWithJustFileAttr = new ArrayList<>();
CorrelationAttributeInstance corrInstance = CorrelationAttributeUtil.getCorrAttrForFile(content);
if (corrInstance != null) {
listWithJustFileAttr.add(corrInstance);
}
updateSheet(new NodeProperty<>(SCORE.toString(), SCORE.toString(), descr, value),
new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, attribute))
new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, listWithJustFileAttr))
);
}
} else if (eventType.equals(Case.Events.CR_COMMENT_CHANGED.toString())) {
CommentChangedEvent event = (CommentChangedEvent) evt;
if (event.getContentID() == content.getId()) {
List<Tag> tags = getAllTagsFromDatabase();
CorrelationAttributeInstance attribute = getCorrelationAttributeInstance();
updateSheet(new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, attribute)));
List<CorrelationAttributeInstance> listWithJustFileAttr = new ArrayList<>();
CorrelationAttributeInstance corrInstance = CorrelationAttributeUtil.getCorrAttrForFile(content);
if (corrInstance != null) {
listWithJustFileAttr.add(corrInstance);
}
updateSheet(new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, listWithJustFileAttr)));
}
} else if (eventType.equals(NodeSpecificEvents.TRANSLATION_AVAILABLE.toString())) {
this.setDisplayName(evt.getNewValue().toString());
@ -411,16 +423,15 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
"# {0} - occurrenceCount",
"AbstractAbstractFileNode.createSheet.count.description=There were {0} datasource(s) found with occurrences of the MD5 correlation value"})
@Override
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue,
String defaultDescription) {
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance attributeInstance, String defaultDescription) {
Long count = -1L; //The column renderer will not display negative values, negative value used when count unavailble to preserve sorting
String description = defaultDescription;
try {
//don't perform the query if there is no correlation value
if (attributeType != null && StringUtils.isNotBlank(attributeValue)) {
count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(attributeType, attributeValue);
if (attributeInstance != null && StringUtils.isNotBlank(attributeInstance.getCorrelationValue())) {
count = CentralRepository.getInstance().getCountCasesWithOtherInstances(attributeInstance);
description = Bundle.AbstractAbstractFileNode_createSheet_count_description(count);
} else if (attributeType != null) {
} else if (attributeInstance != null) {
description = Bundle.AbstractAbstractFileNode_createSheet_count_hashLookupNotRun_description();
}
} catch (CentralRepoException ex) {
@ -434,7 +445,7 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
@NbBundle.Messages({
"AbstractAbstractFileNode.createSheet.comment.displayName=C"})
@Override
protected HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute) {
protected HasCommentStatus getCommentProperty(List<Tag> tags, List<CorrelationAttributeInstance> attributes) {
DataResultViewerTable.HasCommentStatus status = !tags.isEmpty() ? DataResultViewerTable.HasCommentStatus.TAG_NO_COMMENT : DataResultViewerTable.HasCommentStatus.NO_COMMENT;
@ -445,12 +456,17 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
break;
}
}
if (attributes != null && !attributes.isEmpty()) {
for (CorrelationAttributeInstance attribute : attributes) {
if (attribute != null && !StringUtils.isBlank(attribute.getComment())) {
if (status == DataResultViewerTable.HasCommentStatus.TAG_COMMENT) {
status = DataResultViewerTable.HasCommentStatus.CR_AND_TAG_COMMENTS;
} else {
status = DataResultViewerTable.HasCommentStatus.CR_COMMENT;
}
break;
}
}
}
return status;
}
@ -490,15 +506,6 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
return new ArrayList<>(getContentTagsFromDatabase());
}
@Override
protected CorrelationAttributeInstance getCorrelationAttributeInstance() {
CorrelationAttributeInstance attribute = null;
if (CentralRepository.isEnabled() && !UserPreferences.getHideSCOColumns()) {
attribute = CorrelationAttributeUtil.getCorrAttrForFile(content);
}
return attribute;
}
static String getContentPath(AbstractFile file) {
try {
return file.getUniquePath();

View File

@ -325,15 +325,6 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
*/
abstract protected List<Tag> getAllTagsFromDatabase();
/**
* Returns correlation attribute instance for the underlying content of the
* node.
*
* @return correlation attribute instance for the underlying content of the
* node.
*/
abstract protected CorrelationAttributeInstance getCorrelationAttributeInstance();
/**
* Returns Score property for the node.
*
@ -361,22 +352,30 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
/**
* Returns comment property for the node.
*
* @param tags list of tags
* @param attribute correlation attribute instance
* Default implementation is a null implementation.
*
* @param tags The list of tags.
* @param attributes The list of correlation attribute instances.
*
* @return Comment property for the underlying content of the node.
*/
abstract protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute);
protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, List<CorrelationAttributeInstance> attributes) {
return DataResultViewerTable.HasCommentStatus.NO_COMMENT;
}
/**
* Returns occurrences/count property for the node.
*
* @param attributeType the type of the attribute to count
* @param attributeValue the value of the attribute to count
* @param defaultDescription a description to use when none is determined by
* the getCountPropertyAndDescription method
* Default implementation is a null implementation.
*
* @param attribute The correlation attribute for which data will
* be retrieved.
* @param defaultDescription A description to use when none is determined by
* the getCountPropertyAndDescription method.
*
* @return count property for the underlying content of the node.
*/
abstract protected Pair<Long, String> getCountPropertyAndDescription(Type attributeType, String attributeValue, String defaultDescription);
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance attribute, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
}

View File

@ -54,9 +54,7 @@ import org.sleuthkit.autopsy.casemodule.events.CommentChangedEvent;
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil;
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
@ -826,23 +824,6 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
return tags;
}
/**
* Gets the correlation attribute for the MD5 hash of the source file of the
* artifact represented by this node. The correlation attribute instance can
* only be returned if the central repository is enabled and the source
* content is a file.
*
* @return The correlation attribute instance, may be null.
*/
@Override
protected final CorrelationAttributeInstance getCorrelationAttributeInstance() {
CorrelationAttributeInstance correlationAttribute = null;
if (CentralRepository.isEnabled() && srcContent instanceof AbstractFile) {
correlationAttribute = CorrelationAttributeUtil.getCorrAttrForFile((AbstractFile) srcContent);
}
return correlationAttribute;
}
/**
* Computes the value of the comment property ("C" in S, C, O) for the
* artifact represented by this node.
@ -853,13 +834,13 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
* repository.
*
* @param tags The tags applied to the artifact and its source content.
* @param attribute A correlation attribute instance Ffor the central
* @param attribute A correlation attribute instance for the central
* repository lookup.
*
* @return The value of the comment property.
*/
@Override
protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute) {
protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, List<CorrelationAttributeInstance> attributes) {
/*
* Has a tag with a comment been applied to the artifact or its source
@ -877,50 +858,37 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
* Does the given correlation attribute instance have a comment in the
* central repository?
*/
if (attributes != null && !attributes.isEmpty()) {
for (CorrelationAttributeInstance attribute : attributes) {
if (attribute != null && !StringUtils.isBlank(attribute.getComment())) {
if (status == HasCommentStatus.TAG_COMMENT) {
status = HasCommentStatus.CR_AND_TAG_COMMENTS;
if (status == DataResultViewerTable.HasCommentStatus.TAG_COMMENT) {
status = DataResultViewerTable.HasCommentStatus.CR_AND_TAG_COMMENTS;
} else {
status = HasCommentStatus.CR_COMMENT;
status = DataResultViewerTable.HasCommentStatus.CR_COMMENT;
}
break;
}
}
}
return status;
}
/**
* Computes the value of the other occurrences property ("O" in S, C, O) for
* the artifact represented by this node. The value of the other occurrences
* property is the number of other data sources this artifact appears in
* according to a correlation attribute instance lookup in the central
* repository, plus one for the data source for this instance of the
* artifact.
*
* @param corrAttrType The correlation attribute instance type to use
* for the central repsoitory lookup.
* @param attributeValue The correlation attribute instane value to use
* for the central repsoitory lookup.
* @param defaultDescription A default description.
*
* @return The value of the occurrences property as a data sources count and
* a description string.
*
*/
@Override
protected Pair<Long, String> getCountPropertyAndDescription(Type corrAttrType, String attributeValue, String defaultDescription) {
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance attribute, String defaultDescription) {
Long count = -1L;
String description = defaultDescription;
try {
if (corrAttrType != null && StringUtils.isNotBlank(attributeValue)) {
count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(corrAttrType, attributeValue);
description = Bundle.BlackboardArtifactNode_createSheet_count_description(count, corrAttrType.getDisplayName());
} else if (corrAttrType != null) {
if (attribute != null && StringUtils.isNotBlank(attribute.getCorrelationValue())) {
count = CentralRepository.getInstance().getCountCasesWithOtherInstances(attribute);
description = Bundle.BlackboardArtifactNode_createSheet_count_description(count, attribute.getCorrelationType().getDisplayName());
} else if (attribute != null) {
description = Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationValues_description();
}
} catch (CentralRepoException ex) {
logger.log(Level.SEVERE, MessageFormat.format("Error querying central repository for other occurences count (artifact objID={0}, corrAttrType={1}, corrAttrValue={2})", artifact.getId(), corrAttrType, attributeValue), ex);
logger.log(Level.SEVERE, MessageFormat.format("Error querying central repository for other occurences count (artifact objID={0}, corrAttrType={1}, corrAttrValue={2})", artifact.getId(), attribute.getCorrelationType(), attribute.getCorrelationValue()), ex);
} catch (CorrelationAttributeNormalizationException ex) {
logger.log(Level.SEVERE, MessageFormat.format("Error normalizing correlation attribute for central repository query (artifact objID={0}, corrAttrType={2}, corrAttrValue={3})", artifact.getId(), corrAttrType, attributeValue), ex);
logger.log(Level.SEVERE, MessageFormat.format("Error normalizing correlation attribute for central repository query (artifact objID={0}, corrAttrType={2}, corrAttrValue={3})", artifact.getId(), attribute.getCorrelationType(), attribute.getCorrelationValue()), ex);
}
return Pair.of(count, description);
}
@ -953,7 +921,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
}
/**
* Adds a "custom" property to the property sheet of this node, indepoendent
* Adds a "custom" property to the property sheet of this node, independent
* of the artifact this node represents or its source content.
*
* @param property The custom property.
@ -1311,7 +1279,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
"BlackboardArtifactNode.createSheet.count.description=There were {0} datasource(s) found with occurrences of the correlation value of type {1}"})
@Deprecated
protected final void addCountProperty(Sheet.Set sheetSet, CorrelationAttributeInstance attribute) {
Pair<Long, String> countAndDescription = getCountPropertyAndDescription(attribute.getCorrelationType(), attribute.getCorrelationValue(), Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationAttributes_description());
Pair<Long, String> countAndDescription = getCountPropertyAndDescription(attribute, Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationAttributes_description());
sheetSet.put(new NodeProperty<>(Bundle.BlackboardArtifactNode_createSheet_count_name(), Bundle.BlackboardArtifactNode_createSheet_count_displayName(), countAndDescription.getRight(), countAndDescription.getLeft()));
}
@ -1333,7 +1301,9 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
"BlackboardArtifactNode.createSheet.comment.displayName=C"})
@Deprecated
protected final void addCommentProperty(Sheet.Set sheetSet, List<Tag> tags, CorrelationAttributeInstance attribute) {
HasCommentStatus status = getCommentProperty(tags, attribute);
List<CorrelationAttributeInstance> attributes = new ArrayList<>();
attributes.add(attribute);
HasCommentStatus status = getCommentProperty(tags, attributes);
sheetSet.put(new NodeProperty<>(Bundle.BlackboardArtifactNode_createSheet_comment_name(), Bundle.BlackboardArtifactNode_createSheet_comment_displayName(), NO_DESCR, status));
}
}

View File

@ -24,12 +24,11 @@ import java.lang.ref.WeakReference;
import java.util.List;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil;
import org.sleuthkit.autopsy.core.UserPreferences;
import org.sleuthkit.autopsy.events.AutopsyEvent;
import org.sleuthkit.datamodel.Tag;
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil;
/**
* Background task to get Score, Comment and Occurrences values for an Abstract
@ -58,27 +57,23 @@ class GetSCOTask implements Runnable {
}
// get the SCO column values
List<Tag> tags = contentNode.getAllTagsFromDatabase();
SCOData scoData = new SCOData();
scoData.setScoreAndDescription(contentNode.getScorePropertyAndDescription(tags));
//getting the correlation attribute and setting the comment column is done before the eamdb isEnabled check
//because the Comment column will reflect the presence of comments in the CR when the CR is enabled, but reflect tag comments regardless
CorrelationAttributeInstance fileAttribute = contentNode.getCorrelationAttributeInstance();
scoData.setComment(contentNode.getCommentProperty(tags, fileAttribute));
if (CentralRepository.isEnabled()) {
Type type = null;
String value = null;
String description = Bundle.GetSCOTask_occurrences_defaultDescription();
List<CorrelationAttributeInstance> listOfPossibleAttributes = CorrelationAttributeUtil.makeCorrAttrsForSearch(contentNode.getContent());
scoData.setComment(contentNode.getCommentProperty(tags, listOfPossibleAttributes));
CorrelationAttributeInstance corInstance = null;
if (CentralRepository.isEnabled()) {
if (listOfPossibleAttributes.size() > 1) {
//Don't display anything if there is more than 1 correlation property for an artifact but let the user know
description = Bundle.GetSCOTask_occurrences_multipleProperties();
} else if (!listOfPossibleAttributes.isEmpty()) {
//there should only be one item in the list
type = listOfPossibleAttributes.get(0).getCorrelationType();
value = listOfPossibleAttributes.get(0).getCorrelationValue();
corInstance = listOfPossibleAttributes.get(0);
}
scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(type, value, description));
scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(corInstance, description));
}
// signal SCO data is available.

View File

@ -27,15 +27,12 @@ import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.DeleteDataSourceAction;
import org.sleuthkit.autopsy.datasourcesummary.ui.ViewSummaryInformationAction;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor;
import org.sleuthkit.autopsy.directorytree.FileSearchAction;
@ -256,50 +253,4 @@ public class ImageNode extends AbstractContentNode<Image> {
protected List<Tag> getAllTagsFromDatabase() {
return new ArrayList<>();
}
/**
* Returns correlation attribute instance for the underlying content of the
* node.
*
* Null implementation of an abstract method.
*
* @return correlation attribute instance for the underlying content of the
* node.
*/
@Override
protected CorrelationAttributeInstance getCorrelationAttributeInstance() {
return null;
}
/**
* Returns comment property for the node.
*
* Null implementation of an abstract method.
*
* @param tags list of tags
* @param attribute correlation attribute instance
*
* @return Comment property for the underlying content of the node.
*/
@Override
protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute) {
return DataResultViewerTable.HasCommentStatus.NO_COMMENT;
}
/**
* Returns occurrences/count property for the node.
*
* Null implementation of an abstract method.
*
* @param attributeType the type of the attribute to count
* @param attributeValue the value of the attribute to coun
* @param defaultDescription a description to use when none is determined by
* the getCountPropertyAndDescription method
*
* @return count property for the underlying content of the node.
*/
@Override
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
}

View File

@ -30,7 +30,6 @@ import java.util.List;
import java.util.Optional;
import java.util.logging.Level;
import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
@ -40,8 +39,6 @@ import org.openide.util.NbBundle.Messages;
import org.openide.util.WeakListeners;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.events.OsAccountsUpdatedEvent;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.TimeZoneUtils;
import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.backgroundTasksPool;
@ -335,21 +332,6 @@ public final class OsAccounts implements AutopsyVisitableItem {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
protected CorrelationAttributeInstance getCorrelationAttributeInstance() {
return null;
}
@Override
protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute) {
return DataResultViewerTable.HasCommentStatus.NO_COMMENT;
}
@Override
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return null;
}
@Override
public <T> T accept(ContentNodeVisitor<T> visitor) {
return visitor.visit(this);

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2019 Basis Technology Corp.
* Copyright 2019-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -21,12 +21,8 @@ package org.sleuthkit.autopsy.datamodel;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.NO_DESCR;
import org.sleuthkit.datamodel.Pool;
import org.sleuthkit.datamodel.Tag;
@ -141,50 +137,4 @@ public class PoolNode extends AbstractContentNode<Pool> {
protected List<Tag> getAllTagsFromDatabase() {
return new ArrayList<>();
}
/**
* Returns correlation attribute instance for the underlying content of the
* node.
*
* Null implementation of an abstract method.
*
* @return correlation attribute instance for the underlying content of the
* node.
*/
@Override
protected CorrelationAttributeInstance getCorrelationAttributeInstance() {
return null;
}
/**
* Returns comment property for the node.
*
* Null implementation of an abstract method.
*
* @param tags list of tags
* @param attribute correlation attribute instance
*
* @return Comment property for the underlying content of the node.
*/
@Override
protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute) {
return DataResultViewerTable.HasCommentStatus.NO_COMMENT;
}
/**
* Returns occurrences/count property for the node.
*
* Null implementation of an abstract method.
*
* @param attributeType the type of the attribute to count
* @param attributeValue the value of the attribute to coun
* @param defaultDescription a description to use when none is determined by
* the getCountPropertyAndDescription method
*
* @return count property for the underlying content of the node.
*/
@Override
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
}

View File

@ -21,12 +21,8 @@ package org.sleuthkit.autopsy.datamodel;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.NO_DESCR;
import org.sleuthkit.datamodel.UnsupportedContent;
import org.sleuthkit.datamodel.Tag;
@ -40,8 +36,7 @@ public class UnsupportedContentNode extends AbstractContentNode<UnsupportedConte
* @param unsupportedContent underlying Content instance
*/
@NbBundle.Messages({
"UnsupportedContentNode.displayName=Unsupported Content",
})
"UnsupportedContentNode.displayName=Unsupported Content",})
public UnsupportedContentNode(UnsupportedContent unsupportedContent) {
super(unsupportedContent);
@ -73,8 +68,7 @@ public class UnsupportedContentNode extends AbstractContentNode<UnsupportedConte
@NbBundle.Messages({
"UnsupportedContentNode.createSheet.name.name=Name",
"UnsupportedContentNode.createSheet.name.displayName=Name",
"UnsupportedContentNode.createSheet.name.desc=no description",
})
"UnsupportedContentNode.createSheet.name.desc=no description",})
@Override
protected Sheet createSheet() {
Sheet sheet = super.createSheet();
@ -124,49 +118,4 @@ public class UnsupportedContentNode extends AbstractContentNode<UnsupportedConte
return new ArrayList<>();
}
/**
* Returns correlation attribute instance for the underlying content of the
* node.
*
* Null implementation of an abstract method.
*
* @return correlation attribute instance for the underlying content of the
* node.
*/
@Override
protected CorrelationAttributeInstance getCorrelationAttributeInstance() {
return null;
}
/**
* Returns comment property for the node.
*
* Null implementation of an abstract method.
*
* @param tags list of tags
* @param attribute correlation attribute instance
*
* @return Comment property for the underlying content of the node.
*/
@Override
protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute) {
return DataResultViewerTable.HasCommentStatus.NO_COMMENT;
}
/**
* Returns occurrences/count property for the node.
*
* Null implementation of an abstract method.
*
* @param attributeType the type of the attribute to count
* @param attributeValue the value of the attribute to coun
* @param defaultDescription a description to use when none is determined by
* the getCountPropertyAndDescription method
*
* @return count property for the underlying content of the node.
*/
@Override
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
}

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2019 Basis Technology Corp.
* Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -26,14 +26,10 @@ import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.Sheet;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable;
import org.sleuthkit.autopsy.coreutils.Logger;
import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.NO_DESCR;
import org.sleuthkit.autopsy.datamodel.BaseChildFactory.NoSuchEventBusException;
import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor;
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
@ -82,13 +78,13 @@ public class VolumeNode extends AbstractContentNode<Volume> {
// If this is a pool volume use a custom display name
try {
if (vol.getParent() != null &&
vol.getParent().getParent() instanceof Pool) {
if (vol.getParent() != null
&& vol.getParent().getParent() instanceof Pool) {
// Pool volumes are not contiguous so printing a range of blocks is inaccurate
tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + ")";
}
} catch (TskCoreException ex) {
logger.log(Level.WARNING, "Error looking up parent(s) of volume with obj ID = "+ vol.getId(), ex);
logger.log(Level.WARNING, "Error looking up parent(s) of volume with obj ID = " + vol.getId(), ex);
}
this.setDisplayName(tempVolName);
@ -244,49 +240,4 @@ public class VolumeNode extends AbstractContentNode<Volume> {
return new ArrayList<>();
}
/**
* Returns correlation attribute instance for the underlying content of the
* node.
*
* Null implementation of an abstract method.
*
* @return correlation attribute instance for the underlying content of the
* node.
*/
@Override
protected CorrelationAttributeInstance getCorrelationAttributeInstance() {
return null;
}
/**
* Returns comment property for the node.
*
* Null implementation of an abstract method.
*
* @param tags list of tags
* @param attribute correlation attribute instance
*
* @return Comment property for the underlying content of the node.
*/
@Override
protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute) {
return DataResultViewerTable.HasCommentStatus.NO_COMMENT;
}
/**
* Returns occurrences/count property for the node.
*
* Null implementation of an abstract method.
*
* @param attributeType the type of the attribute to count
* @param attributeValue the value of the attribute to coun
* @param defaultDescription a description to use when none is determined by
* the getCountPropertyAndDescription method
*
* @return count property for the underlying content of the node.
*/
@Override
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
}