19 package org.sleuthkit.autopsy.modules.yara.rules;
21 import java.beans.PropertyChangeListener;
22 import java.beans.PropertyChangeSupport;
24 import java.nio.file.Path;
25 import java.nio.file.Paths;
26 import java.util.ArrayList;
27 import java.util.List;
28 import javax.swing.SwingUtilities;
54 changeSupport =
new PropertyChangeSupport(
this);
63 if (instance == null) {
98 if (name == null || name.isEmpty()) {
99 throw new RuleSetException(
"YARA rule set name cannot be null or empty string");
103 throw new RuleSetException(String.format(
"Yara rule set with name %s already exits.", name));
107 Path setPath = Paths.get(basePath.toString(), name);
109 setPath.toFile().mkdir();
113 SwingUtilities.invokeLater(
new Runnable() {
131 if (ruleSet == null) {
132 throw new RuleSetException(
"YARA rule set name cannot be null or empty string");
136 throw new RuleSetException(String.format(
"A YARA rule set with name %s does not exits.", ruleSet.getName()));
141 SwingUtilities.invokeLater(
new Runnable() {
155 List<RuleSet> ruleSets =
new ArrayList<>();
158 String[] ruleSetNames = basePath.toFile().list();
160 for (String setName : ruleSetNames) {
161 ruleSets.add(
new RuleSet(setName, Paths.get(basePath.toString(), setName)));
176 Path setPath = Paths.get(basePath.toString(), name);
178 return setPath.toFile().exists();
189 File baseFile = basePath.toFile();
191 if (!baseFile.exists()) {
215 File[] allContents = directoryToBeDeleted.listFiles();
216 if (allContents != null) {
217 for (File file : allContents) {
221 return directoryToBeDeleted.delete();
synchronized boolean isRuleSetExists(String name)
static synchronized RuleSetManager getInstance()
static final String RULE_SET_FOLDER
void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeSupport getChangeSupport()
static final String RULE_SET_ADDED
static void addPropertyChangeListener(PropertyChangeListener listener)
static final String RULE_SET_DELETED
synchronized List< RuleSet > getRuleSetList()
synchronized RuleSet createRuleSet(String name)
final PropertyChangeSupport changeSupport
boolean deleteDirectory(File directoryToBeDeleted)
static RuleSetManager instance
static final String BASE_FOLDER
synchronized void deleteRuleSet(RuleSet ruleSet)