mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
Made hashset configuration save if malformed file is currently there.
This commit is contained in:
parent
914b1e747a
commit
cb19a0c555
@ -499,30 +499,30 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
hashDatabases.clear();
|
hashDatabases.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean loadHashsetsConfiguration() {
|
private void loadHashsetsConfiguration() {
|
||||||
try {
|
try {
|
||||||
HashLookupSettings settings = HashLookupSettings.readSettings();
|
HashLookupSettings settings = HashLookupSettings.readSettings();
|
||||||
if (settings != null) {
|
if (settings != null) {
|
||||||
this.configureSettings(settings);
|
this.configureSettings(settings);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} catch (HashLookupSettings.HashLookupSettingsException ex) {
|
} catch (HashLookupSettings.HashLookupSettingsException ex) {
|
||||||
Logger.getLogger(HashDbManager.class.getName()).log(Level.WARNING, "Could not read Hash lookup settings from disk.", ex);
|
Logger.getLogger(HashDbManager.class.getName()).log(Level.WARNING, "Could not read Hash lookup settings from disk.", ex);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Messages({"# {0} - database name", "HashDbManager.noDbPath.message=Couldn't get valid database path for: {0}"})
|
@Messages({"# {0} - database name", "HashDbManager.noDbPath.message=Couldn't get valid database path for: {0}",
|
||||||
|
"HashDbManager.noOverwrite.message=Could not overwrite hash database settings."})
|
||||||
private void configureSettings(HashLookupSettings settings) {
|
private void configureSettings(HashLookupSettings settings) {
|
||||||
|
boolean missedPath = false;
|
||||||
List<HashDbInfo> hashDbInfoList = settings.getHashDbInfo();
|
List<HashDbInfo> hashDbInfoList = settings.getHashDbInfo();
|
||||||
for (HashDbInfo hashDb : hashDbInfoList) {
|
for (HashDbInfo hashDb : hashDbInfoList) {
|
||||||
try {
|
try {
|
||||||
String dbPath = this.getValidFilePath(hashDb.getHashSetName(), hashDb.getPath());
|
String dbPath = this.getValidFilePath(hashDb.getHashSetName(), hashDb.getPath());
|
||||||
if (dbPath != null) {
|
if (dbPath != null) {
|
||||||
addExistingHashDatabaseInternal(hashDb.getHashSetName(), getValidFilePath(hashDb.getHashSetName(), hashDb.getPath()), hashDb.getSearchDuringIngest(), hashDb.getSendIngestMessages(), hashDb.getKnownFilesType());
|
addExistingHashDatabaseInternal(hashDb.getHashSetName(), getValidFilePath(hashDb.getHashSetName(), hashDb.getPath()), hashDb.getSearchDuringIngest(), hashDb.getSendIngestMessages(), hashDb.getKnownFilesType());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
logger.log(Level.WARNING, Bundle.HashDbManager_noDbPath_message(hashDb.getHashSetName()));
|
logger.log(Level.WARNING, Bundle.HashDbManager_noDbPath_message(hashDb.getHashSetName()));
|
||||||
|
missedPath = true;
|
||||||
}
|
}
|
||||||
} catch (HashDbManagerException | TskCoreException ex) {
|
} catch (HashDbManagerException | TskCoreException ex) {
|
||||||
Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error opening hash database", ex); //NON-NLS
|
Logger.getLogger(HashDbManager.class.getName()).log(Level.SEVERE, "Error opening hash database", ex); //NON-NLS
|
||||||
@ -531,6 +531,14 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
"HashDbManager.unableToOpenHashDbMsg", hashDb.getHashSetName()),
|
"HashDbManager.unableToOpenHashDbMsg", hashDb.getHashSetName()),
|
||||||
NbBundle.getMessage(this.getClass(), "HashDbManager.openHashDbErr"),
|
NbBundle.getMessage(this.getClass(), "HashDbManager.openHashDbErr"),
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
missedPath = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (missedPath) {
|
||||||
|
try {
|
||||||
|
HashLookupSettings.writeSettings(new HashLookupSettings(this.knownHashSets, this.knownBadHashSets));
|
||||||
|
} catch (HashLookupSettings.HashLookupSettingsException ex) {
|
||||||
|
logger.log(Level.WARNING, Bundle.HashDbManager_noOverwrite_message());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -614,11 +622,11 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
INDEXING_DONE
|
INDEXING_DONE
|
||||||
}
|
}
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private int handle;
|
private final int handle;
|
||||||
private String hashSetName;
|
private final String hashSetName;
|
||||||
private boolean searchDuringIngest;
|
private boolean searchDuringIngest;
|
||||||
private boolean sendIngestMessages;
|
private boolean sendIngestMessages;
|
||||||
private KnownFilesType knownFilesType;
|
private final KnownFilesType knownFilesType;
|
||||||
private boolean indexing;
|
private boolean indexing;
|
||||||
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
||||||
|
|
||||||
@ -633,6 +641,8 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a listener for the events defined in HashDb.Event.
|
* Adds a listener for the events defined in HashDb.Event.
|
||||||
|
*
|
||||||
|
* @param pcl
|
||||||
*/
|
*/
|
||||||
public void addPropertyChangeListener(PropertyChangeListener pcl) {
|
public void addPropertyChangeListener(PropertyChangeListener pcl) {
|
||||||
propertyChangeSupport.addPropertyChangeListener(pcl);
|
propertyChangeSupport.addPropertyChangeListener(pcl);
|
||||||
@ -640,6 +650,8 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a listener for the events defined in HashDb.Event.
|
* Removes a listener for the events defined in HashDb.Event.
|
||||||
|
*
|
||||||
|
* @param pcl
|
||||||
*/
|
*/
|
||||||
public void removePropertyChangeListener(PropertyChangeListener pcl) {
|
public void removePropertyChangeListener(PropertyChangeListener pcl) {
|
||||||
propertyChangeSupport.removePropertyChangeListener(pcl);
|
propertyChangeSupport.removePropertyChangeListener(pcl);
|
||||||
@ -681,6 +693,8 @@ public class HashDbManager implements PropertyChangeListener {
|
|||||||
* Indicates whether the hash database accepts updates.
|
* Indicates whether the hash database accepts updates.
|
||||||
*
|
*
|
||||||
* @return True if the database accepts updates, false otherwise.
|
* @return True if the database accepts updates, false otherwise.
|
||||||
|
*
|
||||||
|
* @throws org.sleuthkit.datamodel.TskCoreException
|
||||||
*/
|
*/
|
||||||
public boolean isUpdateable() throws TskCoreException {
|
public boolean isUpdateable() throws TskCoreException {
|
||||||
return SleuthkitJNI.isUpdateableHashDatabase(this.handle);
|
return SleuthkitJNI.isUpdateableHashDatabase(this.handle);
|
||||||
|
@ -26,9 +26,7 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.io.NbObjectInputStream;
|
import org.openide.util.io.NbObjectInputStream;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user