mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge branch '3139_cr_hashes' into 3144_encaseHashes
This commit is contained in:
commit
3605ba147e
@ -1252,16 +1252,21 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
|
||||
/**
|
||||
* Remove a reference set and all hashes contained in it.
|
||||
* @param centralRepoIndex
|
||||
* @param referenceSetID
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public void deleteReferenceSet(int centralRepoIndex) throws EamDbException{
|
||||
deleteReferenceSetFiles(centralRepoIndex);
|
||||
deleteReferenceSetEntry(centralRepoIndex);
|
||||
public void deleteReferenceSet(int referenceSetID) throws EamDbException{
|
||||
deleteReferenceSetFiles(referenceSetID);
|
||||
deleteReferenceSetEntry(referenceSetID);
|
||||
}
|
||||
|
||||
private void deleteReferenceSetEntry(int centralRepoIndex) throws EamDbException{
|
||||
/**
|
||||
* Remove the entry for this set from the reference_sets table
|
||||
* @param referenceSetID
|
||||
* @throws EamDbException
|
||||
*/
|
||||
private void deleteReferenceSetEntry(int referenceSetID) throws EamDbException{
|
||||
Connection conn = connect();
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
@ -1269,7 +1274,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
|
||||
try {
|
||||
preparedStatement = conn.prepareStatement(sql);
|
||||
preparedStatement.setInt(1, centralRepoIndex);
|
||||
preparedStatement.setInt(1, referenceSetID);
|
||||
preparedStatement.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
throw new EamDbException("Error deleting reference set", ex); // NON-NLS
|
||||
@ -1279,8 +1284,12 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void deleteReferenceSetFiles(int centralRepoIndex) throws EamDbException{
|
||||
/**
|
||||
* Remove all entries for this reference set from the reference_file table
|
||||
* @param referenceSetID
|
||||
* @throws EamDbException
|
||||
*/
|
||||
private void deleteReferenceSetFiles(int referenceSetID) throws EamDbException{
|
||||
Connection conn = connect();
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
@ -1290,7 +1299,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
|
||||
try {
|
||||
preparedStatement = conn.prepareStatement(String.format(sql, fileTableName));
|
||||
preparedStatement.setInt(1, centralRepoIndex);
|
||||
preparedStatement.setInt(1, referenceSetID);
|
||||
preparedStatement.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
throw new EamDbException("Error deleting files from reference set", ex); // NON-NLS
|
||||
@ -1302,14 +1311,15 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
|
||||
/**
|
||||
* Check whether the given reference set exists in the central repository.
|
||||
* @param centralRepoIndex
|
||||
* @param referenceSetID
|
||||
* @param hashSetName
|
||||
* @param version
|
||||
* @return
|
||||
* @return true if a matching entry exists in the central repository
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public boolean referenceSetIsValid(int centralRepoIndex, String hashSetName, String version) throws EamDbException{
|
||||
EamGlobalSet refSet = this.getReferenceSetByID(centralRepoIndex);
|
||||
public boolean referenceSetIsValid(int referenceSetID, String hashSetName, String version) throws EamDbException{
|
||||
EamGlobalSet refSet = this.getReferenceSetByID(referenceSetID);
|
||||
if(refSet == null){
|
||||
return false;
|
||||
}
|
||||
@ -1320,11 +1330,11 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
/**
|
||||
* Check if the given hash is in a specific reference set
|
||||
* @param hash
|
||||
* @param index
|
||||
* @return
|
||||
* @param referenceSetID
|
||||
* @return true if the hash is found in the reference set
|
||||
*/
|
||||
@Override
|
||||
public boolean isHashInReferenceSet(String hash, int index) throws EamDbException{
|
||||
public boolean isHashInReferenceSet(String hash, int referenceSetID) throws EamDbException{
|
||||
|
||||
Connection conn = connect();
|
||||
|
||||
@ -1338,7 +1348,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
try {
|
||||
preparedStatement = conn.prepareStatement(String.format(sql, fileTableName));
|
||||
preparedStatement.setString(1, hash);
|
||||
preparedStatement.setInt(2, index);
|
||||
preparedStatement.setInt(2, referenceSetID);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
resultSet.next();
|
||||
matchingInstances = resultSet.getLong(1);
|
||||
@ -1499,27 +1509,27 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the organization associated with the given reference set.
|
||||
* @param globalSetID ID of the reference set
|
||||
* @param referenceSetID ID of the reference set
|
||||
* @return The organization object
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public EamOrganization getReferenceSetOrganization(int globalSetID) throws EamDbException{
|
||||
public EamOrganization getReferenceSetOrganization(int referenceSetID) throws EamDbException{
|
||||
|
||||
EamGlobalSet globalSet = getReferenceSetByID(globalSetID);
|
||||
EamGlobalSet globalSet = getReferenceSetByID(referenceSetID);
|
||||
return (getOrganizationByID(globalSet.getOrgID()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new Global Set
|
||||
* Add a new reference set
|
||||
*
|
||||
* @param orgID
|
||||
* @param setName
|
||||
* @param version
|
||||
* @param importDate
|
||||
* @return
|
||||
* @return the reference set ID of the newly created set
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
@ -1684,7 +1694,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
/**
|
||||
* Get all reference sets
|
||||
*
|
||||
* @return The global set associated with the ID
|
||||
* @return List of all reference sets in the central repository
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@ -1750,7 +1760,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
* Check whether a reference set with the given name/version is in the central repo
|
||||
* @param hashSetName
|
||||
* @param version
|
||||
* @return
|
||||
* @return true if a matching set is found
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
|
@ -18,12 +18,10 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.sleuthkit.datamodel.TskData;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager;
|
||||
|
||||
/**
|
||||
* Main interface for interacting with the database
|
||||
@ -357,25 +355,26 @@ public interface EamDb {
|
||||
|
||||
/**
|
||||
* Remove a reference set and all hashes contained in it.
|
||||
* @param centralRepoIndex
|
||||
* @param referenceSetID
|
||||
* @throws EamDbException
|
||||
*/
|
||||
public void deleteReferenceSet(int centralRepoIndex) throws EamDbException;
|
||||
public void deleteReferenceSet(int referenceSetID) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Check whether the given reference set exists in the central repository.
|
||||
* @param centralRepoIndex
|
||||
* @param referenceSetID
|
||||
* @param hashSetName
|
||||
* @param version
|
||||
* @return
|
||||
* @return true if a matching entry exists in the central repository
|
||||
* @throws EamDbException
|
||||
*/
|
||||
public boolean referenceSetIsValid(int centralRepoIndex, String hashSetName, String version) throws EamDbException;
|
||||
public boolean referenceSetIsValid(int referenceSetID, String hashSetName, String version) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Check whether a reference set with the given name/version is in the central repo
|
||||
* @param hashSetName
|
||||
* @param version
|
||||
* @return
|
||||
* @return true if a matching set is found
|
||||
* @throws EamDbException
|
||||
*/
|
||||
public boolean referenceSetExists(String hashSetName, String version) throws EamDbException;
|
||||
@ -383,10 +382,10 @@ public interface EamDb {
|
||||
/**
|
||||
* Check if the given hash is in a specific reference set
|
||||
* @param hash
|
||||
* @param index
|
||||
* @return
|
||||
* @param referenceSetID
|
||||
* @return true if the hash is found in the reference set
|
||||
*/
|
||||
public boolean isHashInReferenceSet(String hash, int index) throws EamDbException;
|
||||
public boolean isHashInReferenceSet(String hash, int referenceSetID) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Is the artifact known as bad according to the reference entries?
|
||||
@ -431,11 +430,11 @@ public interface EamDb {
|
||||
|
||||
/**
|
||||
* Get the organization associated with the given reference set.
|
||||
* @param globalSetID ID of the reference set
|
||||
* @param referenceSetID ID of the reference set
|
||||
* @return The organization object
|
||||
* @throws EamDbException
|
||||
*/
|
||||
EamOrganization getReferenceSetOrganization(int globalSetID) throws EamDbException;
|
||||
EamOrganization getReferenceSetOrganization(int referenceSetID) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Update an existing organization.
|
||||
@ -468,13 +467,13 @@ public interface EamDb {
|
||||
int newReferencelSet(EamGlobalSet eamGlobalSet) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Add a new Global Set
|
||||
* Add a new reference set
|
||||
*
|
||||
* @param orgID
|
||||
* @param setName
|
||||
* @param version
|
||||
*
|
||||
* @return The ID of the new global set
|
||||
* @param importDate
|
||||
* @return the reference set ID of the newly created set
|
||||
* @throws EamDbException
|
||||
*/
|
||||
int newReferenceSet(int orgID, String setName, String version, TskData.FileKnown knownStatus,
|
||||
@ -494,7 +493,7 @@ public interface EamDb {
|
||||
/**
|
||||
* Get all reference sets
|
||||
*
|
||||
* @return The global set associated with the ID
|
||||
* @return List of all reference sets in the central repository
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
|
@ -637,14 +637,14 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
|
||||
/**
|
||||
* Remove a reference set and all hashes contained in it.
|
||||
* @param centralRepoIndex
|
||||
* @param referenceSetID
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public void deleteReferenceSet(int centralRepoIndex) throws EamDbException{
|
||||
public void deleteReferenceSet(int referenceSetID) throws EamDbException{
|
||||
try{
|
||||
acquireExclusiveLock();
|
||||
super.deleteReferenceSet(centralRepoIndex);
|
||||
super.deleteReferenceSet(referenceSetID);
|
||||
} finally {
|
||||
releaseExclusiveLock();
|
||||
}
|
||||
@ -653,14 +653,14 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
/**
|
||||
* Check if the given hash is in a specific reference set
|
||||
* @param hash
|
||||
* @param index
|
||||
* @return
|
||||
* @param referenceSetID
|
||||
* @return true if the hash is found in the reference set
|
||||
*/
|
||||
@Override
|
||||
public boolean isHashInReferenceSet(String hash, int index) throws EamDbException{
|
||||
public boolean isHashInReferenceSet(String hash, int referenceSetID) throws EamDbException{
|
||||
try{
|
||||
acquireSharedLock();
|
||||
return super.isHashInReferenceSet(hash, index);
|
||||
return super.isHashInReferenceSet(hash, referenceSetID);
|
||||
} finally {
|
||||
releaseSharedLock();
|
||||
}
|
||||
@ -670,7 +670,7 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
* Check whether a reference set with the given name/version is in the central repo
|
||||
* @param hashSetName
|
||||
* @param version
|
||||
* @return
|
||||
* @return true if a matching set is found
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
@ -816,7 +816,7 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
/**
|
||||
* Get all reference sets
|
||||
*
|
||||
* @return The global set associated with the ID
|
||||
* @return List of all reference sets in the central repository
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@ -847,7 +847,7 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
} finally {
|
||||
releaseExclusiveLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the bulk collection of Reference Type Instances
|
||||
|
@ -281,7 +281,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
return hashDb;
|
||||
}
|
||||
|
||||
public CentralRepoHashDb addExistingCentralRepoHashSet(String hashSetName, String version, int centralRepoIndex,
|
||||
public CentralRepoHashDb addExistingCentralRepoHashSet(String hashSetName, String version, int referenceSetID,
|
||||
boolean searchDuringIngest, boolean sendIngestMessages, HashDb.KnownFilesType knownFilesType,
|
||||
boolean readOnly) throws TskCoreException{
|
||||
|
||||
@ -289,7 +289,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
throw new TskCoreException("Could not load central repository database " + hashSetName + " - central repository is not enabled");
|
||||
}
|
||||
|
||||
CentralRepoHashDb db = new CentralRepoHashDb(hashSetName, version, centralRepoIndex, searchDuringIngest,
|
||||
CentralRepoHashDb db = new CentralRepoHashDb(hashSetName, version, referenceSetID, searchDuringIngest,
|
||||
sendIngestMessages, knownFilesType, readOnly);
|
||||
|
||||
if(! db.isValid()){
|
||||
@ -633,7 +633,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
} else {
|
||||
if(EamDb.isEnabled()){
|
||||
addExistingCentralRepoHashSet(hashDbInfo.getHashSetName(), hashDbInfo.getVersion(),
|
||||
hashDbInfo.getCentralRepoIndex(),
|
||||
hashDbInfo.getReferenceSetID(),
|
||||
hashDbInfo.getSearchDuringIngest(), hashDbInfo.getSendIngestMessages(),
|
||||
hashDbInfo.getKnownFilesType(), hashDbInfo.isReadOnly());
|
||||
}
|
||||
@ -687,7 +687,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
for(HashDbInfo hashDbInfo : crHashDbInfoList) {
|
||||
if(hashDbInfoIsNew(hashDbInfo)){
|
||||
addExistingCentralRepoHashSet(hashDbInfo.getHashSetName(), hashDbInfo.getVersion(),
|
||||
hashDbInfo.getCentralRepoIndex(),
|
||||
hashDbInfo.getReferenceSetID(),
|
||||
hashDbInfo.getSearchDuringIngest(), hashDbInfo.getSendIngestMessages(), hashDbInfo.getKnownFilesType(),
|
||||
hashDbInfo.isReadOnly());
|
||||
}
|
||||
@ -1150,27 +1150,27 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
private boolean searchDuringIngest;
|
||||
private boolean sendIngestMessages;
|
||||
private final HashDb.KnownFilesType knownFilesType;
|
||||
private final int centralRepoIndex;
|
||||
private final int referenceSetID;
|
||||
private final String version;
|
||||
private String orgName;
|
||||
private final boolean readOnly;
|
||||
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
|
||||
@Messages({"HashDbManager.CentralRepoHashDb.orgError=Error loading organization"})
|
||||
private CentralRepoHashDb(String hashSetName, String version, int centralRepoIndex,
|
||||
private CentralRepoHashDb(String hashSetName, String version, int referenceSetID,
|
||||
boolean useForIngest, boolean sendHitMessages, HashDb.KnownFilesType knownFilesType,
|
||||
boolean readOnly)
|
||||
throws TskCoreException{
|
||||
this.hashSetName = hashSetName;
|
||||
this.version = version;
|
||||
this.centralRepoIndex = centralRepoIndex;
|
||||
this.referenceSetID = referenceSetID;
|
||||
this.searchDuringIngest = useForIngest;
|
||||
this.sendIngestMessages = sendHitMessages;
|
||||
this.knownFilesType = knownFilesType;
|
||||
this.readOnly = readOnly;
|
||||
|
||||
try{
|
||||
orgName = EamDb.getInstance().getReferenceSetOrganization(centralRepoIndex).getName();
|
||||
orgName = EamDb.getInstance().getReferenceSetOrganization(referenceSetID).getName();
|
||||
} catch (EamDbException ex){
|
||||
Logger.getLogger(HashDb.class.getName()).log(Level.SEVERE, "Error looking up central repository organization", ex); //NON-NLS
|
||||
orgName = Bundle.HashDbManager_CentralRepoHashDb_orgError();
|
||||
@ -1221,8 +1221,8 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
return orgName;
|
||||
}
|
||||
|
||||
public int getCentralRepoIndex(){
|
||||
return centralRepoIndex;
|
||||
public int getReferenceSetID(){
|
||||
return referenceSetID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1341,7 +1341,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
AbstractFile file = (AbstractFile) content;
|
||||
if (null != file.getMd5Hash()) {
|
||||
try{
|
||||
return EamDb.getInstance().isHashInReferenceSet(file.getMd5Hash(), this.centralRepoIndex);
|
||||
return EamDb.getInstance().isHashInReferenceSet(file.getMd5Hash(), this.referenceSetID);
|
||||
} catch (EamDbException ex){
|
||||
Logger.getLogger(HashDb.class.getName()).log(Level.SEVERE, "Error performing central reposiotry hash lookup", ex); //NON-NLS
|
||||
throw new TskCoreException("Error performing central reposiotry hash lookup", ex);
|
||||
@ -1369,7 +1369,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
AbstractFile file = (AbstractFile) content;
|
||||
if (null != file.getMd5Hash()) {
|
||||
try{
|
||||
if(EamDb.getInstance().isHashInReferenceSet(file.getMd5Hash(), this.centralRepoIndex)){
|
||||
if(EamDb.getInstance().isHashInReferenceSet(file.getMd5Hash(), this.referenceSetID)){
|
||||
// Make a bare-bones HashHitInfo for now
|
||||
result = new HashHitInfo(file.getMd5Hash(), "", "");
|
||||
}
|
||||
@ -1394,7 +1394,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
return EamDb.getInstance().referenceSetIsValid(this.centralRepoIndex, this.hashSetName, this.version);
|
||||
return EamDb.getInstance().referenceSetIsValid(this.referenceSetID, this.hashSetName, this.version);
|
||||
} catch (EamDbException ex){
|
||||
Logger.getLogger(CentralRepoHashDb.class.getName()).log(Level.SEVERE, "Error validating hash database " + hashSetName, ex); //NON-NLS
|
||||
return false;
|
||||
@ -1422,7 +1422,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
int code = 23;
|
||||
code = 47 * code + Objects.hashCode(this.hashSetName);
|
||||
code = 47 * code + Objects.hashCode(this.version);
|
||||
code = 47 * code + Integer.hashCode(this.centralRepoIndex);
|
||||
code = 47 * code + Integer.hashCode(this.referenceSetID);
|
||||
code = 47 * code + Objects.hashCode(this.knownFilesType);
|
||||
return code;
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ final class HashLookupSettings implements Serializable {
|
||||
private final String path;
|
||||
private final String version;
|
||||
private final boolean readOnly;
|
||||
private final int centralRepoIndex;
|
||||
private final int referenceSetID;
|
||||
private DatabaseType dbType;
|
||||
|
||||
/**
|
||||
@ -324,16 +324,16 @@ final class HashLookupSettings implements Serializable {
|
||||
this.searchDuringIngest = searchDuringIngest;
|
||||
this.sendIngestMessages = sendIngestMessages;
|
||||
this.path = path;
|
||||
this.centralRepoIndex = -1;
|
||||
this.referenceSetID = -1;
|
||||
this.version = "";
|
||||
this.readOnly = false;
|
||||
this.dbType = DatabaseType.FILE;
|
||||
}
|
||||
|
||||
HashDbInfo(String hashSetName, String version, int centralRepoIndex, HashDbManager.HashDb.KnownFilesType knownFilesType, boolean readOnly, boolean searchDuringIngest, boolean sendIngestMessages){
|
||||
HashDbInfo(String hashSetName, String version, int referenceSetID, HashDbManager.HashDb.KnownFilesType knownFilesType, boolean readOnly, boolean searchDuringIngest, boolean sendIngestMessages){
|
||||
this.hashSetName = hashSetName;
|
||||
this.version = version;
|
||||
this.centralRepoIndex = centralRepoIndex;
|
||||
this.referenceSetID = referenceSetID;
|
||||
this.knownFilesType = knownFilesType;
|
||||
this.readOnly = readOnly;
|
||||
this.searchDuringIngest = searchDuringIngest;
|
||||
@ -349,7 +349,7 @@ final class HashLookupSettings implements Serializable {
|
||||
this.knownFilesType = fileTypeDb.getKnownFilesType();
|
||||
this.searchDuringIngest = fileTypeDb.getSearchDuringIngest();
|
||||
this.sendIngestMessages = fileTypeDb.getSendIngestMessages();
|
||||
this.centralRepoIndex = -1;
|
||||
this.referenceSetID = -1;
|
||||
this.version = "";
|
||||
this.readOnly = false;
|
||||
this.dbType = DatabaseType.FILE;
|
||||
@ -367,7 +367,7 @@ final class HashLookupSettings implements Serializable {
|
||||
this.searchDuringIngest = centralRepoDb.getSearchDuringIngest();
|
||||
this.sendIngestMessages = centralRepoDb.getSendIngestMessages();
|
||||
this.path = "";
|
||||
this.centralRepoIndex = centralRepoDb.getCentralRepoIndex();
|
||||
this.referenceSetID = centralRepoDb.getReferenceSetID();
|
||||
this.dbType = DatabaseType.CENTRAL_REPOSITORY;
|
||||
}
|
||||
}
|
||||
@ -441,8 +441,8 @@ final class HashLookupSettings implements Serializable {
|
||||
return path;
|
||||
}
|
||||
|
||||
int getCentralRepoIndex(){
|
||||
return centralRepoIndex;
|
||||
int getReferenceSetID(){
|
||||
return referenceSetID;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -481,7 +481,7 @@ final class HashLookupSettings implements Serializable {
|
||||
|
||||
// Central repo tests
|
||||
CentralRepoHashDb crDb = (CentralRepoHashDb) hashDb;
|
||||
if(this.centralRepoIndex != crDb.getCentralRepoIndex()){
|
||||
if(this.referenceSetID != crDb.getReferenceSetID()){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@ final class HashLookupSettings implements Serializable {
|
||||
} else {
|
||||
// For central repo, the name, index, and known files type should match
|
||||
return (this.hashSetName.equals(other.hashSetName)
|
||||
&& (this.centralRepoIndex == other.centralRepoIndex)
|
||||
&& (this.referenceSetID == other.referenceSetID)
|
||||
&& this.knownFilesType.equals(other.knownFilesType));
|
||||
}
|
||||
}
|
||||
@ -527,7 +527,7 @@ final class HashLookupSettings implements Serializable {
|
||||
hash = 89 * hash + Objects.hashCode(this.knownFilesType);
|
||||
hash = 89 * hash + Objects.hashCode(this.dbType);
|
||||
if(this.dbType.equals(DatabaseType.CENTRAL_REPOSITORY)){
|
||||
hash = 89 * hash + this.centralRepoIndex;
|
||||
hash = 89 * hash + this.referenceSetID;
|
||||
}
|
||||
|
||||
return hash;
|
||||
|
@ -66,7 +66,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
.getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingIndexStatusText");
|
||||
private final HashDbManager hashSetManager = HashDbManager.getInstance();
|
||||
private final HashSetTableModel hashSetTableModel = new HashSetTableModel();
|
||||
private final List<Integer> newCentralRepoIndices = new ArrayList<>();
|
||||
private final List<Integer> newReferenceSetIDs = new ArrayList<>();
|
||||
|
||||
public HashLookupSettingsPanel() {
|
||||
initComponents();
|
||||
@ -328,7 +328,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
|
||||
try {
|
||||
hashSetManager.save();
|
||||
newCentralRepoIndices.clear();
|
||||
newReferenceSetIDs.clear();
|
||||
} catch (HashDbManager.HashDbManagerException ex) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
JOptionPane.showMessageDialog(null, Bundle.HashLookupSettingsPanel_saveFail_message(), Bundle.HashLookupSettingsPanel_saveFail_title(), JOptionPane.ERROR_MESSAGE);
|
||||
@ -355,10 +355,10 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
*/
|
||||
if (IngestManager.getInstance().isIngestRunning() == false) {
|
||||
// Remove any new central repo hash sets from the database
|
||||
for(int index:newCentralRepoIndices){
|
||||
for(int refID:newReferenceSetIDs){
|
||||
try{
|
||||
if(EamDb.isEnabled()){
|
||||
EamDb.getInstance().deleteReferenceSet(index);
|
||||
EamDb.getInstance().deleteReferenceSet(refID);
|
||||
} else {
|
||||
// This is the case where the user imported a database, then switched over to the central
|
||||
// repo panel and disabled it before cancelling. We can't delete the database at this point.
|
||||
@ -971,8 +971,8 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
HashDatabase hashDb = new HashDbImportDatabaseDialog().getHashDatabase();
|
||||
if (null != hashDb) {
|
||||
if(hashDb instanceof CentralRepoHashDb){
|
||||
int newDbIndex = ((CentralRepoHashDb)hashDb).getCentralRepoIndex();
|
||||
newCentralRepoIndices.add(newDbIndex);
|
||||
int newReferenceSetID = ((CentralRepoHashDb)hashDb).getReferenceSetID();
|
||||
newReferenceSetIDs.add(newReferenceSetID);
|
||||
}
|
||||
|
||||
hashSetTableModel.refreshModel();
|
||||
|
@ -383,7 +383,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
private final boolean readOnly;
|
||||
private final File importFile;
|
||||
private final long totalLines;
|
||||
private int crIndex = -1;
|
||||
private int referenceSetID = -1;
|
||||
private HashDbManager.CentralRepoHashDb newHashDb = null;
|
||||
private final AtomicLong numLines = new AtomicLong();
|
||||
private String errorString = "";
|
||||
@ -447,7 +447,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
}
|
||||
|
||||
// Create an empty hashset in the central repository
|
||||
crIndex = EamDb.getInstance().newReferenceSet(orgId, hashSetName, version, knownStatus, readOnly);
|
||||
referenceSetID = EamDb.getInstance().newReferenceSet(orgId, hashSetName, version, knownStatus, readOnly);
|
||||
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
CorrelationAttribute.Type contentType = dbManager.getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); // get "FILES" type
|
||||
@ -468,7 +468,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
}
|
||||
|
||||
EamGlobalFileInstance eamGlobalFileInstance = new EamGlobalFileInstance(
|
||||
crIndex,
|
||||
referenceSetID,
|
||||
parts[0].toLowerCase(),
|
||||
knownStatus,
|
||||
"");
|
||||
@ -495,15 +495,15 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
return null;
|
||||
}
|
||||
|
||||
private void deleteIncompleteSet(int crIndex){
|
||||
if(crIndex >= 0){
|
||||
private void deleteIncompleteSet(int idToDelete){
|
||||
if(idToDelete >= 0){
|
||||
|
||||
// This can be slow on large reference sets
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
EamDb.getInstance().deleteReferenceSet(crIndex);
|
||||
EamDb.getInstance().deleteReferenceSet(idToDelete);
|
||||
} catch (EamDbException ex2){
|
||||
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error deleting incomplete hash set from central repository", ex2);
|
||||
}
|
||||
@ -517,7 +517,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
protected void done() {
|
||||
if(isCancelled()){
|
||||
// If the user hit cancel, delete this incomplete hash set from the central repo
|
||||
deleteIncompleteSet(crIndex);
|
||||
deleteIncompleteSet(referenceSetID);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -525,7 +525,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
get();
|
||||
try{
|
||||
newHashDb = HashDbManager.getInstance().addExistingCentralRepoHashSet(hashSetName, version,
|
||||
crIndex,
|
||||
referenceSetID,
|
||||
searchDuringIngest, sendIngestMessages, knownFilesType, readOnly);
|
||||
} catch (TskCoreException ex){
|
||||
JOptionPane.showMessageDialog(null, Bundle.ImportCentralRepoDbProgressDialog_addDbError_message());
|
||||
@ -533,9 +533,9 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Delete this incomplete hash set from the central repo
|
||||
if(crIndex >= 0){
|
||||
if(referenceSetID >= 0){
|
||||
try{
|
||||
EamDb.getInstance().deleteReferenceSet(crIndex);
|
||||
EamDb.getInstance().deleteReferenceSet(referenceSetID);
|
||||
} catch (EamDbException ex2){
|
||||
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error deleting incomplete hash set from central repository", ex);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user