mirror of
https://github.com/elisspace/autopsy.git
synced 2026-10-03 07:49:52 +00:00
Merge conflicts fixed.
This commit is contained in:
@@ -83,7 +83,7 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
||||
*/
|
||||
// @@@ This user interface has some significant usability issues and needs
|
||||
// to be reworked.
|
||||
private class TagMenu extends JMenu {
|
||||
private final class TagMenu extends JMenu {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -99,13 +99,8 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
||||
Logger.getLogger(TagsManager.class.getName()).log(Level.SEVERE, "Failed to get tag names", ex); //NON-NLS
|
||||
}
|
||||
|
||||
// Create a "Quick Tag" sub-menu.
|
||||
JMenu quickTagMenu = new JMenu(NbBundle.getMessage(this.getClass(), "AddTagAction.quickTag"));
|
||||
add(quickTagMenu);
|
||||
|
||||
// Each tag name in the current set of tags gets its own menu item in
|
||||
// the "Quick Tags" sub-menu. Selecting one of these menu items adds
|
||||
// a tag with the associated tag name.
|
||||
// Create a menu item for each of the existing and visible tags.
|
||||
// Selecting one of these menu items adds a tag with the associated tag name.
|
||||
if (null != tagNamesMap && !tagNamesMap.isEmpty()) {
|
||||
for (Map.Entry<String, TagName> entry : tagNamesMap.entrySet()) {
|
||||
String tagDisplayName = entry.getKey();
|
||||
@@ -119,28 +114,15 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
||||
tagNameItem.addActionListener((ActionEvent e) -> {
|
||||
getAndAddTag(entry.getKey(), entry.getValue(), NO_COMMENT);
|
||||
});
|
||||
quickTagMenu.add(tagNameItem);
|
||||
|
||||
add(tagNameItem);
|
||||
}
|
||||
} else {
|
||||
JMenuItem empty = new JMenuItem(NbBundle.getMessage(this.getClass(), "AddTagAction.noTags"));
|
||||
empty.setEnabled(false);
|
||||
quickTagMenu.add(empty);
|
||||
}
|
||||
|
||||
if (getItemCount() > 0) {
|
||||
addSeparator();
|
||||
}
|
||||
|
||||
quickTagMenu.addSeparator();
|
||||
|
||||
// The "Quick Tag" menu also gets an "Choose Tag..." menu item.
|
||||
// Selecting this item initiates a dialog that can be used to create
|
||||
// or select a tag name and adds a tag with the resulting name.
|
||||
JMenuItem newTagMenuItem = new JMenuItem(NbBundle.getMessage(this.getClass(), "AddTagAction.newTag"));
|
||||
newTagMenuItem.addActionListener((ActionEvent e) -> {
|
||||
TagName tagName = GetTagNameDialog.doDialog();
|
||||
if (null != tagName) {
|
||||
addTag(tagName, NO_COMMENT);
|
||||
}
|
||||
});
|
||||
quickTagMenu.add(newTagMenuItem);
|
||||
|
||||
// Create a "Choose Tag and Comment..." menu item. Selecting this item initiates
|
||||
// a dialog that can be used to create or select a tag name with an
|
||||
// optional comment and adds a tag with the resulting name.
|
||||
@@ -153,6 +135,19 @@ abstract class AddTagAction extends AbstractAction implements Presenter.Popup {
|
||||
}
|
||||
});
|
||||
add(tagAndCommentItem);
|
||||
|
||||
// Create a "New Tag..." menu item.
|
||||
// Selecting this item initiates a dialog that can be used to create
|
||||
// or select a tag name and adds a tag with the resulting name.
|
||||
JMenuItem newTagMenuItem = new JMenuItem(NbBundle.getMessage(this.getClass(), "AddTagAction.newTag"));
|
||||
newTagMenuItem.addActionListener((ActionEvent e) -> {
|
||||
TagName tagName = GetTagNameDialog.doDialog();
|
||||
if (null != tagName) {
|
||||
addTag(tagName, NO_COMMENT);
|
||||
}
|
||||
});
|
||||
add(newTagMenuItem);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,10 +46,10 @@ import org.sleuthkit.datamodel.TskData;
|
||||
|
||||
/**
|
||||
*
|
||||
* SQLite manager implementation
|
||||
* Generic JDBC methods
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractSqlEamDb implements EamDb {
|
||||
abstract class AbstractSqlEamDb implements EamDb {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(AbstractSqlEamDb.class.getName());
|
||||
|
||||
@@ -59,6 +59,11 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
protected int bulkArtifactsThreshold;
|
||||
private final Map<String, Collection<CorrelationAttribute>> bulkArtifacts;
|
||||
|
||||
// number of instances to keep in bulk queue before doing an insert.
|
||||
// Update Test code if this changes. It's hard coded there.
|
||||
static final int DEFAULT_BULK_THRESHHOLD = 1000;
|
||||
|
||||
|
||||
/**
|
||||
* Connect to the DB and initialize it.
|
||||
*
|
||||
@@ -426,6 +431,12 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
*/
|
||||
@Override
|
||||
public void newDataSource(CorrelationDataSource eamDataSource) throws EamDbException {
|
||||
if (eamDataSource.getCaseID() == -1) {
|
||||
throw new EamDbException("Case ID is -1");
|
||||
}
|
||||
else if (eamDataSource.getID() != -1) {
|
||||
throw new EamDbException("Database ID is already set in object");
|
||||
}
|
||||
Connection conn = connect();
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
@@ -1385,6 +1396,62 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
|
||||
return artifactInstances;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets list of matching eamArtifact instances that have knownStatus =
|
||||
* "Bad".
|
||||
* @param aType EamArtifact.Type to search for
|
||||
* @return List with 0 or more matching eamArtifact instances.
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public List<CorrelationAttributeInstance> getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException {
|
||||
if (aType == null) {
|
||||
throw new EamDbException("Correlation type is null");
|
||||
}
|
||||
|
||||
Connection conn = connect();
|
||||
|
||||
List<CorrelationAttributeInstance> artifactInstances = new ArrayList<>();
|
||||
|
||||
CorrelationAttributeInstance artifactInstance;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
String tableName = EamDbUtil.correlationTypeToInstanceTableName(aType);
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT cases.case_name, cases.case_uid, data_sources.name, device_id, file_path, known_status, comment, data_sources.case_id FROM ");
|
||||
sql.append(tableName);
|
||||
sql.append(" LEFT JOIN cases ON ");
|
||||
sql.append(tableName);
|
||||
sql.append(".case_id=cases.id");
|
||||
sql.append(" LEFT JOIN data_sources ON ");
|
||||
sql.append(tableName);
|
||||
sql.append(".data_source_id=data_sources.id");
|
||||
sql.append(" WHERE known_status=?");
|
||||
sql.append(" GROUP BY ");
|
||||
sql.append(tableName);
|
||||
sql.append(".value");
|
||||
|
||||
try {
|
||||
preparedStatement = conn.prepareStatement(sql.toString());
|
||||
preparedStatement.setByte(1, TskData.FileKnown.BAD.getFileKnownValue());
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
artifactInstance = getEamArtifactInstanceFromResultSet(resultSet);
|
||||
artifactInstances.add(artifactInstance);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new EamDbException("Error getting notable artifact instances.", ex); // NON-NLS
|
||||
} finally {
|
||||
EamDbUtil.closePreparedStatement(preparedStatement);
|
||||
EamDbUtil.closeResultSet(resultSet);
|
||||
EamDbUtil.closeConnection(conn);
|
||||
}
|
||||
|
||||
return artifactInstances;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count matching eamArtifacts instances that have knownStatus = "Bad".
|
||||
@@ -1675,21 +1742,16 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
return 0 < badInstances;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new organization
|
||||
*
|
||||
* @return the Organization ID of the newly created organization.
|
||||
*
|
||||
* @param eamOrg The organization to add
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
|
||||
@Override
|
||||
public long newOrganization(EamOrganization eamOrg) throws EamDbException {
|
||||
public EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException {
|
||||
if (eamOrg == null) {
|
||||
throw new EamDbException("EamOrganization is null");
|
||||
}
|
||||
|
||||
else if (eamOrg.getOrgID() != -1) {
|
||||
throw new EamDbException("EamOrganization already has an ID");
|
||||
}
|
||||
|
||||
Connection conn = connect();
|
||||
ResultSet generatedKeys = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
@@ -1706,7 +1768,8 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
preparedStatement.executeUpdate();
|
||||
generatedKeys = preparedStatement.getGeneratedKeys();
|
||||
if (generatedKeys.next()) {
|
||||
return generatedKeys.getLong(1);
|
||||
eamOrg.setOrgID((int)generatedKeys.getLong(1));
|
||||
return eamOrg;
|
||||
} else {
|
||||
throw new SQLException("Creating user failed, no ID obtained.");
|
||||
}
|
||||
@@ -1804,6 +1867,22 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
return (getOrganizationByID(globalSet.getOrgID()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that an organization passed in as an argument is valid
|
||||
*
|
||||
* @param org
|
||||
* @throws EamDbException if invalid
|
||||
*/
|
||||
private void testArgument(EamOrganization org) throws EamDbException {
|
||||
if(org == null) {
|
||||
throw new EamDbException("Organization is null");
|
||||
}
|
||||
else if (org.getOrgID() == -1) {
|
||||
throw new EamDbException("Organization has -1 row ID");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update an existing organization.
|
||||
*
|
||||
@@ -1814,10 +1893,8 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
*/
|
||||
@Override
|
||||
public void updateOrganization(EamOrganization updatedOrganization) throws EamDbException {
|
||||
if (updatedOrganization == null) {
|
||||
throw new EamDbException("null updatedOrganization");
|
||||
}
|
||||
|
||||
testArgument(updatedOrganization);
|
||||
|
||||
Connection conn = connect();
|
||||
PreparedStatement preparedStatement = null;
|
||||
String sql = "UPDATE organizations SET org_name = ?, poc_name = ?, poc_email = ?, poc_phone = ? WHERE id = ?";
|
||||
@@ -1842,10 +1919,8 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
"AbstractSqlEamDb.deleteOrganization.errorDeleting.message=Error executing query when attempting to delete organization by id."})
|
||||
@Override
|
||||
public void deleteOrganization(EamOrganization organizationToDelete) throws EamDbException {
|
||||
if (organizationToDelete == null) {
|
||||
throw new EamDbException("Organization to delete is null");
|
||||
}
|
||||
|
||||
testArgument(organizationToDelete);
|
||||
|
||||
Connection conn = connect();
|
||||
PreparedStatement checkIfUsedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
@@ -2504,6 +2579,7 @@ public abstract class AbstractSqlEamDb implements EamDb {
|
||||
if (null == resultSet) {
|
||||
return null;
|
||||
}
|
||||
// @@@ We should have data source ID in the previous query instead of passing -1 into the below constructor
|
||||
CorrelationAttributeInstance eamArtifactInstance = new CorrelationAttributeInstance(
|
||||
resultSet.getInt("id"),
|
||||
new CorrelationCase(resultSet.getInt("case_id"), resultSet.getString("case_uid"), resultSet.getString("case_name")),
|
||||
|
||||
-15
@@ -43,13 +43,6 @@ public class CorrelationAttributeInstance implements Serializable {
|
||||
private String comment;
|
||||
private TskData.FileKnown knownStatus;
|
||||
|
||||
public CorrelationAttributeInstance(
|
||||
CorrelationCase eamCase,
|
||||
CorrelationDataSource eamDataSource
|
||||
) throws EamDbException {
|
||||
this(-1, eamCase, eamDataSource, "", null, TskData.FileKnown.UNKNOWN);
|
||||
}
|
||||
|
||||
public CorrelationAttributeInstance(
|
||||
CorrelationCase eamCase,
|
||||
CorrelationDataSource eamDataSource,
|
||||
@@ -58,14 +51,6 @@ public class CorrelationAttributeInstance implements Serializable {
|
||||
this(-1, eamCase, eamDataSource, filePath, null, TskData.FileKnown.UNKNOWN);
|
||||
}
|
||||
|
||||
public CorrelationAttributeInstance(
|
||||
CorrelationCase eamCase,
|
||||
CorrelationDataSource eamDataSource,
|
||||
String filePath,
|
||||
String comment
|
||||
) throws EamDbException {
|
||||
this(-1, eamCase, eamDataSource, filePath, comment, TskData.FileKnown.UNKNOWN);
|
||||
}
|
||||
|
||||
public CorrelationAttributeInstance(
|
||||
CorrelationCase eamCase,
|
||||
|
||||
+14
-8
@@ -40,15 +40,21 @@ public class CorrelationDataSource implements Serializable {
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param caseId
|
||||
* @param deviceId
|
||||
* @param name
|
||||
* @param correlationCase CorrelationCase object data source is associated with. Must have been created by EamDB and have a valid ID.
|
||||
* @param deviceId User specified case-specific ID
|
||||
* @param name Display name of data source
|
||||
*/
|
||||
public CorrelationDataSource(int caseId, String deviceId, String name) {
|
||||
this(caseId, -1, deviceId, name);
|
||||
public CorrelationDataSource(CorrelationCase correlationCase, String deviceId, String name) {
|
||||
this(correlationCase.getID(), -1, deviceId, name);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param caseId Row ID for Case in DB
|
||||
* @param dataSourceId Row ID for this data source in DB (or -1)
|
||||
* @param deviceId User specified ID for device (unique per case)
|
||||
* @param name User specified name
|
||||
*/
|
||||
CorrelationDataSource(int caseId,
|
||||
int dataSourceId,
|
||||
String deviceId,
|
||||
@@ -90,7 +96,7 @@ public class CorrelationDataSource implements Serializable {
|
||||
correlationDataSource = EamDb.getInstance().getDataSource(correlationCase, deviceId);
|
||||
}
|
||||
if (correlationDataSource == null) {
|
||||
correlationDataSource = new CorrelationDataSource(correlationCase.getID(), deviceId, dataSource.getName());
|
||||
correlationDataSource = new CorrelationDataSource(correlationCase, deviceId, dataSource.getName());
|
||||
if (EamDbUtil.useCentralRepo()) {
|
||||
EamDb.getInstance().newDataSource(correlationDataSource);
|
||||
}
|
||||
@@ -113,7 +119,7 @@ public class CorrelationDataSource implements Serializable {
|
||||
/**
|
||||
* Get the database row ID
|
||||
*
|
||||
* @return the ID
|
||||
* @return the ID or -1 if unknown
|
||||
*/
|
||||
int getID() {
|
||||
return dataSourceID;
|
||||
|
||||
@@ -76,9 +76,9 @@ public class EamArtifactUtil {
|
||||
// have switch based on artifact type
|
||||
for (CorrelationAttribute.Type aType : EamDb.getInstance().getDefinedCorrelationTypes()) {
|
||||
if ((checkEnabled && aType.isEnabled()) || !checkEnabled) {
|
||||
CorrelationAttribute eamArtifact = EamArtifactUtil.getCorrelationAttributeFromBlackboardArtifact(aType, bbArtifact);
|
||||
if (eamArtifact != null) {
|
||||
eamArtifacts.add(eamArtifact);
|
||||
CorrelationAttribute correlationAttribute = EamArtifactUtil.getCorrelationAttributeFromBlackboardArtifact(aType, bbArtifact);
|
||||
if (correlationAttribute != null) {
|
||||
eamArtifacts.add(correlationAttribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public class EamArtifactUtil {
|
||||
|
||||
final AbstractFile file = (AbstractFile) content;
|
||||
|
||||
if (!isValidCentralRepoFile(file)) {
|
||||
if (!isSupportedAbstractFileType(file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public class EamArtifactUtil {
|
||||
|
||||
final AbstractFile af = (AbstractFile) content;
|
||||
|
||||
if (!isValidCentralRepoFile(af)) {
|
||||
if (!isSupportedAbstractFileType(af)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -312,15 +312,11 @@ public class EamArtifactUtil {
|
||||
* @return true if the file should be added to the central repo, false
|
||||
* otherwise
|
||||
*/
|
||||
public static boolean isValidCentralRepoFile(AbstractFile file) {
|
||||
public static boolean isSupportedAbstractFileType(AbstractFile file) {
|
||||
if (file == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.getKnown() == TskData.FileKnown.KNOWN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (file.getType()) {
|
||||
case UNALLOC_BLOCKS:
|
||||
case UNUSED_BLOCKS:
|
||||
|
||||
@@ -34,7 +34,8 @@ public interface EamDb {
|
||||
public static final int SCHEMA_VERSION = 1;
|
||||
public static final CaseDbSchemaVersionNumber CURRENT_DB_SCHEMA_VERSION
|
||||
= new CaseDbSchemaVersionNumber(1, 1);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the instance
|
||||
*
|
||||
@@ -359,6 +360,15 @@ public interface EamDb {
|
||||
*/
|
||||
List<CorrelationAttributeInstance> getArtifactInstancesKnownBad(CorrelationAttribute.Type aType, String value) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Gets list of matching eamArtifact instances that have knownStatus =
|
||||
* "Bad".
|
||||
*
|
||||
* @param aType EamArtifact.Type to search for
|
||||
* @return List with 0 or more matching eamArtifact instances.
|
||||
* @throws EamDbException
|
||||
*/
|
||||
List<CorrelationAttributeInstance> getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException;
|
||||
/**
|
||||
* Count matching eamArtifacts instances that have knownStatus = "Bad".
|
||||
*
|
||||
@@ -460,11 +470,11 @@ public interface EamDb {
|
||||
*
|
||||
* @param eamOrg The organization to add
|
||||
*
|
||||
* @return the Organization ID of the newly created organization.
|
||||
* @return The organization with the org ID set.
|
||||
*
|
||||
* @throws EamDbException
|
||||
*/
|
||||
long newOrganization(EamOrganization eamOrg) throws EamDbException;
|
||||
EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException;
|
||||
|
||||
/**
|
||||
* Get all organizations
|
||||
|
||||
@@ -29,7 +29,7 @@ public class EamOrganization {
|
||||
private String pocEmail;
|
||||
private String pocPhone;
|
||||
|
||||
public EamOrganization(
|
||||
EamOrganization(
|
||||
int orgID,
|
||||
String name,
|
||||
String pocName,
|
||||
@@ -84,7 +84,7 @@ public class EamOrganization {
|
||||
/**
|
||||
* @param orgID the orgID to set
|
||||
*/
|
||||
public void setOrgID(int orgID) {
|
||||
void setOrgID(int orgID) {
|
||||
this.orgID = orgID;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@ import java.sql.Statement;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
import org.sleuthkit.autopsy.casemodule.CaseActionCancelledException;
|
||||
import org.sleuthkit.autopsy.casemodule.CaseActionException;
|
||||
import org.sleuthkit.autopsy.coordinationservice.CoordinationService;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
@@ -34,7 +32,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
* Central Repository database implementation using Postgres as a
|
||||
* backend
|
||||
*/
|
||||
public class PostgresEamDb extends AbstractSqlEamDb {
|
||||
final class PostgresEamDb extends AbstractSqlEamDb {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(PostgresEamDb.class.getName());
|
||||
|
||||
|
||||
+12
-11
@@ -35,6 +35,8 @@ import org.sleuthkit.autopsy.coreutils.TextConverterException;
|
||||
|
||||
/**
|
||||
* Settings for the Postgres implementation of the Central Repository database
|
||||
*
|
||||
* NOTE: This is public scope because the options panel calls it directly to set/get
|
||||
*/
|
||||
public final class PostgresEamDbSettings {
|
||||
|
||||
@@ -42,7 +44,6 @@ public final class PostgresEamDbSettings {
|
||||
private final String DEFAULT_HOST = ""; // NON-NLS
|
||||
private final int DEFAULT_PORT = 5432;
|
||||
private final String DEFAULT_DBNAME = "central_repository"; // NON-NLS
|
||||
private final int DEFAULT_BULK_THRESHHOLD = 1000;
|
||||
private final String DEFAULT_USERNAME = "";
|
||||
private final String DEFAULT_PASSWORD = "";
|
||||
private final String VALIDATION_QUERY = "SELECT version()"; // NON-NLS
|
||||
@@ -89,15 +90,15 @@ public final class PostgresEamDbSettings {
|
||||
try {
|
||||
String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.bulkThreshold"); // NON-NLS
|
||||
if (bulkThresholdString == null || bulkThresholdString.isEmpty()) {
|
||||
this.bulkThreshold = DEFAULT_BULK_THRESHHOLD;
|
||||
this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD;
|
||||
} else {
|
||||
this.bulkThreshold = Integer.parseInt(bulkThresholdString);
|
||||
if (getBulkThreshold() <= 0) {
|
||||
this.bulkThreshold = DEFAULT_BULK_THRESHHOLD;
|
||||
this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD;
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
this.bulkThreshold = DEFAULT_BULK_THRESHHOLD;
|
||||
this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD;
|
||||
}
|
||||
|
||||
userName = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.user"); // NON-NLS
|
||||
@@ -139,7 +140,7 @@ public final class PostgresEamDbSettings {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getConnectionURL(boolean usePostgresDb) {
|
||||
String getConnectionURL(boolean usePostgresDb) {
|
||||
StringBuilder url = new StringBuilder();
|
||||
url.append(getJDBCBaseURI());
|
||||
url.append(getHost());
|
||||
@@ -231,7 +232,7 @@ public final class PostgresEamDbSettings {
|
||||
* Use the current settings and the schema version query to test the
|
||||
* database schema.
|
||||
*
|
||||
* @return true if successfull connection, else false.
|
||||
* @return true if successful connection, else false.
|
||||
*/
|
||||
public boolean verifyDatabaseSchema() {
|
||||
Connection conn = getEphemeralConnection(false);
|
||||
@@ -493,7 +494,7 @@ public final class PostgresEamDbSettings {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isChanged() {
|
||||
boolean isChanged() {
|
||||
String hostString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.host"); // NON-NLS
|
||||
String portString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.port"); // NON-NLS
|
||||
String dbNameString = ModuleSettings.getConfigSetting("CentralRepository", "db.postgresql.dbName"); // NON-NLS
|
||||
@@ -568,7 +569,7 @@ public final class PostgresEamDbSettings {
|
||||
/**
|
||||
* @return the bulkThreshold
|
||||
*/
|
||||
public int getBulkThreshold() {
|
||||
int getBulkThreshold() {
|
||||
return bulkThreshold;
|
||||
}
|
||||
|
||||
@@ -622,21 +623,21 @@ public final class PostgresEamDbSettings {
|
||||
/**
|
||||
* @return the VALIDATION_QUERY
|
||||
*/
|
||||
public String getValidationQuery() {
|
||||
String getValidationQuery() {
|
||||
return VALIDATION_QUERY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the POSTGRES_DRIVER
|
||||
*/
|
||||
public String getDriver() {
|
||||
String getDriver() {
|
||||
return JDBC_DRIVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the JDBC_BASE_URI
|
||||
*/
|
||||
public String getJDBCBaseURI() {
|
||||
String getJDBCBaseURI() {
|
||||
return JDBC_BASE_URI;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
@@ -38,7 +37,7 @@ import org.sleuthkit.autopsy.coordinationservice.CoordinationService;
|
||||
* All methods in AbstractSqlEamDb that read or write to the database should
|
||||
* be overriden here and use appropriate locking.
|
||||
*/
|
||||
public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
final class SqliteEamDb extends AbstractSqlEamDb {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(SqliteEamDb.class.getName());
|
||||
|
||||
@@ -590,6 +589,24 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Gets list of matching eamArtifact instances that have knownStatus =
|
||||
* "Bad".
|
||||
* @param aType EamArtifact.Type to search for
|
||||
* @return List with 0 or more matching eamArtifact instances.
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public List<CorrelationAttributeInstance> getArtifactInstancesKnownBad(CorrelationAttribute.Type aType) throws EamDbException {
|
||||
try{
|
||||
acquireSharedLock();
|
||||
return super.getArtifactInstancesKnownBad(aType);
|
||||
} finally {
|
||||
releaseSharedLock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count matching eamArtifacts instances that have knownStatus = "Bad".
|
||||
*
|
||||
@@ -708,7 +725,7 @@ public class SqliteEamDb extends AbstractSqlEamDb {
|
||||
* @throws EamDbException
|
||||
*/
|
||||
@Override
|
||||
public long newOrganization(EamOrganization eamOrg) throws EamDbException {
|
||||
public EamOrganization newOrganization(EamOrganization eamOrg) throws EamDbException {
|
||||
try{
|
||||
acquireExclusiveLock();
|
||||
return super.newOrganization(eamOrg);
|
||||
|
||||
+12
-11
@@ -35,13 +35,14 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||
|
||||
/**
|
||||
* Settings for the sqlite implementation of the Central Repository database
|
||||
*
|
||||
* NOTE: This is public scope because the options panel calls it directly to set/get
|
||||
*/
|
||||
public final class SqliteEamDbSettings {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(SqliteEamDbSettings.class.getName());
|
||||
private final String DEFAULT_DBNAME = "central_repository.db"; // NON-NLS
|
||||
private final String DEFAULT_DBDIRECTORY = PlatformUtil.getUserDirectory() + File.separator + "central_repository"; // NON-NLS
|
||||
private final int DEFAULT_BULK_THRESHHOLD = 1000;
|
||||
private final String JDBC_DRIVER = "org.sqlite.JDBC"; // NON-NLS
|
||||
private final String JDBC_BASE_URI = "jdbc:sqlite:"; // NON-NLS
|
||||
private final String VALIDATION_QUERY = "SELECT count(*) from sqlite_master"; // NON-NLS
|
||||
@@ -75,15 +76,15 @@ public final class SqliteEamDbSettings {
|
||||
try {
|
||||
String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.bulkThreshold"); // NON-NLS
|
||||
if (bulkThresholdString == null || bulkThresholdString.isEmpty()) {
|
||||
this.bulkThreshold = DEFAULT_BULK_THRESHHOLD;
|
||||
this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD;
|
||||
} else {
|
||||
this.bulkThreshold = Integer.parseInt(bulkThresholdString);
|
||||
if (getBulkThreshold() <= 0) {
|
||||
this.bulkThreshold = DEFAULT_BULK_THRESHHOLD;
|
||||
this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD;
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
this.bulkThreshold = DEFAULT_BULK_THRESHHOLD;
|
||||
this.bulkThreshold = AbstractSqlEamDb.DEFAULT_BULK_THRESHHOLD;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +163,7 @@ public final class SqliteEamDbSettings {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getConnectionURL() {
|
||||
String getConnectionURL() {
|
||||
StringBuilder url = new StringBuilder();
|
||||
url.append(getJDBCBaseURI());
|
||||
url.append(getFileNameWithPath());
|
||||
@@ -439,7 +440,7 @@ public final class SqliteEamDbSettings {
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isChanged() {
|
||||
boolean isChanged() {
|
||||
String dbNameString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.dbName"); // NON-NLS
|
||||
String dbDirectoryString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.dbDirectory"); // NON-NLS
|
||||
String bulkThresholdString = ModuleSettings.getConfigSetting("CentralRepository", "db.sqlite.bulkThreshold"); // NON-NLS
|
||||
@@ -474,14 +475,14 @@ public final class SqliteEamDbSettings {
|
||||
/**
|
||||
* @return the bulkThreshold
|
||||
*/
|
||||
public int getBulkThreshold() {
|
||||
int getBulkThreshold() {
|
||||
return bulkThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bulkThreshold the bulkThreshold to set
|
||||
*/
|
||||
public void setBulkThreshold(int bulkThreshold) throws EamDbException {
|
||||
void setBulkThreshold(int bulkThreshold) throws EamDbException {
|
||||
if (bulkThreshold > 0) {
|
||||
this.bulkThreshold = bulkThreshold;
|
||||
} else {
|
||||
@@ -525,21 +526,21 @@ public final class SqliteEamDbSettings {
|
||||
/**
|
||||
* @return the DRIVER
|
||||
*/
|
||||
public String getDriver() {
|
||||
String getDriver() {
|
||||
return JDBC_DRIVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the VALIDATION_QUERY
|
||||
*/
|
||||
public String getValidationQuery() {
|
||||
String getValidationQuery() {
|
||||
return VALIDATION_QUERY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the JDBC_BASE_URI
|
||||
*/
|
||||
public String getJDBCBaseURI() {
|
||||
String getJDBCBaseURI() {
|
||||
return JDBC_BASE_URI;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,10 +102,14 @@ final class IngestModule implements FileIngestModule {
|
||||
return ProcessResult.ERROR;
|
||||
}
|
||||
|
||||
if (!EamArtifactUtil.isValidCentralRepoFile(abstractFile)) {
|
||||
if (!EamArtifactUtil.isSupportedAbstractFileType(abstractFile)) {
|
||||
return ProcessResult.OK;
|
||||
}
|
||||
|
||||
if (abstractFile.getKnown() == TskData.FileKnown.KNOWN) {
|
||||
return ProcessResult.OK;
|
||||
}
|
||||
|
||||
EamDb dbManager;
|
||||
try {
|
||||
dbManager = EamDb.getInstance();
|
||||
|
||||
+20
-9
@@ -37,7 +37,7 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.EamDb;
|
||||
* Dialog to add a new organization to the Central Repository database
|
||||
*/
|
||||
@SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
|
||||
public class AddNewOrganizationDialog extends javax.swing.JDialog {
|
||||
class AddNewOrganizationDialog extends javax.swing.JDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AddNewOrganizationDialog.class.getName());
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -52,7 +52,7 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog {
|
||||
* Creates new form AddNewOrganizationDialog
|
||||
*/
|
||||
@Messages({"AddNewOrganizationDialog.addNewOrg.msg=Add New Organization"})
|
||||
public AddNewOrganizationDialog() {
|
||||
AddNewOrganizationDialog() {
|
||||
super((JFrame) WindowManager.getDefault().getMainWindow(),
|
||||
Bundle.AddNewOrganizationDialog_addNewOrg_msg(),
|
||||
true); // NON-NLS
|
||||
@@ -66,6 +66,7 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog {
|
||||
display();
|
||||
}
|
||||
|
||||
// populates the dialog with existing case information to edit
|
||||
public AddNewOrganizationDialog(EamOrganization orgToEdit) {
|
||||
super((JFrame) WindowManager.getDefault().getMainWindow(),
|
||||
Bundle.AddNewOrganizationDialog_addNewOrg_msg(),
|
||||
@@ -194,10 +195,19 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return True if new org was added or existing org changed
|
||||
*/
|
||||
public boolean isChanged() {
|
||||
return hasChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only valid if isChanged() is true.
|
||||
*
|
||||
* @return Org that was added or changed. null if nothing changed
|
||||
*/
|
||||
public EamOrganization getNewOrg() {
|
||||
return newOrg;
|
||||
}
|
||||
@@ -333,12 +343,12 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog {
|
||||
try {
|
||||
EamDb dbManager = EamDb.getInstance();
|
||||
if (organizationToEdit != null) {
|
||||
//check if new name exists with ID other than the one in use here
|
||||
newOrg = new EamOrganization(organizationToEdit.getOrgID(),
|
||||
tfOrganizationName.getText(),
|
||||
tfPocName.getText(),
|
||||
tfPocEmail.getText(),
|
||||
tfPocPhone.getText());
|
||||
// make a copy in case the update fails
|
||||
newOrg = dbManager.getOrganizationByID(organizationToEdit.getOrgID());
|
||||
newOrg.setName(tfOrganizationName.getText());
|
||||
newOrg.setPocName(tfPocName.getText());
|
||||
newOrg.setPocEmail(tfPocEmail.getText());
|
||||
newOrg.setPocPhone(tfPocPhone.getText());
|
||||
dbManager.updateOrganization(newOrg);
|
||||
} else {
|
||||
newOrg = new EamOrganization(
|
||||
@@ -346,13 +356,14 @@ public class AddNewOrganizationDialog extends javax.swing.JDialog {
|
||||
tfPocName.getText(),
|
||||
tfPocEmail.getText(),
|
||||
tfPocPhone.getText());
|
||||
newOrg.setOrgID((int)dbManager.newOrganization(newOrg));
|
||||
newOrg = dbManager.newOrganization(newOrg);
|
||||
}
|
||||
hasChanged = true;
|
||||
dispose();
|
||||
} catch (EamDbException ex) {
|
||||
lbWarningMsg.setText(Bundle.AddNewOrganizationDialog_bnOk_addFailed_text());
|
||||
logger.log(Level.SEVERE, "Failed adding new organization.", ex);
|
||||
newOrg = null;
|
||||
}
|
||||
}//GEN-LAST:event_bnOKActionPerformed
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
|
||||
|
||||
// Create the "Add/Edit Central Repository Comment" menu item if the enabled.
|
||||
AbstractFile file = content;
|
||||
if (EamDbUtil.useCentralRepo() && EamArtifactUtil.isValidCentralRepoFile(file) && file.isFile()) {
|
||||
if (EamDbUtil.useCentralRepo() && EamArtifactUtil.isSupportedAbstractFileType(file) && file.isFile()) {
|
||||
actionsList.add(AddEditCentralRepoCommentAction.createAddEditCentralRepoCommentAction(file));
|
||||
}
|
||||
|
||||
|
||||
@@ -1059,10 +1059,15 @@ public final class DirectoryTreeTopComponent extends TopComponent implements Dat
|
||||
DisplayableItemNode undecoratedParentNode = (DisplayableItemNode) ((DirectoryTreeFilterNode) treeNode).getOriginal();
|
||||
undecoratedParentNode.setChildNodeSelectionInfo(new ArtifactNodeSelectionInfo(art));
|
||||
getTree().expandNode(treeNode);
|
||||
try {
|
||||
em.setExploredContextAndSelection(treeNode, new Node[]{treeNode});
|
||||
} catch (PropertyVetoException ex) {
|
||||
LOGGER.log(Level.WARNING, "Property Veto: ", ex); //NON-NLS
|
||||
if (this.getSelectedNode().equals(treeNode)) {
|
||||
this.setDirectoryListingActive();
|
||||
this.respondSelection(em.getSelectedNodes(), new Node[]{treeNode});
|
||||
} else {
|
||||
try {
|
||||
em.setExploredContextAndSelection(treeNode, new Node[]{treeNode});
|
||||
} catch (PropertyVetoException ex) {
|
||||
LOGGER.log(Level.WARNING, "Property Veto: ", ex); //NON-NLS
|
||||
}
|
||||
}
|
||||
// Another thread is needed because we have to wait for dataResult to populate
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@@ -224,8 +224,8 @@ public final class DataSourceIngestJob {
|
||||
/**
|
||||
* Make mappings of ingest module factory class names to templates.
|
||||
*/
|
||||
Map<String, IngestModuleTemplate> dataSourceModuleTemplates = new HashMap<>();
|
||||
Map<String, IngestModuleTemplate> fileModuleTemplates = new HashMap<>();
|
||||
Map<String, IngestModuleTemplate> dataSourceModuleTemplates = new LinkedHashMap<>();
|
||||
Map<String, IngestModuleTemplate> fileModuleTemplates = new LinkedHashMap<>();
|
||||
for (IngestModuleTemplate template : ingestModuleTemplates) {
|
||||
if (template.isDataSourceIngestModuleTemplate()) {
|
||||
dataSourceModuleTemplates.put(template.getModuleFactory().getClass().getCanonicalName(), template);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2014 Basis Technology Corp.
|
||||
* Copyright 2014-2018 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -38,6 +38,7 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupModuleFactory;
|
||||
import org.sleuthkit.autopsy.modules.interestingitems.InterestingItemsIngestModuleFactory;
|
||||
import org.sleuthkit.autopsy.modules.photoreccarver.PhotoRecCarverIngestModuleFactory;
|
||||
import org.sleuthkit.autopsy.modules.embeddedfileextractor.EmbeddedFileExtractorModuleFactory;
|
||||
import org.sleuthkit.autopsy.modules.encryptiondetection.EncryptionDetectionModuleFactory;
|
||||
import org.sleuthkit.autopsy.python.JythonModuleLoader;
|
||||
|
||||
/**
|
||||
@@ -60,6 +61,7 @@ final class IngestModuleFactoryLoader {
|
||||
add("org.sleuthkit.autopsy.thunderbirdparser.EmailParserModuleFactory"); //NON-NLS
|
||||
add(FileExtMismatchDetectorModuleFactory.class.getCanonicalName());
|
||||
add(E01VerifierModuleFactory.class.getCanonicalName());
|
||||
add(EncryptionDetectionModuleFactory.class.getCanonicalName());
|
||||
add(InterestingItemsIngestModuleFactory.class.getCanonicalName());
|
||||
add(PhotoRecCarverIngestModuleFactory.class.getCanonicalName());
|
||||
}
|
||||
|
||||
+30
-30
@@ -51,6 +51,8 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
private static final String PROPERTIES_FILE = "CentralRepository";
|
||||
private static final String CR_DB_NAME = "testcentralrepo.db";
|
||||
private static final Path testDirectory = Paths.get(System.getProperty("java.io.tmpdir"), "CentralRepoDatamodelTest");
|
||||
private static final int DEFAULT_BULK_THRESHOLD = 1000; // hard coded from EamDb
|
||||
|
||||
SqliteEamDbSettings dbSettingsSqlite;
|
||||
|
||||
private CorrelationCase case1;
|
||||
@@ -129,26 +131,26 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
case2 = EamDb.getInstance().newCase(case2);
|
||||
assertTrue("Failed to create test object case2", case2 != null);
|
||||
|
||||
dataSource1fromCase1 = new CorrelationDataSource(case1.getID(), "dataSource1_deviceID", "dataSource1");
|
||||
dataSource1fromCase1 = new CorrelationDataSource(case1, "dataSource1_deviceID", "dataSource1");
|
||||
EamDb.getInstance().newDataSource(dataSource1fromCase1);
|
||||
dataSource1fromCase1 = EamDb.getInstance().getDataSource(case1, dataSource1fromCase1.getDeviceID());
|
||||
assertTrue("Failed to create test object dataSource1fromCase1", dataSource1fromCase1 != null);
|
||||
|
||||
dataSource2fromCase1 = new CorrelationDataSource(case1.getID(), "dataSource2_deviceID", "dataSource2");
|
||||
dataSource2fromCase1 = new CorrelationDataSource(case1, "dataSource2_deviceID", "dataSource2");
|
||||
EamDb.getInstance().newDataSource(dataSource2fromCase1);
|
||||
dataSource2fromCase1 = EamDb.getInstance().getDataSource(case1, dataSource2fromCase1.getDeviceID());
|
||||
assertTrue("Failed to create test object dataSource2fromCase1", dataSource2fromCase1 != null);
|
||||
|
||||
dataSource1fromCase2 = new CorrelationDataSource(case2.getID(), "dataSource3_deviceID", "dataSource3");
|
||||
dataSource1fromCase2 = new CorrelationDataSource(case2, "dataSource3_deviceID", "dataSource3");
|
||||
EamDb.getInstance().newDataSource(dataSource1fromCase2);
|
||||
dataSource1fromCase2 = EamDb.getInstance().getDataSource(case2, dataSource1fromCase2.getDeviceID());
|
||||
assertTrue("Failed to create test object dataSource1fromCase2", dataSource1fromCase2 != null);
|
||||
|
||||
org1 = new EamOrganization("org1");
|
||||
org1.setOrgID((int) EamDb.getInstance().newOrganization(org1));
|
||||
org1 = EamDb.getInstance().newOrganization(org1);
|
||||
|
||||
org2 = new EamOrganization("org2");
|
||||
org2.setOrgID((int) EamDb.getInstance().newOrganization(org2));
|
||||
org2 = EamDb.getInstance().newOrganization(org2);
|
||||
|
||||
// Store the file type object for later use
|
||||
fileType = EamDb.getInstance().getCorrelationTypeById(CorrelationAttribute.FILES_TYPE_ID);
|
||||
@@ -470,7 +472,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Create the first list, which will have (bulkThreshold / 2) entries
|
||||
List<CorrelationAttribute> list1 = new ArrayList<>();
|
||||
for (int i = 0; i < dbSettingsSqlite.getBulkThreshold() / 2; i++) {
|
||||
for (int i = 0; i < DEFAULT_BULK_THRESHOLD / 2; i++) {
|
||||
String value = "bulkInsertValue1_" + String.valueOf(i);
|
||||
String path = "C:\\bulkInsertPath1\\file" + String.valueOf(i);
|
||||
|
||||
@@ -490,7 +492,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Make a second list with length equal to bulkThreshold
|
||||
List<CorrelationAttribute> list2 = new ArrayList<>();
|
||||
for (int i = 0; i < dbSettingsSqlite.getBulkThreshold(); i++) {
|
||||
for (int i = 0; i < DEFAULT_BULK_THRESHOLD; i++) {
|
||||
String value = "bulkInsertValue2_" + String.valueOf(i);
|
||||
String path = "C:\\bulkInsertPath2\\file" + String.valueOf(i);
|
||||
|
||||
@@ -506,7 +508,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// There should now be bulkThreshold artifacts in the database
|
||||
long count = EamDb.getInstance().getCountArtifactInstancesByCaseDataSource(case1.getCaseUUID(), dataSource1fromCase1.getDeviceID());
|
||||
assertTrue("Artifact count " + count + " does not match bulkThreshold " + dbSettingsSqlite.getBulkThreshold(), count == dbSettingsSqlite.getBulkThreshold());
|
||||
assertTrue("Artifact count " + count + " does not match bulkThreshold " + DEFAULT_BULK_THRESHOLD, count == DEFAULT_BULK_THRESHOLD);
|
||||
|
||||
// Now call bulkInsertArtifacts() to insert the rest of queue
|
||||
EamDb.getInstance().bulkInsertArtifacts();
|
||||
@@ -784,7 +786,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Test adding instance with invalid data source ID
|
||||
try {
|
||||
CorrelationDataSource badDS = new CorrelationDataSource(case1.getID(), "badDSUuid", "badDSName");
|
||||
CorrelationDataSource badDS = new CorrelationDataSource(case1, "badDSUuid", "badDSName");
|
||||
CorrelationAttributeInstance inst = new CorrelationAttributeInstance(case1, badDS, "badPath");
|
||||
failAttr.addInstance(inst);
|
||||
EamDb.getInstance().addArtifact(failAttr);
|
||||
@@ -1305,7 +1307,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
// Test adding a basic organization
|
||||
try {
|
||||
orgA = new EamOrganization(orgAname);
|
||||
orgA.setOrgID((int) EamDb.getInstance().newOrganization(orgA));
|
||||
orgA = EamDb.getInstance().newOrganization(orgA);
|
||||
assertTrue("Organization ID is still -1 after adding to db", orgA.getOrgID() != -1);
|
||||
} catch (EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
@@ -1316,7 +1318,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
// Test adding an organization with additional fields
|
||||
try {
|
||||
orgB = new EamOrganization(orgBname, orgBpocName, orgBpocEmail, orgBpocPhone);
|
||||
orgB.setOrgID((int) EamDb.getInstance().newOrganization(orgB));
|
||||
orgB = EamDb.getInstance().newOrganization(orgB);
|
||||
assertTrue("Organization ID is still -1 after adding to db", orgB.getOrgID() != -1);
|
||||
} catch (EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
@@ -1408,14 +1410,13 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
}
|
||||
|
||||
// Test updating invalid org
|
||||
// Shouldn't do anything
|
||||
|
||||
try {
|
||||
EamOrganization temp = new EamOrganization("invalidOrg");
|
||||
temp.setOrgID(3434);
|
||||
EamDb.getInstance().updateOrganization(temp);
|
||||
Assert.fail("updateOrganization worked for invalid ID");
|
||||
} catch (EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
Assert.fail(ex);
|
||||
// this is the expected behavior
|
||||
}
|
||||
|
||||
// Test updating null org
|
||||
@@ -1439,7 +1440,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
// Test deleting existing org that isn't in use
|
||||
try {
|
||||
EamOrganization orgToDelete = new EamOrganization("deleteThis");
|
||||
orgToDelete.setOrgID((int) EamDb.getInstance().newOrganization(orgToDelete));
|
||||
orgToDelete = EamDb.getInstance().newOrganization(orgToDelete);
|
||||
int orgCount = EamDb.getInstance().getOrganizations().size();
|
||||
|
||||
EamDb.getInstance().deleteOrganization(orgToDelete);
|
||||
@@ -1453,7 +1454,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
try {
|
||||
// Make a new org
|
||||
EamOrganization inUseOrg = new EamOrganization("inUseOrg");
|
||||
inUseOrg.setOrgID((int) EamDb.getInstance().newOrganization(inUseOrg));
|
||||
inUseOrg = EamDb.getInstance().newOrganization(inUseOrg);
|
||||
|
||||
// Make a reference set that uses it
|
||||
EamGlobalSet tempSet = new EamGlobalSet(inUseOrg.getOrgID(), "inUseOrgTest", "1.0", TskData.FileKnown.BAD, false, fileType);
|
||||
@@ -1467,14 +1468,12 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
}
|
||||
|
||||
// Test deleting non-existent org
|
||||
// Should do nothing
|
||||
try {
|
||||
EamOrganization temp = new EamOrganization("temp");
|
||||
temp.setOrgID(9876);
|
||||
EamDb.getInstance().deleteOrganization(temp);
|
||||
Assert.fail("deleteOrganization failed to throw exception for non-existent organization");
|
||||
} catch (EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
Assert.fail(ex);
|
||||
// This is the expected behavior
|
||||
}
|
||||
|
||||
// Test deleting null org
|
||||
@@ -1632,7 +1631,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
// Create a list of global file instances. Make enough that the bulk threshold should be hit once.
|
||||
Set<EamGlobalFileInstance> instances = new HashSet<>();
|
||||
String bulkTestHash = "bulktesthash_";
|
||||
for (int i = 0; i < dbSettingsSqlite.getBulkThreshold() * 1.5; i++) {
|
||||
for (int i = 0; i < DEFAULT_BULK_THRESHOLD * 1.5; i++) {
|
||||
String hash = bulkTestHash + String.valueOf(i);
|
||||
instances.add(new EamGlobalFileInstance(notableSet2id, hash, TskData.FileKnown.BAD, null));
|
||||
}
|
||||
@@ -1641,7 +1640,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
EamDb.getInstance().bulkInsertReferenceTypeEntries(instances, fileType);
|
||||
|
||||
// There's no way to get a count of the number of entries in the database, so just do a spot check
|
||||
if (dbSettingsSqlite.getBulkThreshold() > 10) {
|
||||
if (DEFAULT_BULK_THRESHOLD > 10) {
|
||||
String hash = bulkTestHash + "10";
|
||||
assertTrue("Sample bulk insert instance not found", EamDb.getInstance().isFileHashInReferenceSet(hash, notableSet2id));
|
||||
}
|
||||
@@ -2163,7 +2162,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Test creating a data source with valid case, name, and ID
|
||||
try {
|
||||
dataSourceA = new CorrelationDataSource(case2.getID(), dataSourceAid, dataSourceAname);
|
||||
dataSourceA = new CorrelationDataSource(case2, dataSourceAid, dataSourceAname);
|
||||
EamDb.getInstance().newDataSource(dataSourceA);
|
||||
} catch (EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
@@ -2173,7 +2172,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Test creating a data source with the same case, name, and ID
|
||||
try {
|
||||
CorrelationDataSource temp = new CorrelationDataSource(case2.getID(), dataSourceAid, dataSourceAname);
|
||||
CorrelationDataSource temp = new CorrelationDataSource(case2, dataSourceAid, dataSourceAname);
|
||||
EamDb.getInstance().newDataSource(temp);
|
||||
Assert.fail("newDataSource did not throw exception from duplicate data source");
|
||||
} catch (EamDbException ex) {
|
||||
@@ -2182,7 +2181,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Test creating a data source with the same name and ID but different case
|
||||
try {
|
||||
dataSourceB = new CorrelationDataSource(case1.getID(), dataSourceAid, dataSourceAname);
|
||||
dataSourceB = new CorrelationDataSource(case1, dataSourceAid, dataSourceAname);
|
||||
EamDb.getInstance().newDataSource(dataSourceB);
|
||||
} catch (EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
@@ -2192,7 +2191,8 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Test creating a data source with an invalid case ID
|
||||
try {
|
||||
CorrelationDataSource temp = new CorrelationDataSource(5000, "tempID", "tempName");
|
||||
CorrelationCase correlationCase = new CorrelationCase("1", "test");
|
||||
CorrelationDataSource temp = new CorrelationDataSource(correlationCase, "tempID", "tempName");
|
||||
EamDb.getInstance().newDataSource(temp);
|
||||
Assert.fail("newDataSource did not throw exception from invalid case ID");
|
||||
} catch (EamDbException ex) {
|
||||
@@ -2201,7 +2201,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Test creating a data source with null device ID
|
||||
try {
|
||||
CorrelationDataSource temp = new CorrelationDataSource(case2.getID(), null, "tempName");
|
||||
CorrelationDataSource temp = new CorrelationDataSource(case2, null, "tempName");
|
||||
EamDb.getInstance().newDataSource(temp);
|
||||
Assert.fail("newDataSource did not throw exception from null device ID");
|
||||
} catch (EamDbException ex) {
|
||||
@@ -2210,7 +2210,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
|
||||
// Test creating a data source with null name
|
||||
try {
|
||||
CorrelationDataSource temp = new CorrelationDataSource(case2.getID(), "tempID", null);
|
||||
CorrelationDataSource temp = new CorrelationDataSource(case2, "tempID", null);
|
||||
EamDb.getInstance().newDataSource(temp);
|
||||
Assert.fail("newDataSource did not throw exception from null name");
|
||||
} catch (EamDbException ex) {
|
||||
@@ -2489,7 +2489,7 @@ public class CentralRepoDatamodelTest extends TestCase {
|
||||
List<CorrelationCase> cases = new ArrayList<>();
|
||||
String bulkTestUuid = "bulkTestUUID_";
|
||||
String bulkTestName = "bulkTestName_";
|
||||
for (int i = 0; i < dbSettingsSqlite.getBulkThreshold() * 1.5; i++) {
|
||||
for (int i = 0; i < DEFAULT_BULK_THRESHOLD * 1.5; i++) {
|
||||
String name = bulkTestUuid + String.valueOf(i);
|
||||
String uuid = bulkTestName + String.valueOf(i);
|
||||
cases.add(new CorrelationCase(uuid, name));
|
||||
|
||||
Reference in New Issue
Block a user