mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +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.awt.EventQueue;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
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.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
||||||
import org.sleuthkit.autopsy.modules.interestingitems.FilesSetDefsPanel;
|
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);
|
filterPanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.fileFiltersTab.toolTipText"), 1);
|
||||||
tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.text"), null,
|
tabbedPane.insertTab(NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.text"), null,
|
||||||
profilePanel, NbBundle.getMessage(IngestOptionsPanel.class, "IngestOptionsPanel.profilesTab.toolTipText"), 2);
|
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();
|
addIngestJobEventsListener();
|
||||||
enableTabs();
|
enableTabs();
|
||||||
}
|
}
|
||||||
@ -135,6 +153,10 @@ class IngestOptionsPanel extends IngestModuleGlobalSettingsPanel implements Opti
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveSettings() {
|
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();
|
filterPanel.store();
|
||||||
settingsPanel.store();
|
settingsPanel.store();
|
||||||
profilePanel.store();
|
profilePanel.store();
|
||||||
|
@ -22,7 +22,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@ -109,10 +108,17 @@ class IngestProfileMap {
|
|||||||
return IngestJobSettings.getEnabledModulesKey();
|
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.name = name;
|
||||||
this.description = desc;
|
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;
|
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 {
|
class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
|||||||
"ProfilePanel.messages.profilesMustBeNamed=Ingest profile must be named."})
|
"ProfilePanel.messages.profilesMustBeNamed=Ingest profile must be named."})
|
||||||
|
|
||||||
private final IngestJobSettingsPanel ingestSettingsPanel;
|
private final IngestJobSettingsPanel ingestSettingsPanel;
|
||||||
private final IngestJobSettings tempSettings;
|
private final IngestJobSettings settings;
|
||||||
private IngestProfile profile;
|
private IngestProfile profile;
|
||||||
private final static String NEW_PROFILE_NAME = NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.newProfileText");
|
private final static String NEW_PROFILE_NAME = NbBundle.getMessage(ProfilePanel.class, "ProfilePanel.newProfileText");
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
|||||||
*/
|
*/
|
||||||
ProfilePanel() {
|
ProfilePanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
tempSettings = new IngestJobSettings(NEW_PROFILE_NAME);
|
settings = new IngestJobSettings(NEW_PROFILE_NAME);
|
||||||
ingestSettingsPanel = new IngestJobSettingsPanel(tempSettings);
|
ingestSettingsPanel = new IngestJobSettingsPanel(settings);
|
||||||
ingestSettingsPanel.setPastJobsButtonVisible(false);
|
ingestSettingsPanel.setPastJobsButtonVisible(false);
|
||||||
jPanel1.add(ingestSettingsPanel, 0);
|
jPanel1.add(ingestSettingsPanel, 0);
|
||||||
|
|
||||||
@ -56,8 +56,8 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
|||||||
profile = selectedProfile;
|
profile = selectedProfile;
|
||||||
profileDescArea.setText(profile.getDescription());
|
profileDescArea.setText(profile.getDescription());
|
||||||
profileNameField.setText(profile.getName());
|
profileNameField.setText(profile.getName());
|
||||||
tempSettings = new IngestJobSettings(selectedProfile.getName());
|
settings = new IngestJobSettings(selectedProfile.getName());
|
||||||
ingestSettingsPanel = new IngestJobSettingsPanel(tempSettings);
|
ingestSettingsPanel = new IngestJobSettingsPanel(settings);
|
||||||
ingestSettingsPanel.setPastJobsButtonVisible(false);
|
ingestSettingsPanel.setPastJobsButtonVisible(false);
|
||||||
jPanel1.add(ingestSettingsPanel, 0);
|
jPanel1.add(ingestSettingsPanel, 0);
|
||||||
}
|
}
|
||||||
@ -65,6 +65,14 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
|||||||
String getProfileName(){
|
String getProfileName(){
|
||||||
return profileNameField.getText();
|
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.
|
* 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
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
@ -157,7 +165,7 @@ class ProfilePanel extends IngestModuleGlobalSettingsPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void saveSettings() {
|
public void saveSettings() {
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
IngestProfile.renameProfile(tempSettings.getExecutionContext(), profileNameField.getText());
|
IngestProfile.renameProfile(settings.getExecutionContext(), profileNameField.getText());
|
||||||
} else if (!profile.getName().equals(profileNameField.getText())) {
|
} else if (!profile.getName().equals(profileNameField.getText())) {
|
||||||
IngestProfile.renameProfile(profile.getName(), 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 final DefaultListModel<IngestProfile> profilesListModel = new DefaultListModel<>();
|
||||||
|
private TreeMap<String, IngestProfile> profiles;
|
||||||
|
private ProfilePanel panel;
|
||||||
|
private boolean filtersShouldBeRefreshed;
|
||||||
/**
|
/**
|
||||||
* Creates new form ProfileOptionsPanel
|
* Creates new form ProfileOptionsPanel
|
||||||
*/
|
*/
|
||||||
ProfileSettingsPanel() {
|
ProfileSettingsPanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
this.filtersShouldBeRefreshed = false;
|
||||||
this.profileList.setModel(profilesListModel);
|
this.profileList.setModel(profilesListModel);
|
||||||
this.profileList.addListSelectionListener(new ProfileSettingsPanel.ProfileListSelectionListener());
|
this.profileList.addListSelectionListener(new ProfileSettingsPanel.ProfileListSelectionListener());
|
||||||
ingestWarningLabel.setVisible(false);
|
ingestWarningLabel.setVisible(false);
|
||||||
@ -261,6 +264,20 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
|||||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||||
}//GEN-LAST:event_deleteProfileButtonActionPerformed
|
}//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
|
* Enable / disable buttons, so they can be disabled while ingest is
|
||||||
* running.
|
* running.
|
||||||
@ -319,8 +336,7 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
|||||||
* @param selectedProfile
|
* @param selectedProfile
|
||||||
*/
|
*/
|
||||||
private void doProfileDialog(IngestProfile selectedProfile) {
|
private void doProfileDialog(IngestProfile selectedProfile) {
|
||||||
// Create a files set defintion panle.
|
// Create a files set defintion panel.
|
||||||
ProfilePanel panel;
|
|
||||||
if (selectedProfile != null) {
|
if (selectedProfile != null) {
|
||||||
// Editing an existing set definition.
|
// Editing an existing set definition.
|
||||||
panel = new ProfilePanel(selectedProfile);
|
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);
|
option = JOptionPane.showConfirmDialog(null, panel, Bundle.ProfileSettingsPanel_title(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
|
||||||
} while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
|
} while (option == JOptionPane.OK_OPTION && !panel.isValidDefinition());
|
||||||
|
|
||||||
TreeMap<String, IngestProfile> profileMap = new IngestProfileMap().getIngestProfileMap();
|
// 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 (profileMap.containsKey(panel.getProfileName()) && selectedProfile == null) {
|
if (this.profiles.containsKey(panel.getProfileName()) && selectedProfile == null) {
|
||||||
MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
|
MessageNotifyUtil.Message.error(NbBundle.getMessage(this.getClass(),
|
||||||
"ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text",
|
"ProfileSettingsPanel.doFileSetsDialog.duplicateProfile.text",
|
||||||
panel.getProfileName()));
|
panel.getProfileName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (option == JOptionPane.OK_OPTION) {
|
if (option == JOptionPane.OK_OPTION) {
|
||||||
panel.saveSettings();
|
this.saveSettings();
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,12 +367,12 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveSettings() {
|
public void saveSettings() {
|
||||||
|
this.store();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void store() {
|
public void store() {
|
||||||
|
panel.saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -364,17 +380,17 @@ class ProfileSettingsPanel extends IngestModuleGlobalSettingsPanel implements Op
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
int currentIndex = profileList.getSelectedIndex();
|
int currentIndex = this.profileList.getSelectedIndex();
|
||||||
profilesListModel.clear();
|
this.profilesListModel.clear();
|
||||||
IngestProfileMap profileMap = new IngestProfileMap();
|
this.profiles = new IngestProfileMap().getIngestProfileMap();
|
||||||
for (IngestProfile profile : profileMap.getIngestProfileMap().values()) {
|
for (IngestProfile profile : this.profiles.values()) {
|
||||||
profilesListModel.addElement(profile);
|
profilesListModel.addElement(profile);
|
||||||
}
|
}
|
||||||
if (currentIndex < 0 || currentIndex >= profilesListModel.getSize()) {
|
if (currentIndex < 0 || currentIndex >= profilesListModel.getSize()) {
|
||||||
currentIndex = 0;
|
currentIndex = 0;
|
||||||
}
|
}
|
||||||
refreshEditDeleteButtons();
|
refreshEditDeleteButtons();
|
||||||
profileList.setSelectedIndex(currentIndex);
|
this.profileList.setSelectedIndex(currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class ProfileListSelectionListener implements ListSelectionListener {
|
private final class ProfileListSelectionListener implements ListSelectionListener {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user