mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +00:00
Persist CR data on hash setters.
This commit is contained in:
parent
c6e73b31cc
commit
61f2112bcc
@ -826,7 +826,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates an existing data source in the database
|
* Updates an existing data source in the database.
|
||||||
*
|
*
|
||||||
* @param eamDataSource The data source to update
|
* @param eamDataSource The data source to update
|
||||||
*/
|
*/
|
||||||
@ -862,6 +862,73 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
EamDbUtil.closeConnection(conn);
|
EamDbUtil.closeConnection(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the MD5 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws EamDbException {
|
||||||
|
updateDataSourceStringValue(eamDataSource, "md5", eamDataSource.getMd5());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the SHA-1 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws EamDbException {
|
||||||
|
updateDataSourceStringValue(eamDataSource, "sha1", eamDataSource.getSha1());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the SHA-256 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws EamDbException {
|
||||||
|
updateDataSourceStringValue(eamDataSource, "sha256", eamDataSource.getSha256());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the specified value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
* @param column The name of the column to be updated
|
||||||
|
* @param value The value to assign to the specified column
|
||||||
|
*/
|
||||||
|
private void updateDataSourceStringValue(CorrelationDataSource eamDataSource, String column, String value) throws EamDbException {
|
||||||
|
if (eamDataSource == null) {
|
||||||
|
throw new EamDbException("Correlation data source is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
Connection conn = connect();
|
||||||
|
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
String sql = "UPDATE data_sources "
|
||||||
|
+ "SET " + column + "=? "
|
||||||
|
+ "WHERE id=?";
|
||||||
|
|
||||||
|
try {
|
||||||
|
preparedStatement = conn.prepareStatement(sql);
|
||||||
|
|
||||||
|
preparedStatement.setString(1, value);
|
||||||
|
preparedStatement.setInt(2, eamDataSource.getID());
|
||||||
|
|
||||||
|
preparedStatement.executeUpdate();
|
||||||
|
//update the case in the cache
|
||||||
|
dataSourceCacheByDsObjectId.put(getDataSourceByDSObjectIdCacheKey(eamDataSource.getCaseID(), eamDataSource.getDataSourceObjectID()), eamDataSource);
|
||||||
|
dataSourceCacheById.put(getDataSourceByIdCacheKey(eamDataSource.getCaseID(), eamDataSource.getID()), eamDataSource);
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
throw new EamDbException("Error updating data source.", ex); // NON-NLS
|
||||||
|
} finally {
|
||||||
|
EamDbUtil.closeStatement(preparedStatement);
|
||||||
|
EamDbUtil.closeConnection(conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts new Artifact(s) into the database. Should add associated Case and
|
* Inserts new Artifact(s) into the database. Should add associated Case and
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
@ -229,15 +230,20 @@ public class CorrelationDataSource implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the MD5 hash value.
|
* Set the MD5 hash value and persist to the Central Repository if available.
|
||||||
*
|
|
||||||
* Note: This does not add the hash value to Central Repository. A method,
|
|
||||||
* such as EamDb.updateDataSource(), can be called to persist hash values.
|
|
||||||
*
|
*
|
||||||
* @param md5Hash The MD5 hash value.
|
* @param md5Hash The MD5 hash value.
|
||||||
|
*
|
||||||
|
* @exception EamDbException If there's an issue updating the Central
|
||||||
|
* Repository.
|
||||||
*/
|
*/
|
||||||
public void setMd5(String md5Hash) {
|
public void setMd5(String md5Hash) throws EamDbException {
|
||||||
this.md5Hash = md5Hash;
|
this.md5Hash = md5Hash;
|
||||||
|
|
||||||
|
boolean useCR = EamDb.isEnabled();
|
||||||
|
if (useCR) {
|
||||||
|
EamDb.getInstance().updateDataSourceMd5Hash(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -248,15 +254,18 @@ public class CorrelationDataSource implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the SHA-1 hash value.
|
* Set the SHA-1 hash value and persist to the Central Repository if
|
||||||
*
|
* available.
|
||||||
* Note: This does not add the hash value to Central Repository. A method,
|
|
||||||
* such as EamDb.updateDataSource(), can be called to persist hash values.
|
|
||||||
*
|
*
|
||||||
* @param sha1Hash The SHA-1 hash value.
|
* @param sha1Hash The SHA-1 hash value.
|
||||||
*/
|
*/
|
||||||
public void setSha1(String sha1Hash) {
|
public void setSha1(String sha1Hash) throws EamDbException {
|
||||||
this.sha1Hash = sha1Hash;
|
this.sha1Hash = sha1Hash;
|
||||||
|
|
||||||
|
boolean useCR = EamDb.isEnabled();
|
||||||
|
if (useCR) {
|
||||||
|
EamDb.getInstance().updateDataSourceSha1Hash(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -267,14 +276,17 @@ public class CorrelationDataSource implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the SHA-256 hash value.
|
* Set the SHA-256 hash value and persist to the Central Repository if
|
||||||
*
|
* available.
|
||||||
* Note: This does not add the hash value to Central Repository. A method,
|
|
||||||
* such as EamDb.updateDataSource(), can be called to persist hash values.
|
|
||||||
*
|
*
|
||||||
* @param sha256Hash The SHA-256 hash value.
|
* @param sha256Hash The SHA-256 hash value.
|
||||||
*/
|
*/
|
||||||
public void setSha256(String sha256Hash) {
|
public void setSha256(String sha256Hash) throws EamDbException {
|
||||||
this.sha256Hash = sha256Hash;
|
this.sha256Hash = sha256Hash;
|
||||||
|
|
||||||
|
boolean useCR = EamDb.isEnabled();
|
||||||
|
if (useCR) {
|
||||||
|
EamDb.getInstance().updateDataSourceSha256Hash(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,6 +211,27 @@ public interface EamDb {
|
|||||||
* @param eamDataSource The data source to update
|
* @param eamDataSource The data source to update
|
||||||
*/
|
*/
|
||||||
void updateDataSource(CorrelationDataSource eamDataSource) throws EamDbException;
|
void updateDataSource(CorrelationDataSource eamDataSource) throws EamDbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the MD5 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws EamDbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the SHA-1 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws EamDbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the SHA-256 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws EamDbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves Data Source details based on data source device ID
|
* Retrieves Data Source details based on data source device ID
|
||||||
|
@ -448,6 +448,51 @@ final class SqliteEamDb extends AbstractSqlEamDb {
|
|||||||
releaseExclusiveLock();
|
releaseExclusiveLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the MD5 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateDataSourceMd5Hash(CorrelationDataSource eamDataSource) throws EamDbException {
|
||||||
|
try {
|
||||||
|
acquireExclusiveLock();
|
||||||
|
super.updateDataSourceMd5Hash(eamDataSource);
|
||||||
|
} finally {
|
||||||
|
releaseExclusiveLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the SHA-1 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateDataSourceSha1Hash(CorrelationDataSource eamDataSource) throws EamDbException {
|
||||||
|
try {
|
||||||
|
acquireExclusiveLock();
|
||||||
|
super.updateDataSourceSha1Hash(eamDataSource);
|
||||||
|
} finally {
|
||||||
|
releaseExclusiveLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the SHA-256 hash value in an existing data source in the database.
|
||||||
|
*
|
||||||
|
* @param eamDataSource The data source to update
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateDataSourceSha256Hash(CorrelationDataSource eamDataSource) throws EamDbException {
|
||||||
|
try {
|
||||||
|
acquireExclusiveLock();
|
||||||
|
super.updateDataSourceSha256Hash(eamDataSource);
|
||||||
|
} finally {
|
||||||
|
releaseExclusiveLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts new Artifact(s) into the database. Should add associated Case and
|
* Inserts new Artifact(s) into the database. Should add associated Case and
|
||||||
|
@ -401,7 +401,6 @@ public class IngestEventsListener {
|
|||||||
correlationDataSource.setMd5(imageMd5Hash);
|
correlationDataSource.setMd5(imageMd5Hash);
|
||||||
correlationDataSource.setSha1(imageSha1Hash);
|
correlationDataSource.setSha1(imageSha1Hash);
|
||||||
correlationDataSource.setSha256(imageSha256Hash);
|
correlationDataSource.setSha256(imageSha256Hash);
|
||||||
dbManager.updateDataSource(correlationDataSource);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user