mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
2197 can no longer create profiles with out of date filters
This commit is contained in:
parent
5fc2d75476
commit
6246f5e9cd
@ -21,6 +21,9 @@ package org.sleuthkit.autopsy.ingest;
|
||||
import java.awt.EventQueue;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
||||
import org.sleuthkit.autopsy.modules.interestingitems.FilesSetDefsPanel;
|
||||
@ -66,6 +69,21 @@ class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implements Opti
|
||||
filterPanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.fileFiltersTab.toolTipText"), 1);
|
||||
tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.text"), null,
|
||||
profilePanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.toolTipText"), 2);
|
||||
//Listener for when tabbed panes are switched, because we can have two file filter definitions panels open at the same time
|
||||
//we may wind up in a situation where the user has created and saved one in the profiles panel
|
||||
//so we need to refresh the filterPanel in those cases before proceeding.
|
||||
tabbedPane.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
if (e.getSource() instanceof JTabbedPane) {
|
||||
profilePanel.shouldFiltersBeRefreshed();
|
||||
{
|
||||
filterPanel.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addIngestJobEventsListener();
|
||||
enableTabs();
|
||||
}
|
||||
@ -135,6 +153,10 @@ class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implements Opti
|
||||
*/
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
//if a new filter was created in the profilePanel we don't want to save over it accidently
|
||||
if (profilePanel.shouldFiltersBeRefreshed()) {
|
||||
filterPanel.load();
|
||||
}
|
||||
filterPanel.store();
|
||||
settingsPanel.store();
|
||||
profilePanel.store();
|
||||
|
@ -22,7 +22,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.TreeMap;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@ -109,10 +108,17 @@ class IngestProfileMap {
|
||||
return IngestJobSettings.getEnabledModulesKey();
|
||||
}
|
||||
|
||||
IngestProfile(String name, String desc, String selected) {
|
||||
/**
|
||||
* Creates a new IngestProfile
|
||||
*
|
||||
* @param name - unique name of the profile
|
||||
* @param desc - optional description of profile
|
||||
* @param selectedFilter - the File Ingest Filter used for this profile
|
||||
*/
|
||||
IngestProfile(String name, String desc, String selectedFilter) {
|
||||
this.name = name;
|
||||
this.description = desc;
|
||||
this.fileIngestFilter = selected;
|
||||
this.fileIngestFilter = selectedFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,7 @@ import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.ingest.IngestProfileMap.IngestProfile;
|
||||
|
||||
/**
|
||||
* Panel to display options for profile creation.
|
||||
* Panel to display options for profile creation and editing.
|
||||
*/
|
||||
class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
||||
|
||||
@ -35,7 +35,7 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
||||
"ProfilePanel.messages.profilesMustBeNamed=Ingest profile must be named."})
|
||||
|
||||
private final IngestJobSettingsPanel ingestSettingsPanel;
|
||||
private final IngestJobSettings tempSettings;
|
||||
private final IngestJobSettings settings;
|
||||
private IngestProfile profile;
|
||||
private final static String NEW_PROFILE_NAME = NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.newProfileText");
|
||||
|
||||
@ -44,8 +44,8 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
||||
*/
|
||||
ProfilePanel() {
|
||||
initComponents();
|
||||
tempSettings = new IngestJobSettings(NEW_PROFILE_NAME);
|
||||
ingestSettingsPanel = new IngestJobSettingsPanel(tempSettings);
|
||||
settings = new IngestJobSettings(NEW_PROFILE_NAME);
|
||||
ingestSettingsPanel = new IngestJobSettingsPanel(settings);
|
||||
ingestSettingsPanel.setPastJobsButtonVisible(false);
|
||||
jPanel1.add(ingestSettingsPanel, 0);
|
||||
|
||||
@ -56,8 +56,8 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
||||
profile = selectedProfile;
|
||||
profileDescArea.setText(profile.getDescription());
|
||||
profileNameField.setText(profile.getName());
|
||||
tempSettings = new IngestJobSettings(selectedProfile.getName());
|
||||
ingestSettingsPanel = new IngestJobSettingsPanel(tempSettings);
|
||||
settings = new IngestJobSettings(selectedProfile.getName());
|
||||
ingestSettingsPanel = new IngestJobSettingsPanel(settings);
|
||||
ingestSettingsPanel.setPastJobsButtonVisible(false);
|
||||
jPanel1.add(ingestSettingsPanel, 0);
|
||||
}
|
||||
@ -65,6 +65,14 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
||||
String getProfileName(){
|
||||
return profileNameField.getText();
|
||||
}
|
||||
|
||||
String getProfileDesc(){
|
||||
return profileDescArea.getText();
|
||||
}
|
||||
|
||||
IngestJobSettings getSettings(){
|
||||
return ingestSettingsPanel.getSettings();
|
||||
}
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
@ -157,7 +165,7 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
if (profile == null) {
|
||||
IngestProfile.renameProfile(tempSettings.getExecutionContext(), profileNameField.getText());
|
||||
IngestProfile.renameProfile(settings.getExecutionContext(), profileNameField.getText());
|
||||
} else if (!profile.getName().equals(profileNameField.getText())) {
|
||||
IngestProfile.renameProfile(profile.getName(), profileNameField.getText());
|
||||
}
|
||||
|
@ -48,12 +48,15 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
})
|
||||
|
||||
private final DefaultListModel<IngestProfile> profilesListModel = new DefaultListModel<>();
|
||||
|
||||
private TreeMap<String, IngestProfile> profiles;
|
||||
private ProfilePanel panel;
|
||||
private boolean filtersShouldBeRefreshed;
|
||||
/**
|
||||
* Creates new form ProfileOptionsPanel
|
||||
*/
|
||||
ProfileSettingsPanel() {
|
||||
initComponents();
|
||||
this.filtersShouldBeRefreshed = false;
|
||||
this.profileList.setModel(profilesListModel);
|
||||
this.profileList.addListSelectionListener(new ProfileSettingsPanel.ProfileListSelectionListener());
|
||||
ingestWarningLabel.setVisible(false);
|
||||
@ -261,6 +264,20 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||
}//GEN-LAST:event_deleteProfileButtonActionPerformed
|
||||
|
||||
/**
|
||||
* Returns whether there were possible changes to the filter list since the last time
|
||||
* this was called.
|
||||
*
|
||||
* Resets value to false after being called.
|
||||
*
|
||||
* @return true or false
|
||||
*/
|
||||
boolean shouldFiltersBeRefreshed(){
|
||||
boolean shouldRefresh = filtersShouldBeRefreshed;
|
||||
filtersShouldBeRefreshed = false;
|
||||
return shouldRefresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable / disable buttons, so they can be disabled while ingest is
|
||||
* running.
|
||||
@ -319,8 +336,7 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
* @param selectedProfile
|
||||
*/
|
||||
private void doProfileDialog(IngestProfile selectedProfile) {
|
||||
// Create a files set defintion panle.
|
||||
ProfilePanel panel;
|
||||
// Create a files set defintion panel.
|
||||
if (selectedProfile != null) {
|
||||
// Editing an existing set definition.
|
||||
panel = new ProfilePanel(selectedProfile);
|
||||
@ -334,16 +350,16 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
option = JOptionPane.showConfirmDialog(null, panel, Bundle.ProfileSettingsPanel_title(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||
} while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
|
||||
|
||||
TreeMap<String, IngestProfile> profileMap = new IngestProfileMap().getIngestProfileMap();
|
||||
|
||||
if (profileMap.containsKey(panel.getProfileName()) && selectedProfile == null) {
|
||||
// While adding new profile(selectedPRofile == null), if a profile with same name already exists, do not add to the profiles hashMap.
|
||||
// In case of editing an existing profile(selectedProfile != null), following check is not performed.
|
||||
if (this.profiles.containsKey(panel.getProfileName()) && selectedProfile == null) {
|
||||
MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
|
||||
"ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text",
|
||||
panel.getProfileName()));
|
||||
return;
|
||||
}
|
||||
if (option == JOptionPane.OK_OPTION) {
|
||||
panel.saveSettings();
|
||||
this.saveSettings();
|
||||
load();
|
||||
}
|
||||
|
||||
@ -351,12 +367,12 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
|
||||
@Override
|
||||
public void saveSettings() {
|
||||
|
||||
this.store();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void store() {
|
||||
|
||||
panel.saveSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,17 +380,17 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
||||
*/
|
||||
@Override
|
||||
public void load() {
|
||||
int currentIndex = profileList.getSelectedIndex();
|
||||
profilesListModel.clear();
|
||||
IngestProfileMap profileMap = new IngestProfileMap();
|
||||
for (IngestProfile profile : profileMap.getIngestProfileMap().values()) {
|
||||
int currentIndex = this.profileList.getSelectedIndex();
|
||||
this.profilesListModel.clear();
|
||||
this.profiles = new IngestProfileMap().getIngestProfileMap();
|
||||
for (IngestProfile profile : this.profiles.values()) {
|
||||
profilesListModel.addElement(profile);
|
||||
}
|
||||
if (currentIndex < 0 || currentIndex >= profilesListModel.getSize()) {
|
||||
currentIndex = 0;
|
||||
}
|
||||
refreshEditDeleteButtons();
|
||||
profileList.setSelectedIndex(currentIndex);
|
||||
this.profileList.setSelectedIndex(currentIndex);
|
||||
}
|
||||
|
||||
private final class ProfileListSelectionListener implements ListSelectionListener {
|
||||
|
Loading…
x
Reference in New Issue
Block a user