mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 02:57:44 +00:00
Merge branch '3139_cr_hashes' into 3141_addHashes
This commit is contained in:
commit
b62100c588
@ -1252,16 +1252,21 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a reference set and all hashes contained in it.
|
* Remove a reference set and all hashes contained in it.
|
||||||
* @param centralRepoIndex
|
* @param referenceSetID
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteReferenceSet(int centralRepoIndex) throws EamDbException{
|
public void deleteReferenceSet(int referenceSetID) throws EamDbException{
|
||||||
deleteReferenceSetFiles(centralRepoIndex);
|
deleteReferenceSetFiles(referenceSetID);
|
||||||
deleteReferenceSetEntry(centralRepoIndex);
|
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();
|
Connection conn = connect();
|
||||||
|
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
@ -1269,7 +1274,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
preparedStatement = conn.prepareStatement(sql);
|
preparedStatement = conn.prepareStatement(sql);
|
||||||
preparedStatement.setInt(1, centralRepoIndex);
|
preparedStatement.setInt(1, referenceSetID);
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new EamDbException("Error deleting reference set", ex); // NON-NLS
|
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();
|
Connection conn = connect();
|
||||||
|
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
@ -1290,7 +1299,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
preparedStatement = conn.prepareStatement(String.format(sql, fileTableName));
|
preparedStatement = conn.prepareStatement(String.format(sql, fileTableName));
|
||||||
preparedStatement.setInt(1, centralRepoIndex);
|
preparedStatement.setInt(1, referenceSetID);
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new EamDbException("Error deleting files from reference set", ex); // NON-NLS
|
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.
|
* Check whether the given reference set exists in the central repository.
|
||||||
* @param centralRepoIndex
|
* @param referenceSetID
|
||||||
* @param hashSetName
|
* @param hashSetName
|
||||||
* @param version
|
* @param version
|
||||||
* @return
|
* @return true if a matching entry exists in the central repository
|
||||||
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean referenceSetIsValid(int centralRepoIndex, String hashSetName, String version) throws EamDbException{
|
public boolean referenceSetIsValid(int referenceSetID, String hashSetName, String version) throws EamDbException{
|
||||||
EamGlobalSet refSet = this.getReferenceSetByID(centralRepoIndex);
|
EamGlobalSet refSet = this.getReferenceSetByID(referenceSetID);
|
||||||
if(refSet == null){
|
if(refSet == null){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1320,11 +1330,11 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
/**
|
/**
|
||||||
* Check if the given hash is in a specific reference set
|
* Check if the given hash is in a specific reference set
|
||||||
* @param hash
|
* @param hash
|
||||||
* @param index
|
* @param referenceSetID
|
||||||
* @return
|
* @return true if the hash is found in the reference set
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isHashInReferenceSet(String hash, int index) throws EamDbException{
|
public boolean isHashInReferenceSet(String hash, int referenceSetID) throws EamDbException{
|
||||||
|
|
||||||
Connection conn = connect();
|
Connection conn = connect();
|
||||||
|
|
||||||
@ -1338,7 +1348,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
try {
|
try {
|
||||||
preparedStatement = conn.prepareStatement(String.format(sql, fileTableName));
|
preparedStatement = conn.prepareStatement(String.format(sql, fileTableName));
|
||||||
preparedStatement.setString(1, hash);
|
preparedStatement.setString(1, hash);
|
||||||
preparedStatement.setInt(2, index);
|
preparedStatement.setInt(2, referenceSetID);
|
||||||
resultSet = preparedStatement.executeQuery();
|
resultSet = preparedStatement.executeQuery();
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
matchingInstances = resultSet.getLong(1);
|
matchingInstances = resultSet.getLong(1);
|
||||||
@ -1499,27 +1509,27 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the organization associated with the given reference set.
|
* 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
|
* @return The organization object
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@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()));
|
return (getOrganizationByID(globalSet.getOrgID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Global Set
|
* Add a new reference set
|
||||||
*
|
*
|
||||||
* @param orgID
|
* @param orgID
|
||||||
* @param setName
|
* @param setName
|
||||||
* @param version
|
* @param version
|
||||||
* @param importDate
|
* @param importDate
|
||||||
* @return
|
* @return the reference set ID of the newly created set
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -1684,7 +1694,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
/**
|
/**
|
||||||
* Get all reference sets
|
* Get all reference sets
|
||||||
*
|
*
|
||||||
* @return The global set associated with the ID
|
* @return List of all reference sets in the central repository
|
||||||
*
|
*
|
||||||
* @throws EamDbException
|
* @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
|
* Check whether a reference set with the given name/version is in the central repo
|
||||||
* @param hashSetName
|
* @param hashSetName
|
||||||
* @param version
|
* @param version
|
||||||
* @return
|
* @return true if a matching set is found
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,12 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.sleuthkit.datamodel.TskData;
|
import org.sleuthkit.datamodel.TskData;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main interface for interacting with the database
|
* Main interface for interacting with the database
|
||||||
@ -365,25 +363,26 @@ public interface EamDb {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a reference set and all hashes contained in it.
|
* Remove a reference set and all hashes contained in it.
|
||||||
* @param centralRepoIndex
|
* @param referenceSetID
|
||||||
* @throws EamDbException
|
* @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.
|
* Check whether the given reference set exists in the central repository.
|
||||||
* @param centralRepoIndex
|
* @param referenceSetID
|
||||||
* @param hashSetName
|
* @param hashSetName
|
||||||
* @param version
|
* @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
|
* Check whether a reference set with the given name/version is in the central repo
|
||||||
* @param hashSetName
|
* @param hashSetName
|
||||||
* @param version
|
* @param version
|
||||||
* @return
|
* @return true if a matching set is found
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
public boolean referenceSetExists(String hashSetName, String version) throws EamDbException;
|
public boolean referenceSetExists(String hashSetName, String version) throws EamDbException;
|
||||||
@ -391,10 +390,10 @@ public interface EamDb {
|
|||||||
/**
|
/**
|
||||||
* Check if the given hash is in a specific reference set
|
* Check if the given hash is in a specific reference set
|
||||||
* @param hash
|
* @param hash
|
||||||
* @param index
|
* @param referenceSetID
|
||||||
* @return
|
* @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?
|
* Is the artifact known as bad according to the reference entries?
|
||||||
@ -439,11 +438,11 @@ public interface EamDb {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the organization associated with the given reference set.
|
* 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
|
* @return The organization object
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
EamOrganization getReferenceSetOrganization(int globalSetID) throws EamDbException;
|
EamOrganization getReferenceSetOrganization(int referenceSetID) throws EamDbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing organization.
|
* Update an existing organization.
|
||||||
@ -476,13 +475,13 @@ public interface EamDb {
|
|||||||
int newReferencelSet(EamGlobalSet eamGlobalSet) throws EamDbException;
|
int newReferencelSet(EamGlobalSet eamGlobalSet) throws EamDbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Global Set
|
* Add a new reference set
|
||||||
*
|
*
|
||||||
* @param orgID
|
* @param orgID
|
||||||
* @param setName
|
* @param setName
|
||||||
* @param version
|
* @param version
|
||||||
*
|
* @param importDate
|
||||||
* @return The ID of the new global set
|
* @return the reference set ID of the newly created set
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
int newReferenceSet(int orgID, String setName, String version, TskData.FileKnown knownStatus,
|
int newReferenceSet(int orgID, String setName, String version, TskData.FileKnown knownStatus,
|
||||||
@ -502,7 +501,7 @@ public interface EamDb {
|
|||||||
/**
|
/**
|
||||||
* Get all reference sets
|
* Get all reference sets
|
||||||
*
|
*
|
||||||
* @return The global set associated with the ID
|
* @return List of all reference sets in the central repository
|
||||||
*
|
*
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
|
@ -637,14 +637,14 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a reference set and all hashes contained in it.
|
* Remove a reference set and all hashes contained in it.
|
||||||
* @param centralRepoIndex
|
* @param referenceSetID
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void deleteReferenceSet(int centralRepoIndex) throws EamDbException{
|
public void deleteReferenceSet(int referenceSetID) throws EamDbException{
|
||||||
try{
|
try{
|
||||||
acquireExclusiveLock();
|
acquireExclusiveLock();
|
||||||
super.deleteReferenceSet(centralRepoIndex);
|
super.deleteReferenceSet(referenceSetID);
|
||||||
} finally {
|
} finally {
|
||||||
releaseExclusiveLock();
|
releaseExclusiveLock();
|
||||||
}
|
}
|
||||||
@ -653,14 +653,14 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
|||||||
/**
|
/**
|
||||||
* Check if the given hash is in a specific reference set
|
* Check if the given hash is in a specific reference set
|
||||||
* @param hash
|
* @param hash
|
||||||
* @param index
|
* @param referenceSetID
|
||||||
* @return
|
* @return true if the hash is found in the reference set
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isHashInReferenceSet(String hash, int index) throws EamDbException{
|
public boolean isHashInReferenceSet(String hash, int referenceSetID) throws EamDbException{
|
||||||
try{
|
try{
|
||||||
acquireSharedLock();
|
acquireSharedLock();
|
||||||
return super.isHashInReferenceSet(hash, index);
|
return super.isHashInReferenceSet(hash, referenceSetID);
|
||||||
} finally {
|
} finally {
|
||||||
releaseSharedLock();
|
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
|
* Check whether a reference set with the given name/version is in the central repo
|
||||||
* @param hashSetName
|
* @param hashSetName
|
||||||
* @param version
|
* @param version
|
||||||
* @return
|
* @return true if a matching set is found
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -816,7 +816,7 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
|||||||
/**
|
/**
|
||||||
* Get all reference sets
|
* Get all reference sets
|
||||||
*
|
*
|
||||||
* @return The global set associated with the ID
|
* @return List of all reference sets in the central repository
|
||||||
*
|
*
|
||||||
* @throws EamDbException
|
* @throws EamDbException
|
||||||
*/
|
*/
|
||||||
|
@ -90,6 +90,7 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
@NbBundle.Messages({"HashDbImportDatabaseDialog.centralRepoExtFilter.text=Hash Database File (.idx only)"})
|
@NbBundle.Messages({"HashDbImportDatabaseDialog.centralRepoExtFilter.text=Hash Database File (.idx only)"})
|
||||||
private void updateFileChooserFilter() {
|
private void updateFileChooserFilter() {
|
||||||
|
fileChooser.resetChoosableFileFilters();
|
||||||
if(centralRepoRadioButton.isSelected()){
|
if(centralRepoRadioButton.isSelected()){
|
||||||
String[] EXTENSION = new String[]{"idx"}; //NON-NLS
|
String[] EXTENSION = new String[]{"idx"}; //NON-NLS
|
||||||
FileNameExtensionFilter filter = new FileNameExtensionFilter(
|
FileNameExtensionFilter filter = new FileNameExtensionFilter(
|
||||||
|
@ -284,7 +284,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
return hashDb;
|
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 searchDuringIngest, boolean sendIngestMessages, HashDb.KnownFilesType knownFilesType,
|
||||||
boolean readOnly) throws TskCoreException{
|
boolean readOnly) throws TskCoreException{
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
throw new TskCoreException("Could not load central repository database " + hashSetName + " - central repository is not enabled");
|
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);
|
sendIngestMessages, knownFilesType, readOnly);
|
||||||
|
|
||||||
if(! db.isValid()){
|
if(! db.isValid()){
|
||||||
@ -636,7 +636,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
} else {
|
} else {
|
||||||
if(EamDb.isEnabled()){
|
if(EamDb.isEnabled()){
|
||||||
addExistingCentralRepoHashSet(hashDbInfo.getHashSetName(), hashDbInfo.getVersion(),
|
addExistingCentralRepoHashSet(hashDbInfo.getHashSetName(), hashDbInfo.getVersion(),
|
||||||
hashDbInfo.getCentralRepoIndex(),
|
hashDbInfo.getReferenceSetID(),
|
||||||
hashDbInfo.getSearchDuringIngest(), hashDbInfo.getSendIngestMessages(),
|
hashDbInfo.getSearchDuringIngest(), hashDbInfo.getSendIngestMessages(),
|
||||||
hashDbInfo.getKnownFilesType(), hashDbInfo.isReadOnly());
|
hashDbInfo.getKnownFilesType(), hashDbInfo.isReadOnly());
|
||||||
}
|
}
|
||||||
@ -690,7 +690,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
for(HashDbInfo hashDbInfo : crHashDbInfoList) {
|
for(HashDbInfo hashDbInfo : crHashDbInfoList) {
|
||||||
if(hashDbInfoIsNew(hashDbInfo)){
|
if(hashDbInfoIsNew(hashDbInfo)){
|
||||||
addExistingCentralRepoHashSet(hashDbInfo.getHashSetName(), hashDbInfo.getVersion(),
|
addExistingCentralRepoHashSet(hashDbInfo.getHashSetName(), hashDbInfo.getVersion(),
|
||||||
hashDbInfo.getCentralRepoIndex(),
|
hashDbInfo.getReferenceSetID(),
|
||||||
hashDbInfo.getSearchDuringIngest(), hashDbInfo.getSendIngestMessages(), hashDbInfo.getKnownFilesType(),
|
hashDbInfo.getSearchDuringIngest(), hashDbInfo.getSendIngestMessages(), hashDbInfo.getKnownFilesType(),
|
||||||
hashDbInfo.isReadOnly());
|
hashDbInfo.isReadOnly());
|
||||||
}
|
}
|
||||||
@ -1153,27 +1153,27 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
private boolean searchDuringIngest;
|
private boolean searchDuringIngest;
|
||||||
private boolean sendIngestMessages;
|
private boolean sendIngestMessages;
|
||||||
private final HashDb.KnownFilesType knownFilesType;
|
private final HashDb.KnownFilesType knownFilesType;
|
||||||
private final int centralRepoIndex;
|
private final int referenceSetID;
|
||||||
private final String version;
|
private final String version;
|
||||||
private String orgName;
|
private String orgName;
|
||||||
private final boolean readOnly;
|
private final boolean readOnly;
|
||||||
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
||||||
|
|
||||||
@Messages({"HashDbManager.CentralRepoHashDb.orgError=Error loading organization"})
|
@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 useForIngest, boolean sendHitMessages, HashDb.KnownFilesType knownFilesType,
|
||||||
boolean readOnly)
|
boolean readOnly)
|
||||||
throws TskCoreException{
|
throws TskCoreException{
|
||||||
this.hashSetName = hashSetName;
|
this.hashSetName = hashSetName;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.centralRepoIndex = centralRepoIndex;
|
this.referenceSetID = referenceSetID;
|
||||||
this.searchDuringIngest = useForIngest;
|
this.searchDuringIngest = useForIngest;
|
||||||
this.sendIngestMessages = sendHitMessages;
|
this.sendIngestMessages = sendHitMessages;
|
||||||
this.knownFilesType = knownFilesType;
|
this.knownFilesType = knownFilesType;
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
|
|
||||||
try{
|
try{
|
||||||
orgName = EamDb.getInstance().getReferenceSetOrganization(centralRepoIndex).getName();
|
orgName = EamDb.getInstance().getReferenceSetOrganization(referenceSetID).getName();
|
||||||
} catch (EamDbException ex){
|
} catch (EamDbException ex){
|
||||||
Logger.getLogger(HashDb.class.getName()).log(Level.SEVERE, "Error looking up central repository organization", ex); //NON-NLS
|
Logger.getLogger(HashDb.class.getName()).log(Level.SEVERE, "Error looking up central repository organization", ex); //NON-NLS
|
||||||
orgName = Bundle.HashDbManager_CentralRepoHashDb_orgError();
|
orgName = Bundle.HashDbManager_CentralRepoHashDb_orgError();
|
||||||
@ -1228,8 +1228,8 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
return orgName;
|
return orgName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCentralRepoIndex(){
|
public int getReferenceSetID(){
|
||||||
return centralRepoIndex;
|
return referenceSetID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1381,7 +1381,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
AbstractFile file = (AbstractFile) content;
|
AbstractFile file = (AbstractFile) content;
|
||||||
if (null != file.getMd5Hash()) {
|
if (null != file.getMd5Hash()) {
|
||||||
try{
|
try{
|
||||||
return EamDb.getInstance().isHashInReferenceSet(file.getMd5Hash(), this.centralRepoIndex);
|
return EamDb.getInstance().isHashInReferenceSet(file.getMd5Hash(), this.referenceSetID);
|
||||||
} catch (EamDbException ex){
|
} catch (EamDbException ex){
|
||||||
Logger.getLogger(HashDb.class.getName()).log(Level.SEVERE, "Error performing central reposiotry hash lookup", ex); //NON-NLS
|
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);
|
throw new TskCoreException("Error performing central reposiotry hash lookup", ex);
|
||||||
@ -1409,7 +1409,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
AbstractFile file = (AbstractFile) content;
|
AbstractFile file = (AbstractFile) content;
|
||||||
if (null != file.getMd5Hash()) {
|
if (null != file.getMd5Hash()) {
|
||||||
try{
|
try{
|
||||||
if(EamDb.getInstance().isHashInReferenceSet(file.getMd5Hash(), this.centralRepoIndex)){
|
if(EamDb.getInstance().isHashInReferenceSet(file.getMd5Hash(), this.referenceSetID)){
|
||||||
// Make a bare-bones HashHitInfo for now
|
// Make a bare-bones HashHitInfo for now
|
||||||
result = new HashHitInfo(file.getMd5Hash(), "", "");
|
result = new HashHitInfo(file.getMd5Hash(), "", "");
|
||||||
}
|
}
|
||||||
@ -1434,7 +1434,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
return EamDb.getInstance().referenceSetIsValid(this.centralRepoIndex, this.hashSetName, this.version);
|
return EamDb.getInstance().referenceSetIsValid(this.referenceSetID, this.hashSetName, this.version);
|
||||||
} catch (EamDbException ex){
|
} catch (EamDbException ex){
|
||||||
Logger.getLogger(CentralRepoHashDb.class.getName()).log(Level.SEVERE, "Error validating hash database " + hashSetName, ex); //NON-NLS
|
Logger.getLogger(CentralRepoHashDb.class.getName()).log(Level.SEVERE, "Error validating hash database " + hashSetName, ex); //NON-NLS
|
||||||
return false;
|
return false;
|
||||||
@ -1462,7 +1462,7 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
int code = 23;
|
int code = 23;
|
||||||
code = 47 * code + Objects.hashCode(this.hashSetName);
|
code = 47 * code + Objects.hashCode(this.hashSetName);
|
||||||
code = 47 * code + Objects.hashCode(this.version);
|
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);
|
code = 47 * code + Objects.hashCode(this.knownFilesType);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ final class HashLookupSettings implements Serializable {
|
|||||||
private final String path;
|
private final String path;
|
||||||
private final String version;
|
private final String version;
|
||||||
private final boolean readOnly;
|
private final boolean readOnly;
|
||||||
private final int centralRepoIndex;
|
private final int referenceSetID;
|
||||||
private DatabaseType dbType;
|
private DatabaseType dbType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -324,16 +324,16 @@ final class HashLookupSettings implements Serializable {
|
|||||||
this.searchDuringIngest = searchDuringIngest;
|
this.searchDuringIngest = searchDuringIngest;
|
||||||
this.sendIngestMessages = sendIngestMessages;
|
this.sendIngestMessages = sendIngestMessages;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.centralRepoIndex = -1;
|
this.referenceSetID = -1;
|
||||||
this.version = "";
|
this.version = "";
|
||||||
this.readOnly = false;
|
this.readOnly = false;
|
||||||
this.dbType = DatabaseType.FILE;
|
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.hashSetName = hashSetName;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.centralRepoIndex = centralRepoIndex;
|
this.referenceSetID = referenceSetID;
|
||||||
this.knownFilesType = knownFilesType;
|
this.knownFilesType = knownFilesType;
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
this.searchDuringIngest = searchDuringIngest;
|
this.searchDuringIngest = searchDuringIngest;
|
||||||
@ -349,7 +349,7 @@ final class HashLookupSettings implements Serializable {
|
|||||||
this.knownFilesType = fileTypeDb.getKnownFilesType();
|
this.knownFilesType = fileTypeDb.getKnownFilesType();
|
||||||
this.searchDuringIngest = fileTypeDb.getSearchDuringIngest();
|
this.searchDuringIngest = fileTypeDb.getSearchDuringIngest();
|
||||||
this.sendIngestMessages = fileTypeDb.getSendIngestMessages();
|
this.sendIngestMessages = fileTypeDb.getSendIngestMessages();
|
||||||
this.centralRepoIndex = -1;
|
this.referenceSetID = -1;
|
||||||
this.version = "";
|
this.version = "";
|
||||||
this.readOnly = false;
|
this.readOnly = false;
|
||||||
this.dbType = DatabaseType.FILE;
|
this.dbType = DatabaseType.FILE;
|
||||||
@ -367,7 +367,7 @@ final class HashLookupSettings implements Serializable {
|
|||||||
this.searchDuringIngest = centralRepoDb.getSearchDuringIngest();
|
this.searchDuringIngest = centralRepoDb.getSearchDuringIngest();
|
||||||
this.sendIngestMessages = centralRepoDb.getSendIngestMessages();
|
this.sendIngestMessages = centralRepoDb.getSendIngestMessages();
|
||||||
this.path = "";
|
this.path = "";
|
||||||
this.centralRepoIndex = centralRepoDb.getCentralRepoIndex();
|
this.referenceSetID = centralRepoDb.getReferenceSetID();
|
||||||
this.dbType = DatabaseType.CENTRAL_REPOSITORY;
|
this.dbType = DatabaseType.CENTRAL_REPOSITORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,8 +441,8 @@ final class HashLookupSettings implements Serializable {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCentralRepoIndex(){
|
int getReferenceSetID(){
|
||||||
return centralRepoIndex;
|
return referenceSetID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -481,7 +481,7 @@ final class HashLookupSettings implements Serializable {
|
|||||||
|
|
||||||
// Central repo tests
|
// Central repo tests
|
||||||
CentralRepoHashDb crDb = (CentralRepoHashDb) hashDb;
|
CentralRepoHashDb crDb = (CentralRepoHashDb) hashDb;
|
||||||
if(this.centralRepoIndex != crDb.getCentralRepoIndex()){
|
if(this.referenceSetID != crDb.getReferenceSetID()){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +515,7 @@ final class HashLookupSettings implements Serializable {
|
|||||||
} else {
|
} else {
|
||||||
// For central repo, the name, index, and known files type should match
|
// For central repo, the name, index, and known files type should match
|
||||||
return (this.hashSetName.equals(other.hashSetName)
|
return (this.hashSetName.equals(other.hashSetName)
|
||||||
&& (this.centralRepoIndex == other.centralRepoIndex)
|
&& (this.referenceSetID == other.referenceSetID)
|
||||||
&& this.knownFilesType.equals(other.knownFilesType));
|
&& 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.knownFilesType);
|
||||||
hash = 89 * hash + Objects.hashCode(this.dbType);
|
hash = 89 * hash + Objects.hashCode(this.dbType);
|
||||||
if(this.dbType.equals(DatabaseType.CENTRAL_REPOSITORY)){
|
if(this.dbType.equals(DatabaseType.CENTRAL_REPOSITORY)){
|
||||||
hash = 89 * hash + this.centralRepoIndex;
|
hash = 89 * hash + this.referenceSetID;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
|
@ -66,7 +66,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
|||||||
.getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingIndexStatusText");
|
.getMessage(HashLookupSettingsPanel.class, "HashDbConfigPanel.errorGettingIndexStatusText");
|
||||||
private final HashDbManager hashSetManager = HashDbManager.getInstance();
|
private final HashDbManager hashSetManager = HashDbManager.getInstance();
|
||||||
private final HashSetTableModel hashSetTableModel = new HashSetTableModel();
|
private final HashSetTableModel hashSetTableModel = new HashSetTableModel();
|
||||||
private final List<Integer> newCentralRepoIndices = new ArrayList<>();
|
private final List<Integer> newReferenceSetIDs = new ArrayList<>();
|
||||||
|
|
||||||
public HashLookupSettingsPanel() {
|
public HashLookupSettingsPanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
@ -328,7 +328,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
hashSetManager.save();
|
hashSetManager.save();
|
||||||
newCentralRepoIndices.clear();
|
newReferenceSetIDs.clear();
|
||||||
} catch (HashDbManager.HashDbManagerException ex) {
|
} catch (HashDbManager.HashDbManagerException ex) {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
JOptionPane.showMessageDialog(null, Bundle.HashLookupSettingsPanel_saveFail_message(), Bundle.HashLookupSettingsPanel_saveFail_title(), JOptionPane.ERROR_MESSAGE);
|
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) {
|
if (IngestManager.getInstance().isIngestRunning() == false) {
|
||||||
// Remove any new central repo hash sets from the database
|
// Remove any new central repo hash sets from the database
|
||||||
for(int index:newCentralRepoIndices){
|
for(int refID:newReferenceSetIDs){
|
||||||
try{
|
try{
|
||||||
if(EamDb.isEnabled()){
|
if(EamDb.isEnabled()){
|
||||||
EamDb.getInstance().deleteReferenceSet(index);
|
EamDb.getInstance().deleteReferenceSet(refID);
|
||||||
} else {
|
} else {
|
||||||
// This is the case where the user imported a database, then switched over to the central
|
// 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.
|
// repo panel and disabled it before cancelling. We can't delete the database at this point.
|
||||||
@ -976,8 +976,8 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
|||||||
HashDatabase hashDb = new HashDbImportDatabaseDialog().getHashDatabase();
|
HashDatabase hashDb = new HashDbImportDatabaseDialog().getHashDatabase();
|
||||||
if (null != hashDb) {
|
if (null != hashDb) {
|
||||||
if(hashDb instanceof CentralRepoHashDb){
|
if(hashDb instanceof CentralRepoHashDb){
|
||||||
int newDbIndex = ((CentralRepoHashDb)hashDb).getCentralRepoIndex();
|
int newReferenceSetID = ((CentralRepoHashDb)hashDb).getReferenceSetID();
|
||||||
newCentralRepoIndices.add(newDbIndex);
|
newReferenceSetIDs.add(newReferenceSetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashSetTableModel.refreshModel();
|
hashSetTableModel.refreshModel();
|
||||||
|
@ -143,7 +143,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
|||||||
private final boolean readOnly;
|
private final boolean readOnly;
|
||||||
private final File importFile;
|
private final File importFile;
|
||||||
private final long totalLines;
|
private final long totalLines;
|
||||||
private int crIndex = -1;
|
private int referenceSetID = -1;
|
||||||
private HashDbManager.CentralRepoHashDb newHashDb = null;
|
private HashDbManager.CentralRepoHashDb newHashDb = null;
|
||||||
private final AtomicLong numLines = new AtomicLong();
|
private final AtomicLong numLines = new AtomicLong();
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create an empty hashset in the central repository
|
// 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();
|
EamDb dbManager = EamDb.getInstance();
|
||||||
CorrelationAttribute.Type contentType = dbManager.getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); // get "FILES" type
|
CorrelationAttribute.Type contentType = dbManager.getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID); // get "FILES" type
|
||||||
@ -222,7 +222,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
|||||||
}
|
}
|
||||||
|
|
||||||
EamGlobalFileInstance eamGlobalFileInstance = new EamGlobalFileInstance(
|
EamGlobalFileInstance eamGlobalFileInstance = new EamGlobalFileInstance(
|
||||||
crIndex,
|
referenceSetID,
|
||||||
parts[0].toLowerCase(),
|
parts[0].toLowerCase(),
|
||||||
knownStatus,
|
knownStatus,
|
||||||
"");
|
"");
|
||||||
@ -249,15 +249,15 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteIncompleteSet(int crIndex){
|
private void deleteIncompleteSet(int idToDelete){
|
||||||
if(crIndex >= 0){
|
if(idToDelete >= 0){
|
||||||
|
|
||||||
// This can be slow on large reference sets
|
// This can be slow on large reference sets
|
||||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try{
|
try{
|
||||||
EamDb.getInstance().deleteReferenceSet(crIndex);
|
EamDb.getInstance().deleteReferenceSet(idToDelete);
|
||||||
} catch (EamDbException ex2){
|
} catch (EamDbException ex2){
|
||||||
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error deleting incomplete hash set from central repository", ex2);
|
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error deleting incomplete hash set from central repository", ex2);
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
|||||||
protected void done() {
|
protected void done() {
|
||||||
if(isCancelled()){
|
if(isCancelled()){
|
||||||
// If the user hit cancel, delete this incomplete hash set from the central repo
|
// If the user hit cancel, delete this incomplete hash set from the central repo
|
||||||
deleteIncompleteSet(crIndex);
|
deleteIncompleteSet(referenceSetID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
|||||||
get();
|
get();
|
||||||
try{
|
try{
|
||||||
newHashDb = HashDbManager.getInstance().addExistingCentralRepoHashSet(hashSetName, version,
|
newHashDb = HashDbManager.getInstance().addExistingCentralRepoHashSet(hashSetName, version,
|
||||||
crIndex,
|
referenceSetID,
|
||||||
searchDuringIngest, sendIngestMessages, knownFilesType, readOnly);
|
searchDuringIngest, sendIngestMessages, knownFilesType, readOnly);
|
||||||
} catch (TskCoreException ex){
|
} catch (TskCoreException ex){
|
||||||
JOptionPane.showMessageDialog(null, Bundle.ImportCentralRepoDbProgressDialog_addDbError_message());
|
JOptionPane.showMessageDialog(null, Bundle.ImportCentralRepoDbProgressDialog_addDbError_message());
|
||||||
@ -287,9 +287,9 @@ class ImportCentralRepoDbProgressDialog extends javax.swing.JDialog implements P
|
|||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// Delete this incomplete hash set from the central repo
|
// Delete this incomplete hash set from the central repo
|
||||||
if(crIndex >= 0){
|
if(referenceSetID >= 0){
|
||||||
try{
|
try{
|
||||||
EamDb.getInstance().deleteReferenceSet(crIndex);
|
EamDb.getInstance().deleteReferenceSet(referenceSetID);
|
||||||
} catch (EamDbException ex2){
|
} catch (EamDbException ex2){
|
||||||
Logger.getLogger(ImportCentralRepoDbProgressDialog.class.getName()).log(Level.SEVERE, "Error deleting incomplete hash set from central repository", ex);
|
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