mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Merge pull request #3269 from APriestman/3244_referenceSetType
Add correlation type field to reference sets
This commit is contained in:
commit
fe0114afa6
@ -1610,7 +1610,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
PreparedStatement preparedStatement1 = null;
|
||||
PreparedStatement preparedStatement2 = null;
|
||||
ResultSet resultSet = null;
|
||||
String sql1 = "INSERT INTO reference_sets(org_id, set_name, version, known_status, read_only, import_date) VALUES (?, ?, ?, ?, ?, ?)";
|
||||
String sql1 = "INSERT INTO reference_sets(org_id, set_name, version, known_status, read_only, type, import_date) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||
String sql2 = "SELECT id FROM reference_sets WHERE org_id=? AND set_name=? AND version=? AND import_date=? LIMIT 1";
|
||||
|
||||
try {
|
||||
@ -1620,7 +1620,8 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
preparedStatement1.setString(3, eamGlobalSet.getVersion());
|
||||
preparedStatement1.setInt(4, eamGlobalSet.getFileKnownStatus().getFileKnownValue());
|
||||
preparedStatement1.setBoolean(5, eamGlobalSet.isReadOnly());
|
||||
preparedStatement1.setString(6, eamGlobalSet.getImportDate().toString());
|
||||
preparedStatement1.setInt(6, eamGlobalSet.getType().getId());
|
||||
preparedStatement1.setString(7, eamGlobalSet.getImportDate().toString());
|
||||
|
||||
preparedStatement1.executeUpdate();
|
||||
|
||||
@ -1680,18 +1681,20 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
/**
|
||||
* Get all reference sets
|
||||
*
|
||||
* @param correlationType Type of sets to return
|
||||
*
|
||||
* @return List of all reference sets in the central repository
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public List<EamGlobalSet> getAllReferenceSets() throws EamDbException {
|
||||
public List<EamGlobalSet> getAllReferenceSets(CorrelationAttribute.Type correlationType) throws EamDbException {
|
||||
List<EamGlobalSet> results = new ArrayList<>();
|
||||
Connection conn = connect();
|
||||
|
||||
PreparedStatement preparedStatement1 = null;
|
||||
ResultSet resultSet = null;
|
||||
String sql1 = "SELECT * FROM reference_sets";
|
||||
String sql1 = "SELECT * FROM reference_sets WHERE type=" + correlationType.getId();
|
||||
|
||||
try {
|
||||
preparedStatement1 = conn.prepareStatement(sql1);
|
||||
@ -2194,7 +2197,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
return eamOrganization;
|
||||
}
|
||||
|
||||
private EamGlobalSet getEamGlobalSetFromResultSet(ResultSet resultSet) throws SQLException {
|
||||
private EamGlobalSet getEamGlobalSetFromResultSet(ResultSet resultSet) throws SQLException, EamDbException {
|
||||
if (null == resultSet) {
|
||||
return null;
|
||||
}
|
||||
@ -2206,6 +2209,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
resultSet.getString("version"),
|
||||
TskData.FileKnown.valueOf(resultSet.getByte("known_status")),
|
||||
resultSet.getBoolean("read_only"),
|
||||
EamDb.getInstance().getCorrelationTypeById(resultSet.getInt("type")),
|
||||
LocalDate.parse(resultSet.getString("import_date"))
|
||||
);
|
||||
|
||||
|
@ -147,8 +147,6 @@ public interface EamDb {
|
||||
*/
|
||||
CorrelationCase newCase(Case autopsyCase) throws EamDbException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates an existing Case in the database
|
||||
*
|
||||
@ -357,14 +355,17 @@ public interface EamDb {
|
||||
|
||||
/**
|
||||
* Remove a reference set and all values contained in it.
|
||||
*
|
||||
* @param referenceSetID
|
||||
* @throws EamDbException
|
||||
*/
|
||||
public void deleteReferenceSet(int referenceSetID) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Check whether a reference set with the given parameters exists in the central repository.
|
||||
* Used to check whether reference sets saved in the settings are still present.
|
||||
* Check whether a reference set with the given parameters exists in the
|
||||
* central repository. Used to check whether reference sets saved in the
|
||||
* settings are still present.
|
||||
*
|
||||
* @param referenceSetID
|
||||
* @param referenceSetName
|
||||
* @param version
|
||||
@ -374,8 +375,10 @@ public interface EamDb {
|
||||
public boolean referenceSetIsValid(int referenceSetID, String referenceSetName, String version) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Check whether a reference set with the given name/version is in the central repo.
|
||||
* Used to check for name collisions when creating reference sets.
|
||||
* Check whether a reference set with the given name/version is in the
|
||||
* central repo. Used to check for name collisions when creating reference
|
||||
* sets.
|
||||
*
|
||||
* @param referenceSetName
|
||||
* @param version
|
||||
* @return true if a matching set is found
|
||||
@ -384,8 +387,9 @@ public interface EamDb {
|
||||
public boolean referenceSetExists(String referenceSetName, String version) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Check if the given file hash is in this reference set.
|
||||
* Only searches the reference_files table.
|
||||
* Check if the given file hash is in this reference set. Only searches the
|
||||
* reference_files table.
|
||||
*
|
||||
* @param hash
|
||||
* @param referenceSetID
|
||||
* @return true if the hash is found in the reference set
|
||||
@ -395,6 +399,7 @@ public interface EamDb {
|
||||
|
||||
/**
|
||||
* Check if the given value is in a specific reference set
|
||||
*
|
||||
* @param value
|
||||
* @param referenceSetID
|
||||
* @param correlationTypeID
|
||||
@ -445,6 +450,7 @@ public interface EamDb {
|
||||
|
||||
/**
|
||||
* Get the organization associated with the given reference set.
|
||||
*
|
||||
* @param referenceSetID ID of the reference set
|
||||
* @return The organization object
|
||||
* @throws EamDbException
|
||||
@ -495,18 +501,19 @@ public interface EamDb {
|
||||
/**
|
||||
* Get all reference sets
|
||||
*
|
||||
* @param correlationType Type of sets to return
|
||||
*
|
||||
* @return List of all reference sets in the central repository
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
List<EamGlobalSet> getAllReferenceSets() throws EamDbException;
|
||||
List<EamGlobalSet> getAllReferenceSets(CorrelationAttribute.Type correlationType) throws EamDbException;
|
||||
|
||||
/**
|
||||
* 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 EamDbException
|
||||
*/
|
||||
@ -601,17 +608,20 @@ public interface EamDb {
|
||||
|
||||
/**
|
||||
* Upgrade the schema of the database (if needed)
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
public void upgradeSchema() throws EamDbException, SQLException;
|
||||
|
||||
/**
|
||||
* Gets an exclusive lock (if applicable).
|
||||
* Will return the lock if successful, null if unsuccessful because locking
|
||||
* isn't supported, and throw an exception if we should have been able to get the
|
||||
* lock but failed (meaning the database is in use).
|
||||
* Gets an exclusive lock (if applicable). Will return the lock if
|
||||
* successful, null if unsuccessful because locking isn't supported, and
|
||||
* throw an exception if we should have been able to get the lock but failed
|
||||
* (meaning the database is in use).
|
||||
*
|
||||
* @return the lock, or null if locking is not supported
|
||||
* @throws EamDbException if the coordination service is running but we fail to get the lock
|
||||
* @throws EamDbException if the coordination service is running but we fail
|
||||
* to get the lock
|
||||
*/
|
||||
public CoordinationService.Lock getExclusiveMultiUserDbLock() throws EamDbException;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public class EamGlobalSet {
|
||||
private String version;
|
||||
private TskData.FileKnown fileKnownStatus;
|
||||
private boolean isReadOnly;
|
||||
private CorrelationAttribute.Type type;
|
||||
private LocalDate importDate;
|
||||
|
||||
public EamGlobalSet(
|
||||
@ -41,6 +42,7 @@ public class EamGlobalSet {
|
||||
String version,
|
||||
TskData.FileKnown knownStatus,
|
||||
boolean isReadOnly,
|
||||
CorrelationAttribute.Type type,
|
||||
LocalDate importDate) {
|
||||
this.globalSetID = globalSetID;
|
||||
this.orgID = orgID;
|
||||
@ -48,6 +50,7 @@ public class EamGlobalSet {
|
||||
this.version = version;
|
||||
this.fileKnownStatus = knownStatus;
|
||||
this.isReadOnly = isReadOnly;
|
||||
this.type = type;
|
||||
this.importDate = importDate;
|
||||
}
|
||||
|
||||
@ -57,8 +60,9 @@ public class EamGlobalSet {
|
||||
String version,
|
||||
TskData.FileKnown knownStatus,
|
||||
boolean isReadOnly,
|
||||
CorrelationAttribute.Type type,
|
||||
LocalDate importDate) {
|
||||
this(-1, orgID, setName, version, knownStatus, isReadOnly, importDate);
|
||||
this(-1, orgID, setName, version, knownStatus, isReadOnly, type, importDate);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,8 +81,9 @@ public class EamGlobalSet {
|
||||
String setName,
|
||||
String version,
|
||||
TskData.FileKnown knownStatus,
|
||||
boolean isReadOnly) {
|
||||
this(-1, orgID, setName, version, knownStatus, isReadOnly, LocalDate.now());
|
||||
boolean isReadOnly,
|
||||
CorrelationAttribute.Type type) {
|
||||
this(-1, orgID, setName, version, knownStatus, isReadOnly, type, LocalDate.now());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,6 +170,24 @@ public class EamGlobalSet {
|
||||
this.fileKnownStatus = fileKnownStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of reference set
|
||||
*
|
||||
* @return the type (files, phone numbers, etc)
|
||||
*/
|
||||
public CorrelationAttribute.Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of reference set
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
void setType(CorrelationAttribute.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the importDate
|
||||
*/
|
||||
|
@ -356,6 +356,7 @@ public final class PostgresEamDbSettings {
|
||||
createReferenceSetsTable.append("version text NOT NULL,");
|
||||
createReferenceSetsTable.append("known_status integer NOT NULL,");
|
||||
createReferenceSetsTable.append("read_only boolean NOT NULL,");
|
||||
createReferenceSetsTable.append("type integer NOT NULL,");
|
||||
createReferenceSetsTable.append("import_date text NOT NULL,");
|
||||
createReferenceSetsTable.append("foreign key (org_id) references organizations(id) ON UPDATE SET NULL ON DELETE SET NULL,");
|
||||
createReferenceSetsTable.append("CONSTRAINT hash_set_unique UNIQUE (set_name, version)");
|
||||
|
@ -810,15 +810,17 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
/**
|
||||
* Get all reference sets
|
||||
*
|
||||
* @param correlationType Type of sets to return
|
||||
*
|
||||
* @return List of all reference sets in the central repository
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public List<EamGlobalSet> getAllReferenceSets() throws EamDbException{
|
||||
public List<EamGlobalSet> getAllReferenceSets(CorrelationAttribute.Type correlationType) throws EamDbException {
|
||||
try{
|
||||
acquireSharedLock();
|
||||
return super.getAllReferenceSets();
|
||||
return super.getAllReferenceSets(correlationType);
|
||||
} finally {
|
||||
releaseSharedLock();
|
||||
}
|
||||
|
@ -298,6 +298,7 @@ public final class SqliteEamDbSettings {
|
||||
createReferenceSetsTable.append("version text NOT NULL,");
|
||||
createReferenceSetsTable.append("known_status integer NOT NULL,");
|
||||
createReferenceSetsTable.append("read_only boolean NOT NULL,");
|
||||
createReferenceSetsTable.append("type integer NOT NULL,");
|
||||
createReferenceSetsTable.append("import_date text NOT NULL,");
|
||||
createReferenceSetsTable.append("foreign key (org_id) references organizations(id) ON UPDATE SET NULL ON DELETE SET NULL,");
|
||||
createReferenceSetsTable.append("CONSTRAINT hash_set_unique UNIQUE (set_name, version)");
|
||||
|
@ -31,6 +31,7 @@ import javax.swing.JOptionPane;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.windows.WindowManager;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttribute;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbUtil;
|
||||
@ -527,7 +528,7 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
|
||||
|
||||
try{
|
||||
int referenceSetID = EamDb.getInstance().newReferenceSet(new EamGlobalSet(selectedOrg.getOrgID(), hashSetNameTextField.getText(),
|
||||
"", fileKnown, false));
|
||||
"", fileKnown, false, EamDb.getInstance().getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID)));
|
||||
newHashDb = HashDbManager.getInstance().addExistingCentralRepoHashSet(hashSetNameTextField.getText(),
|
||||
"", referenceSetID,
|
||||
true, sendIngestMessagesCheckbox.isSelected(), type, false);
|
||||
|
@ -490,7 +490,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
List<HashDbInfo> crHashSets = new ArrayList<>();
|
||||
if(EamDb.isEnabled()){
|
||||
try{
|
||||
List<EamGlobalSet> crSets = EamDb.getInstance().getAllReferenceSets();
|
||||
List<EamGlobalSet> crSets = EamDb.getInstance().getAllReferenceSets(EamDb.getInstance().getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID));
|
||||
for(EamGlobalSet globalSet:crSets){
|
||||
|
||||
// Defaults for fields not stored in the central repository:
|
||||
|
@ -237,7 +237,8 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
|
||||
// Create an empty hashset in the central repository
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
referenceSetID.set(dbManager.newReferenceSet(new EamGlobalSet(orgId, hashSetName, version, knownStatus, readOnly)));
|
||||
referenceSetID.set(dbManager.newReferenceSet(new EamGlobalSet(orgId, hashSetName, version, knownStatus,
|
||||
readOnly, EamDb.getInstance().getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID))));
|
||||
|
||||
// Get the "FILES" content type. This is a database lookup so we
|
||||
// only want to do it once.
|
||||
|
Loading…
x
Reference in New Issue
Block a user