mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 01:07:42 +00:00
Finished updating settings code
This commit is contained in:
parent
82cb5fa8e3
commit
2305664e11
@ -237,7 +237,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
return new HashDb(handle, info.getHashSetName(), info.getSearchDuringIngest(), info.getSendIngestMessages(),
|
||||
info.getKnownFilesType());
|
||||
} else if(info.isCentralRepoDatabaseType()){
|
||||
throw new TskCoreException("Not done");
|
||||
throw new TskCoreException("Not implemented yet");
|
||||
}
|
||||
throw new TskCoreException("Invalid database type in HashDbInfo");
|
||||
}
|
||||
@ -780,15 +780,7 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
|
||||
@Override
|
||||
public DatabaseType getDatabaseType(){
|
||||
if(this instanceof HashDb){
|
||||
return DatabaseType.FILE;
|
||||
} else {
|
||||
return DatabaseType.CENTRAL_REPOSITORY;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasIndexFile() {
|
||||
return true;
|
||||
return DatabaseType.FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -988,12 +980,6 @@ public class HashDbManager implements PropertyChangeListener {
|
||||
if (!Objects.equals(this.hashSetName, other.hashSetName)) {
|
||||
return false;
|
||||
}
|
||||
if (this.searchDuringIngest != other.searchDuringIngest) {
|
||||
return false;
|
||||
}
|
||||
if (this.sendIngestMessages != other.sendIngestMessages) {
|
||||
return false;
|
||||
}
|
||||
if (this.knownFilesType != other.knownFilesType) {
|
||||
return false;
|
||||
}
|
||||
|
@ -60,20 +60,9 @@ public class HashLookupModuleFactory extends IngestModuleFactoryAdapter {
|
||||
@Override
|
||||
public IngestModuleIngestJobSettings getDefaultIngestJobSettings() {
|
||||
// All available hash sets are enabled and always calculate hashes is true by default.
|
||||
//HashDbManager hashDbManager = HashDbManager.getInstance();
|
||||
//List<String> knownHashSetNames = getHashSetNames(hashDbManager.getKnownFileHashSets());
|
||||
//List<String> knownBadHashSetNames = getHashSetNames(hashDbManager.getKnownBadFileHashSets());
|
||||
return new HashLookupModuleSettings(true, HashDbManager.getInstance().getAllHashSetsNew());
|
||||
}
|
||||
|
||||
private List<String> getHashSetNames(List<HashDbManager.HashDb> hashDbs) {
|
||||
List<String> hashSetNames = new ArrayList<>();
|
||||
for (HashDbManager.HashDb db : hashDbs) {
|
||||
hashSetNames.add(db.getHashSetName());
|
||||
}
|
||||
return hashSetNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasIngestJobSettingsPanel() {
|
||||
return true;
|
||||
|
@ -24,8 +24,10 @@ import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.io.IOException;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashLookupSettings.HashDbInfo;
|
||||
|
||||
/**
|
||||
* Ingest job settings for the hash lookup module.
|
||||
@ -33,12 +35,12 @@ import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase;
|
||||
final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private HashSet<String> namesOfEnabledKnownHashSets;
|
||||
private HashSet<String> namesOfDisabledKnownHashSets; // Added in version 1.1
|
||||
private HashSet<String> namesOfEnabledKnownBadHashSets;
|
||||
private HashSet<String> namesOfDisabledKnownBadHashSets; // Added in version 1.1
|
||||
private HashSet<String> namesOfEnabledKnownHashSets; // The four lists of hash set names are only used for upgrading
|
||||
private HashSet<String> namesOfDisabledKnownHashSets; // from older settings files. All data should be stored in
|
||||
private HashSet<String> namesOfEnabledKnownBadHashSets; // the databaseInfoList list.
|
||||
private HashSet<String> namesOfDisabledKnownBadHashSets;
|
||||
private boolean shouldCalculateHashes = true;
|
||||
private List<HashLookupSettings.HashDbInfo> databaseInfoList;
|
||||
private List<HashDbInfo> databaseInfoList;
|
||||
|
||||
HashLookupModuleSettings(boolean shouldCalculateHashes, List<HashDatabase> hashDbList){
|
||||
this.shouldCalculateHashes = shouldCalculateHashes;
|
||||
@ -52,7 +54,7 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
|
||||
/**
|
||||
* This overrides the default deserialization code so we can
|
||||
* copy the enabled/disabled status into the DatabaseType objects
|
||||
* copy the enabled/disabled status into the DatabaseType objects.
|
||||
* @param stream
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
@ -69,24 +71,34 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
*
|
||||
* @param shouldCalculateHashes Whether or not hashes should be
|
||||
* calculated.
|
||||
* @param namesOfEnabledKnownHashSets A list of enabled known hash sets.
|
||||
* @param namesOfEnabledKnownBadHashSets A list of enabled notable hash
|
||||
* sets.
|
||||
* @param namesOfDisabledKnownHashSets A list of disabled known hash
|
||||
* sets.
|
||||
* @param namesOfDisabledKnownBadHashSets A list of disabled notable hash
|
||||
* sets.
|
||||
* @param enabledHashSets A list of enabled hash sets.
|
||||
* @param disabledHashSets A list of disabled hash sets.
|
||||
*/
|
||||
HashLookupModuleSettings(boolean shouldCalculateHashes,
|
||||
List<String> namesOfEnabledKnownHashSets,
|
||||
List<String> namesOfEnabledKnownBadHashSets,
|
||||
List<String> namesOfDisabledKnownHashSets,
|
||||
List<String> namesOfDisabledKnownBadHashSets) {
|
||||
List<HashDatabase> enabledHashSets,
|
||||
List<HashDatabase> disabledHashSets) {
|
||||
this.shouldCalculateHashes = shouldCalculateHashes;
|
||||
this.namesOfEnabledKnownHashSets = new HashSet<>(namesOfEnabledKnownHashSets);
|
||||
this.namesOfEnabledKnownBadHashSets = new HashSet<>(namesOfEnabledKnownBadHashSets);
|
||||
this.namesOfDisabledKnownHashSets = new HashSet<>(namesOfDisabledKnownHashSets);
|
||||
this.namesOfDisabledKnownBadHashSets = new HashSet<>(namesOfDisabledKnownBadHashSets);
|
||||
|
||||
databaseInfoList = new ArrayList<>();
|
||||
for(HashDatabase db:enabledHashSets){
|
||||
try{
|
||||
HashDbInfo dbInfo = new HashDbInfo(db);
|
||||
dbInfo.setSearchDuringIngest(true);
|
||||
databaseInfoList.add(dbInfo);
|
||||
} catch (TskCoreException ex){
|
||||
Logger.getLogger(HashLookupModuleSettings.class.getName()).log(Level.SEVERE, "Error creating hash database settings for " + db.getHashSetName(), ex); //NON-NLS
|
||||
}
|
||||
}
|
||||
for(HashDatabase db:disabledHashSets){
|
||||
try{
|
||||
HashDbInfo dbInfo = new HashDbInfo(db);
|
||||
dbInfo.setSearchDuringIngest(false);
|
||||
databaseInfoList.add(dbInfo);
|
||||
} catch (TskCoreException ex){
|
||||
Logger.getLogger(HashLookupModuleSettings.class.getName()).log(Level.SEVERE, "Error creating hash database settings for " + db.getHashSetName(), ex); //NON-NLS
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +106,6 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
*/
|
||||
@Override
|
||||
public long getVersionNumber() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return HashLookupModuleSettings.serialVersionUID;
|
||||
}
|
||||
|
||||
@ -105,7 +116,6 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
* @return True if hashes are to be calculated, false otherwise.
|
||||
*/
|
||||
boolean shouldCalculateHashes() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return this.shouldCalculateHashes;
|
||||
}
|
||||
|
||||
@ -118,50 +128,14 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
* @return True if the hash set is enabled, false otherwise.
|
||||
*/
|
||||
boolean isHashSetEnabled(HashDatabase db) {
|
||||
//this.upgradeFromOlderVersions();
|
||||
// TEMP TEMP TEMP TEMP
|
||||
return db.getSearchDuringIngest();
|
||||
//return !(this.namesOfDisabledKnownHashSets.contains(hashSetName) || this.namesOfDisabledKnownBadHashSets.contains(hashSetName));
|
||||
}
|
||||
for(HashDbInfo dbInfo:databaseInfoList){
|
||||
if(dbInfo.matches(db)){
|
||||
return dbInfo.getSearchDuringIngest();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of all explicitly enabled known files hash sets.
|
||||
*
|
||||
* @return The list of names.
|
||||
*/
|
||||
List<String> getNamesOfEnabledKnownHashSets() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return new ArrayList<>(this.namesOfEnabledKnownHashSets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of all explicitly disabled known files hash sets.
|
||||
*
|
||||
* @return The list of names.
|
||||
*/
|
||||
List<String> getNamesOfDisabledKnownHashSets() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return new ArrayList<>(namesOfDisabledKnownHashSets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of all explicitly enabled notable files hash sets.
|
||||
*
|
||||
* @return The list of names.
|
||||
*/
|
||||
List<String> getNamesOfEnabledKnownBadHashSets() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return new ArrayList<>(this.namesOfEnabledKnownBadHashSets);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of all explicitly disabled notable files hash sets.
|
||||
*
|
||||
* @return The list of names.
|
||||
*/
|
||||
List<String> getNamesOfDisabledKnownBadHashSets() {
|
||||
this.upgradeFromOlderVersions();
|
||||
return new ArrayList<>(this.namesOfDisabledKnownBadHashSets);
|
||||
// We didn't find it, so return true
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,10 +143,8 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
* compatible, version of this class is de-serialized.
|
||||
*/
|
||||
private void upgradeFromOlderVersions() {
|
||||
System.out.println("upgradeFromOlderVersions");
|
||||
|
||||
if(databaseInfoList != null){
|
||||
System.out.println(" No upgrade needed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -192,7 +164,7 @@ final class HashLookupModuleSettings implements IngestModuleIngestJobSettings {
|
||||
}
|
||||
|
||||
for(HashLookupSettings.HashDbInfo db:databaseInfoList){
|
||||
if(disabledHashSetNames.contains(db.getHashSetName())){
|
||||
if(db.isFileDatabaseType() && disabledHashSetNames.contains(db.getHashSetName())){
|
||||
db.setSearchDuringIngest(false);
|
||||
} else {
|
||||
db.setSearchDuringIngest(true);
|
||||
|
@ -21,9 +21,7 @@ package org.sleuthkit.autopsy.modules.hashdatabase;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
@ -102,23 +100,20 @@ public final class HashLookupModuleSettingsPanel extends IngestModuleIngestJobSe
|
||||
|
||||
@Override
|
||||
public IngestModuleIngestJobSettings getSettings() {
|
||||
List<String> enabledKnownHashSetNames = new ArrayList<>();
|
||||
List<String> disabledKnownHashSetNames = new ArrayList<>();
|
||||
List<String> enabledKnownBadHashSetNames = new ArrayList<>();
|
||||
List<String> disabledKnownBadHashSetNames = new ArrayList<>();
|
||||
getHashSetNames(knownHashSetModels, enabledKnownHashSetNames, disabledKnownHashSetNames);
|
||||
getHashSetNames(knownBadHashSetModels, enabledKnownBadHashSetNames, disabledKnownBadHashSetNames);
|
||||
List<HashDatabase> enabledHashSets = new ArrayList<>();
|
||||
List<HashDatabase> disabledHashSets = new ArrayList<>();
|
||||
addHashSets(knownHashSetModels, enabledHashSets, disabledHashSets);
|
||||
addHashSets(knownBadHashSetModels, enabledHashSets, disabledHashSets);
|
||||
return new HashLookupModuleSettings(alwaysCalcHashesCheckbox.isSelected(),
|
||||
enabledKnownHashSetNames, enabledKnownBadHashSetNames,
|
||||
disabledKnownHashSetNames, disabledKnownBadHashSetNames);
|
||||
enabledHashSets, disabledHashSets);
|
||||
}
|
||||
|
||||
private void getHashSetNames(List<HashSetModel> hashSetModels, List<String> enabledHashSetNames, List<String> disabledHashSetNames) {
|
||||
private void addHashSets(List<HashSetModel> hashSetModels, List<HashDatabase> enabledHashSets, List<HashDatabase> disabledHashSets) {
|
||||
for (HashSetModel model : hashSetModels) {
|
||||
if (model.isEnabled() && model.isValid()) {
|
||||
enabledHashSetNames.add(model.getName());
|
||||
enabledHashSets.add(model.getDatabase());
|
||||
} else {
|
||||
disabledHashSetNames.add(model.getName());
|
||||
disabledHashSets.add(model.getDatabase());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,17 +131,21 @@ public final class HashLookupModuleSettingsPanel extends IngestModuleIngestJobSe
|
||||
|
||||
void updateHashSetModels(List<HashDatabase> hashDbs, List<HashSetModel> hashSetModels) {
|
||||
|
||||
// TEMP TEMP SKIP TEMP
|
||||
/*
|
||||
List<HashDatabase> hashDatabases = new ArrayList<>(hashDbs);
|
||||
|
||||
// Update the hash sets and detect deletions.
|
||||
List<HashSetModel> deletedHashSetModels = new ArrayList<>();
|
||||
for (HashSetModel model : hashSetModels) {
|
||||
String hashSetName = model.getName();
|
||||
if (hashSetDbs.containsKey(hashSetName)) {
|
||||
HashDb db = hashSetDbs.get(hashSetName);
|
||||
model.setIndexed(isHashDbValid(db));
|
||||
hashSetDbs.remove(hashSetName);
|
||||
} else {
|
||||
boolean foundDatabase = false;
|
||||
for(HashDatabase db : hashDatabases){
|
||||
if(model.getDatabase().equals(db)){
|
||||
model.setValid(isHashDbValid(db));
|
||||
hashDatabases.remove(db);
|
||||
foundDatabase = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(! foundDatabase){
|
||||
deletedHashSetModels.add(model);
|
||||
}
|
||||
}
|
||||
@ -157,10 +156,9 @@ public final class HashLookupModuleSettingsPanel extends IngestModuleIngestJobSe
|
||||
}
|
||||
|
||||
// Add any new hash sets. All new sets are enabled by default.
|
||||
for (HashDb db : hashSetDbs.values()) {
|
||||
String name = db.getHashSetName();
|
||||
hashSetModels.add(new HashSetModel(name, true, isHashDbValid(db)));
|
||||
}*/
|
||||
for (HashDatabase db : hashDatabases) {
|
||||
hashSetModels.add(new HashSetModel(db, true, isHashDbValid(db)));
|
||||
}
|
||||
}
|
||||
|
||||
void reset(HashLookupModuleSettings newSettings) {
|
||||
|
@ -25,6 +25,7 @@ import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@ -35,6 +36,7 @@ import org.sleuthkit.autopsy.core.RuntimeProperties;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||
import org.sleuthkit.autopsy.coreutils.XMLUtil;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDatabase.DatabaseType;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.w3c.dom.Document;
|
||||
@ -434,6 +436,74 @@ final class HashLookupSettings implements Serializable {
|
||||
return dbType == DatabaseType.CENTRAL_REPOSITORY;
|
||||
}
|
||||
|
||||
boolean matches(HashDatabase hashDb){
|
||||
if(hashDb == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ! this.knownFilesType.equals(hashDb.getKnownFilesType())){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ! this.dbType.equals(hashDb.getDatabaseType())){
|
||||
return false;
|
||||
}
|
||||
|
||||
if( ! this.hashSetName.equals(hashDb.getHashSetName())){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.dbType.equals(DatabaseType.FILE)){
|
||||
// FILE types will always have unique names, so no more testing required
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO TODO central repo check
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final HashDbInfo other = (HashDbInfo) obj;
|
||||
|
||||
if(! this.dbType.equals(other.dbType)){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.dbType.equals(DatabaseType.FILE)){
|
||||
// For files, we expect the name and known type to match
|
||||
return (this.hashSetName.equals(other.hashSetName)
|
||||
&& this.knownFilesType.equals(other.knownFilesType));
|
||||
} else {
|
||||
// For central repo, the name, index, and known files type should match
|
||||
return (this.hashSetName.equals(other.hashSetName)
|
||||
&& (this.centralRepoIndex == other.centralRepoIndex)
|
||||
&& this.knownFilesType.equals(other.knownFilesType));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 89 * hash + Objects.hashCode(this.hashSetName);
|
||||
hash = 89 * hash + Objects.hashCode(this.knownFilesType);
|
||||
hash = 89 * hash + Objects.hashCode(this.dbType);
|
||||
if(this.dbType.equals(DatabaseType.CENTRAL_REPOSITORY)){
|
||||
hash = 89 * hash + this.centralRepoIndex;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* This overrides the default deserialization code so we can
|
||||
* properly set the dbType enum and other new fields
|
||||
|
@ -392,6 +392,11 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
}
|
||||
}
|
||||
|
||||
public void selectRowByDatabase(HashDatabase db){
|
||||
setSelection(hashSetTableModel.getIndexByDatabase(db));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void selectRowByName(String name) {
|
||||
setSelection(hashSetTableModel.getIndexByName(name));
|
||||
}
|
||||
@ -458,6 +463,16 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
}
|
||||
}
|
||||
|
||||
int getIndexByDatabase(HashDatabase db){
|
||||
for (int i = 0; i < hashSets.size(); ++i) {
|
||||
if (hashSets.get(i).equals(db)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
int getIndexByName(String name) {
|
||||
for (int i = 0; i < hashSets.size(); ++i) {
|
||||
if (hashSets.get(i).getHashSetName().equals(name)) {
|
||||
@ -797,7 +812,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
HashDatabase hashDb = new HashDbCreateDatabaseDialog().getHashDatabase();
|
||||
if (null != hashDb) {
|
||||
hashSetTableModel.refreshModel();
|
||||
((HashSetTable) hashSetTable).selectRowByName(hashDb.getHashSetName());
|
||||
((HashSetTable) hashSetTable).selectRowByDatabase(hashDb);
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
}
|
||||
}//GEN-LAST:event_createDatabaseButtonActionPerformed
|
||||
@ -844,7 +859,7 @@ public final class HashLookupSettingsPanel extends IngestModuleGlobalSettingsPan
|
||||
HashDatabase hashDb = new HashDbImportDatabaseDialog().getHashDatabase();
|
||||
if (null != hashDb) {
|
||||
hashSetTableModel.refreshModel();
|
||||
((HashSetTable) hashSetTable).selectRowByName(hashDb.getHashSetName());
|
||||
((HashSetTable) hashSetTable).selectRowByDatabase(hashDb);
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
}
|
||||
}//GEN-LAST:event_importDatabaseButtonActionPerformed
|
||||
|
Loading…
x
Reference in New Issue
Block a user