19 package org.sleuthkit.autopsy.modules.yara.ui;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import javax.swing.JOptionPane;
26 import javax.swing.event.ListSelectionEvent;
27 import javax.swing.event.ListSelectionListener;
28 import org.openide.util.NbBundle.Messages;
49 ruleSetPanel.addListSelectionListener(
new ListSelectionListener() {
51 public void valueChanged(ListSelectionEvent e) {
56 ruleSetPanel.addDeleteRuleListener(
new ActionListener() {
58 public void actionPerformed(ActionEvent e) {
65 public void actionPerformed(ActionEvent e) {
79 "# {0} - rule set name",
80 "YaraRuleSetOptionPanel_RuleSet_Missing=The folder for the selected YARA rule set, {0}, no longer exists.",
81 "YaraRuleSetOptionPanel_RuleSet_Missing_title=Folder removed",
91 if(ruleSet != null && !ruleSet.
getPath().toFile().exists()) {
94 JOptionPane.showMessageDialog(
this,
95 Bundle.YaraRuleSetOptionPanel_RuleSet_Missing(ruleSet.
getName()),
96 Bundle.YaraRuleSetOptionPanel_RuleSet_Missing_title(),
97 JOptionPane.ERROR_MESSAGE);
104 "YaraRuleSetOptionPanel_new_rule_set_name_msg=Supply a new unique rule set name:",
105 "YaraRuleSetOptionPanel_new_rule_set_name_title=Rule Set Name",
106 "# {0} - rule set name",
107 "YaraRuleSetOptionPanel_badName_msg=Rule set name {0} already exists.\nRule set names must be unique.",
108 "YaraRuleSetOptionPanel_badName_title=Create Rule Set",
109 "YaraRuleSetOptionPanel_badName2_msg=Rule set is invalid.\nRule set names must be non-empty string and unique.",})
115 String value = JOptionPane.showInputDialog(
this,
116 Bundle.YaraRuleSetOptionPanel_new_rule_set_name_msg(),
117 Bundle.YaraRuleSetOptionPanel_new_rule_set_name_title());
124 if (value.isEmpty()) {
125 JOptionPane.showMessageDialog(
this,
126 Bundle.YaraRuleSetOptionPanel_badName2_msg(),
127 Bundle.YaraRuleSetOptionPanel_badName_title(),
128 JOptionPane.ERROR_MESSAGE);
135 JOptionPane.showMessageDialog(
this,
136 Bundle.YaraRuleSetOptionPanel_badName_msg(value),
137 Bundle.YaraRuleSetOptionPanel_badName_title(),
138 JOptionPane.ERROR_MESSAGE);
139 logger.log(Level.WARNING,
"Failed to create new rule set, user provided existing name.", ex);
144 "# {0} - rule set name",
145 "YaraRuleSetOptionPanel_rule_set_delete=Unable to delete the selected YARA rule set {0}.\nRule set may have already been removed."
154 if (ruleSet != null) {
158 JOptionPane.showMessageDialog(
this,
159 Bundle.YaraRuleSetOptionPanel_rule_set_delete(ruleSet.
getName()),
160 Bundle.YaraRuleSetOptionPanel_badName_title(),
161 JOptionPane.ERROR_MESSAGE);
162 logger.log(Level.WARNING, String.format(
"Failed to delete YARA rule set %s", ruleSet.
getName()), ex);
173 @SuppressWarnings(
"unchecked")
176 java.awt.GridBagConstraints gridBagConstraints;
178 javax.swing.JScrollPane scrollPane =
new javax.swing.JScrollPane();
179 javax.swing.JPanel viewportPanel =
new javax.swing.JPanel();
180 javax.swing.JSeparator separator =
new javax.swing.JSeparator();
184 setBorder(javax.swing.BorderFactory.createLineBorder(
new java.awt.Color(0, 0, 0)));
185 setLayout(
new java.awt.BorderLayout());
187 scrollPane.setBorder(null);
189 viewportPanel.setMinimumSize(
new java.awt.Dimension(1000, 127));
190 viewportPanel.setPreferredSize(
new java.awt.Dimension(1020, 400));
191 viewportPanel.setLayout(
new java.awt.GridBagLayout());
193 separator.setOrientation(javax.swing.SwingConstants.VERTICAL);
194 gridBagConstraints =
new java.awt.GridBagConstraints();
195 gridBagConstraints.gridx = 1;
196 gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
197 gridBagConstraints.weighty = 1.0;
198 viewportPanel.add(separator, gridBagConstraints);
202 gridBagConstraints =
new java.awt.GridBagConstraints();
203 gridBagConstraints.gridx = 2;
204 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
205 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
206 gridBagConstraints.weightx = 1.0;
207 gridBagConstraints.weighty = 1.0;
208 gridBagConstraints.insets =
new java.awt.Insets(10, 10, 10, 10);
211 ruleSetPanel.setMaximumSize(
new java.awt.Dimension(400, 2147483647));
212 ruleSetPanel.setMinimumSize(
new java.awt.Dimension(400, 107));
213 ruleSetPanel.setPreferredSize(
new java.awt.Dimension(400, 214));
214 gridBagConstraints =
new java.awt.GridBagConstraints();
215 gridBagConstraints.gridx = 0;
216 gridBagConstraints.gridy = 0;
217 gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
218 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
219 gridBagConstraints.weighty = 1.0;
220 gridBagConstraints.insets =
new java.awt.Insets(10, 10, 10, 10);
223 scrollPane.setViewportView(viewportPanel);
225 add(scrollPane, java.awt.BorderLayout.CENTER);
static synchronized RuleSetManager getInstance()
org.sleuthkit.autopsy.modules.yara.ui.RuleSetPanel ruleSetPanel
void handleDeleteRuleSet()
void handleSelectionChange()
static final Logger logger
static final long serialVersionUID
synchronized List< RuleSet > getRuleSetList()
synchronized RuleSet createRuleSet(String name)
org.sleuthkit.autopsy.modules.yara.ui.RuleSetDetailsPanel ruleSetDetailsPanel
synchronized void deleteRuleSet(RuleSet ruleSet)