filter -> condition

This commit is contained in:
Oliver Spohngellert 2016-02-18 17:23:58 -05:00
parent a15750199b
commit 730ee53fc7
7 changed files with 292 additions and 285 deletions

View File

@ -21,7 +21,7 @@ FilesSetRulePanel.nameRegexCheckbox.text=Regex
FilesSetRulePanel.ruleNameTextField.text=
FilesSetRulePanel.nameTextField.text=
FilesSetRulePanel.ruleNameLabel.text=Rule Name:
FilesSetRulePanel.messages.emptyNameFilter=You must specify a name pattern for this rule.
FilesSetRulePanel.messages.emptyNameCondition=You must specify a name pattern for this rule.
FilesSetRulePanel.messages.invalidNameRegex=The name regular expression is not valid:\n\n{0}
FilesSetRulePanel.messages.invalidCharInName=The name cannot contain \\, /, :, *, ?, \", <, or > unless it is a regular expression.
FilesSetRulePanel.messages.invalidCharInPath=The path cannot contain \\, :, *, ?, \", <, or > unless it is a regular expression.
@ -42,7 +42,6 @@ InterestingItemDefsPanel.jLabel6.text=Set Details
InterestingItemDefsPanel.jLabel8.text=File Size:
InterestingItemDefsPanel.jLabel7.text=MIME Type:
InterestingItemDefsPanel.jTextArea1.text=This module allows you to find files that match specified criteria. Each set has a list of rules, which will match on file name and parent path patterns.
InterestingItemDefsPanel.rulePathFilterRegexCheckBox.text=Regex
InterestingItemDefsPanel.jLabel4.text=Path Pattern:
InterestingItemDefsPanel.jLabel1.text=Rule Details
InterestingItemDefsPanel.dirsRadioButton.text=Directories
@ -54,7 +53,6 @@ InterestingItemDefsPanel.bothRadioButton.text=Files and Directories
InterestingItemDefsPanel.setsListLabel.text=Rule Sets
InterestingItemDefsPanel.fileNameRegexCheckbox.text=Regex
InterestingItemDefsPanel.ignoreKnownFilesCheckbox.text=Ignore Known Files
InterestingItemDefsPanel.rulePathFilterTextField.text=
InterestingItemDefsPanel.fileNameRadioButton.text=File Name
InterestingItemDefsPanel.jLabel5.text=Description:
InterestingItemDefsPanel.fileNameTextField.text=
@ -65,3 +63,5 @@ InterestingItemDefsPanel.rulesListLabel.text=Rules:
InterestingItemDefsPanel.editRuleButton.text=Edit Rule
InterestingItemDefsPanel.filesRadioButton.text=Files
InterestingItemDefsPanel.newRuleButton.text=New Rule
InterestingItemDefsPanel.rulePathConditionTextField.text=
InterestingItemDefsPanel.rulePathConditionRegexCheckBox.text=Regex

View File

@ -35,8 +35,6 @@ InterestingItemDefsPanel.doFileSetsDialog.duplicateRuleSet.text=\u540d\u524d\u30
FilesSetRulePanel.jLabel5.text=\u898b\u3064\u3051\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u60c5\u5831\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002
InterestingItemDefsPanel.jTextArea1.text=\u6307\u5b9a\u3055\u308c\u305f\u6761\u4ef6\u3068\u4e00\u81f4\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u691c\u7d22\u3059\u308b\u306e\u304c\u53ef\u80fd\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u3002\u5404\u30bb\u30c3\u30c8\u306b\u306f\u30d5\u30a1\u30a4\u30eb\u540d\u304a\u3088\u3073\u30da\u30a2\u30ec\u30f3\u30c8\u30d1\u30b9\u30d1\u30bf\u30fc\u30f3\u3092\u3082\u3068\u306b\u4e00\u81f4\u3059\u308b\u3001\u30eb\u30fc\u30eb\u30ea\u30b9\u30c8\u304c\u3042\u308a\u307e\u3059\u3002
InterestingItemDefsPanel.rulePathFilterRegexCheckBox.text=\u6b63\u898f\u8868\u73fe
InterestingItemDefsPanel.jLabel4.text=\u30d1\u30b9\u30d1\u30bf\u30fc\u30f3\uff1a
InterestingItemDefsPanel.jLabel1.text=\u30eb\u30fc\u30eb\u8a73\u7d30
@ -78,3 +76,4 @@ InterestingItemDefsPanel.filesRadioButton.text=\u30d5\u30a1\u30a4\u30eb
InterestingItemDefsPanel.newRuleButton.text=\u65b0\u898f\u30eb\u30fc\u30eb
InterestingItemDefsPanel.jLabel6.text=\u30bb\u30c3\u30c8\u8a73\u7d30
InterestingItemDefsPanel.rulePathConditionRegexCheckBox.text=\u6b63\u898f\u8868\u73fe

View File

@ -18,6 +18,7 @@
*/
package org.sleuthkit.autopsy.modules.interestingitems;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -35,8 +36,9 @@ import org.sleuthkit.datamodel.TskData;
* Interesting files set definition objects are immutable, so they may be safely
* published to multiple threads.
*/
final class FilesSet {
final class FilesSet implements Serializable {
private static final long serialVersionUID = 1L;
private final String name;
private final String description;
private final boolean ignoreKnownFiles;
@ -135,33 +137,34 @@ final class FilesSet {
* A set membership rule for an interesting files set. The immutability of a
* rule object allows it to be safely published to multiple threads.
*/
static class Rule {
static class Rule implements Serializable {
private static final long serialVersionUID = 1L;
private final String uuid;
private final String ruleName;
private final FileNameFilter fileNameFilter;
private final MetaTypeCondition metaTypeFilter;
private final ParentPathFilter pathFilter;
private final MimeTypeCondition mimeTypeFilter;
private final FileSizeCondition fileSizeFilter;
private final List<FileAttributeCondition> filters = new ArrayList<>();
private final FileNameCondition fileNameCondition;
private final MetaTypeCondition metaTypeCondition;
private final ParentPathCondition pathCondition;
private final MimeTypeCondition mimeTypeCondition;
private final FileSizeCondition fileSizeCondition;
private final List<FileAttributeCondition> conditions = new ArrayList<>();
/**
* Construct an interesting files set membership rule.
*
* @param ruleName The name of the rule.
* @param fileNameFilter A file name filter.
* @param metaTypeFilter A file meta-type filter.
* @param pathFilter A file path filter, may be null.
* @param fileNameCondition A file name condition.
* @param metaTypeCondition A file meta-type condition.
* @param pathCondition A file path condition, may be null.
*/
Rule(String ruleName, FileNameFilter fileNameFilter, MetaTypeCondition metaTypeFilter, ParentPathFilter pathFilter, MimeTypeCondition mimeTypeFilter, FileSizeCondition fileSizeFilter) {
Rule(String ruleName, FileNameCondition fileNameCondition, MetaTypeCondition metaTypeCondition, ParentPathCondition pathCondition, MimeTypeCondition mimeTypeCondition, FileSizeCondition fileSizeCondition) {
// since ruleName is optional, ruleUUID can be used to uniquely identify a rule.
this.uuid = UUID.randomUUID().toString();
if (metaTypeFilter == null) {
throw new IllegalArgumentException("Interesting files set rule meta-type filter cannot be null");
if (metaTypeCondition == null) {
throw new IllegalArgumentException("Interesting files set rule meta-type condition cannot be null");
}
if (ruleName == null && fileNameFilter == null && mimeTypeFilter == null) {
throw new IllegalArgumentException("Must have at least one filter on rule.");
if (ruleName == null && fileNameCondition == null && mimeTypeCondition == null) {
throw new IllegalArgumentException("Must have at least one condition on rule.");
}
this.ruleName = ruleName;
@ -170,28 +173,28 @@ final class FilesSet {
* The rules are evaluated in the order added. MetaType check is
* fastest, so do it first
*/
this.metaTypeFilter = metaTypeFilter;
if (this.metaTypeFilter != null) {
this.filters.add(this.metaTypeFilter);
this.metaTypeCondition = metaTypeCondition;
if (this.metaTypeCondition != null) {
this.conditions.add(this.metaTypeCondition);
}
this.fileNameFilter = fileNameFilter;
if (this.fileNameFilter != null) {
this.filters.add(fileNameFilter);
this.fileNameCondition = fileNameCondition;
if (this.fileNameCondition != null) {
this.conditions.add(fileNameCondition);
}
this.mimeTypeFilter = mimeTypeFilter;
if (this.mimeTypeFilter != null) {
this.filters.add(mimeTypeFilter);
this.mimeTypeCondition = mimeTypeCondition;
if (this.mimeTypeCondition != null) {
this.conditions.add(mimeTypeCondition);
}
this.pathFilter = pathFilter;
if (this.pathFilter != null) {
this.filters.add(this.pathFilter);
this.pathCondition = pathCondition;
if (this.pathCondition != null) {
this.conditions.add(this.pathCondition);
}
this.fileSizeFilter = fileSizeFilter;
if (this.fileSizeFilter != null) {
this.filters.add(this.fileSizeFilter);
this.fileSizeCondition = fileSizeCondition;
if (this.fileSizeCondition != null) {
this.conditions.add(this.fileSizeCondition);
}
}
@ -205,30 +208,30 @@ final class FilesSet {
}
/**
* Get the file name filter for the rule.
* Get the file name condition for the rule.
*
* @return A file name filter.
* @return A file name condition.
*/
FileNameFilter getFileNameFilter() {
return this.fileNameFilter;
FileNameCondition getFileNameCondition() {
return this.fileNameCondition;
}
/**
* Get the meta-type filter for the rule.
* Get the meta-type condition for the rule.
*
* @return A meta-type filter.
* @return A meta-type condition.
*/
MetaTypeCondition getMetaTypeFilter() {
return this.metaTypeFilter;
MetaTypeCondition getMetaTypeCondition() {
return this.metaTypeCondition;
}
/**
* Get the path filter for the rule.
* Get the path condition for the rule.
*
* @return A path filter, may be null.
* @return A path condition, may be null.
*/
ParentPathFilter getPathFilter() {
return this.pathFilter;
ParentPathCondition getPathCondition() {
return this.pathCondition;
}
/**
@ -239,8 +242,8 @@ final class FilesSet {
* @return True if the rule is satisfied, false otherwise.
*/
boolean isSatisfied(AbstractFile file) {
for (FileAttributeCondition filter : filters) {
if (!filter.passes(file)) {
for (FileAttributeCondition condition : conditions) {
if (!condition.passes(file)) {
return false;
}
}
@ -254,7 +257,7 @@ final class FilesSet {
public String toString() {
// This override is designed to provide a display name for use with
// javax.swing.DefaultListModel<E>.
return this.ruleName + " (" + fileNameFilter.getTextToMatch() + ")";
return this.ruleName + " (" + fileNameCondition.getTextToMatch() + ")";
}
/**
@ -265,20 +268,21 @@ final class FilesSet {
}
/**
* @return the mimeTypeFilter
* @return the mimeTypeCondition
*/
public MimeTypeCondition getMimeTypeFilter() {
return mimeTypeFilter;
public MimeTypeCondition getMimeTypeCondition() {
return mimeTypeCondition;
}
/**
* An interface for the file attribute filters of which interesting
* An interface for the file attribute conditions of which interesting
* files set membership rules are composed.
*/
static interface FileAttributeCondition {
static interface FileAttributeCondition extends Serializable {
/**
* Tests whether or not a file satisfies the conditions of a filter.
* Tests whether or not a file satisfies the conditions of a
* condition.
*
* @param file The file to test.
*
@ -288,16 +292,17 @@ final class FilesSet {
}
/**
* A class for filtering files based upon their MIME types.
* A class for checking files based upon their MIME types.
*/
static final class MimeTypeCondition implements FileAttributeCondition {
private static final long serialVersionUID = 1L;
private String mimeType;
/**
* Constructs a MimeTypeFilter
* Constructs a MimeTypeCondition
*
* @param mimeType The mime type to filter for
* @param mimeType The mime type to condition for
*/
MimeTypeCondition(String mimeType) {
this.mimeType = mimeType;
@ -312,7 +317,7 @@ final class FilesSet {
}
/**
* Gets the mime type that is being filtered
* Gets the mime type that is being checked
*
* @return the mime type
*/
@ -324,6 +329,8 @@ final class FilesSet {
static final class FileSizeCondition implements FileAttributeCondition {
private static final long serialVersionUID = 1L;
static enum COMPARATOR {
LESS_THAN,
@ -331,24 +338,19 @@ final class FilesSet {
EQUAL,
GREATER_THAN,
GREATER_THAN_EQUAL;
public static COMPARATOR fromSymbol(String symbol) {
if (symbol.equals("<=") || symbol.equals("")) {
return LESS_THAN_EQUAL;
}
else if (symbol.equals("<")) {
} else if (symbol.equals("<")) {
return LESS_THAN;
}
else if (symbol.equals("==") || symbol.equals("=")) {
} else if (symbol.equals("==") || symbol.equals("=")) {
return EQUAL;
}
else if (symbol.equals(">")) {
} else if (symbol.equals(">")) {
return GREATER_THAN;
}
else if (symbol.equals(">=") || symbol.equals("")) {
} else if (symbol.equals(">=") || symbol.equals("")) {
return GREATER_THAN_EQUAL;
}
else {
} else {
throw new IllegalArgumentException("Invalid symbol");
}
}
@ -369,21 +371,17 @@ final class FilesSet {
public long getSize() {
return this.size;
}
public static SIZE_UNIT fromName(String name) {
if (name.equals("Bytes")) {
return BYTE;
}
else if (name.equals("Kilobytes")) {
} else if (name.equals("Kilobytes")) {
return KILOBYTE;
}
else if (name.equals("Megabytes")) {
} else if (name.equals("Megabytes")) {
return MEGABYTE;
}
else if (name.equals("Gigabytes")) {
} else if (name.equals("Gigabytes")) {
return GIGABYTE;
}
else {
} else {
throw new IllegalArgumentException("Invalid symbol");
}
}
@ -401,18 +399,18 @@ final class FilesSet {
@Override
public boolean passes(AbstractFile file) {
long fileSize = file.getSize();
long filterSize = this.unit.getSize() * this.sizeValue;
long conditionSize = this.unit.getSize() * this.sizeValue;
switch (this.comparator) {
case GREATER_THAN:
return fileSize > filterSize;
return fileSize > conditionSize;
case GREATER_THAN_EQUAL:
return fileSize >= filterSize;
return fileSize >= conditionSize;
case LESS_THAN_EQUAL:
return fileSize <= filterSize;
return fileSize <= conditionSize;
case LESS_THAN:
return fileSize < filterSize;
return fileSize < conditionSize;
default:
return fileSize == filterSize;
return fileSize == conditionSize;
}
}
@ -420,12 +418,14 @@ final class FilesSet {
}
/**
* A file meta-type filter for an interesting files set membership rule.
* The immutability of a meta-type filter object allows it to be safely
* published to multiple threads.
* A file meta-type condition for an interesting files set membership
* rule. The immutability of a meta-type condition object allows it to
* be safely published to multiple threads.
*/
static final class MetaTypeCondition implements FileAttributeCondition {
private static final long serialVersionUID = 1L;
enum Type {
FILES,
@ -436,7 +436,7 @@ final class FilesSet {
private final Type type;
/**
* Construct a meta-type filter.
* Construct a meta-type condition.
*
* @param metaType The meta-type to match, must.
*/
@ -461,7 +461,7 @@ final class FilesSet {
}
/**
* Gets the meta-type the filter matches.
* Gets the meta-type the condition matches.
*
* @return A member of the MetaTypeCondition.Type enumeration.
*/
@ -471,20 +471,20 @@ final class FilesSet {
}
/**
* An interface for file attribute filters that do textual matching.
* An interface for file attribute conditions that do textual matching.
*/
static interface TextFilter extends FileAttributeCondition {
static interface TextCondition extends FileAttributeCondition {
/**
* Gets the text the filter matches.
* Gets the text the condition matches.
*
* @return The text.
*/
String getTextToMatch();
/**
* Queries whether or not the text the filter matches is a regular
* expression.
* Queries whether or not the text the condition matches is a
* regular expression.
*
* @return True if the text to be matched is a regular expression,
* false otherwise.
@ -492,7 +492,7 @@ final class FilesSet {
boolean isRegex();
/**
* Determines whether a string of text matches the filter.
* Determines whether a string of text matches the condition.
*
* @param textToMatch The text string.
*
@ -503,19 +503,20 @@ final class FilesSet {
}
/**
* An abstract base class for file attribute filters that do textual
* An abstract base class for file attribute conditions that do textual
* matching.
*/
private static abstract class AbstractTextFilter implements TextFilter {
private static abstract class AbstractTextCondition implements TextCondition {
private static final long serialVersionUID = 1L;
private final TextMatcher textMatcher;
/**
* Construct a case-insensitive text filter.
* Construct a case-insensitive text condition.
*
* @param text The text to be matched.
*/
AbstractTextFilter(String text, Boolean partialMatch) {
AbstractTextCondition(String text, Boolean partialMatch) {
if (partialMatch) {
this.textMatcher = new FilesSet.Rule.CaseInsensitivePartialStringComparisionMatcher(text);
} else {
@ -524,16 +525,16 @@ final class FilesSet {
}
/**
* Construct a regular expression text filter.
* Construct a regular expression text condition.
*
* @param regex The regular expression to be matched.
*/
AbstractTextFilter(Pattern regex) {
AbstractTextCondition(Pattern regex) {
this.textMatcher = new FilesSet.Rule.RegexMatcher(regex);
}
/**
* Get the text the filter matches.
* Get the text the condition matches.
*
* @return The text.
*/
@ -543,8 +544,8 @@ final class FilesSet {
}
/**
* Queries whether or not the text the filter matches is a regular
* expression.
* Queries whether or not the text the condition matches is a
* regular expression.
*
* @return True if the text to be matched is a regular expression,
* false otherwise.
@ -555,7 +556,7 @@ final class FilesSet {
}
/**
* Determines whether a string of text matches the filter.
* Determines whether a string of text matches the condition.
*
* @param textToMatch The text string.
*
@ -575,27 +576,29 @@ final class FilesSet {
}
/**
* A file path filter for an interesting files set membership rule. The
* immutability of a path filter object allows it to be safely published
* to multiple threads.
* A file path condition for an interesting files set membership rule.
* The immutability of a path condition object allows it to be safely
* published to multiple threads.
*/
static final class ParentPathFilter extends AbstractTextFilter {
static final class ParentPathCondition extends AbstractTextCondition {
private static final long serialVersionUID = 1L;
/**
* Construct a case-insensitive file path filter.
* Construct a case-insensitive file path condition.
*
* @param path The path to be matched.
*/
ParentPathFilter(String path) {
ParentPathCondition(String path) {
super(path, true);
}
/**
* Construct a file path regular expression filter.
* Construct a file path regular expression condition.
*
* @param path The path regular expression to be matched.
*/
ParentPathFilter(Pattern path) {
ParentPathCondition(Pattern path) {
super(path);
}
@ -610,34 +613,37 @@ final class FilesSet {
}
/**
* A "tagging" interface to group name and extension filters separately
* from path filters for type safety when constructing rules.
* A "tagging" interface to group name and extension conditions
* separately from path conditions for type safety when constructing
* rules.
*/
static interface FileNameFilter extends TextFilter {
static interface FileNameCondition extends TextCondition {
}
/**
* A file name filter for an interesting files set membership rule. The
* immutability of a file name filter object allows it to be safely
* published to multiple threads.
* A file name condition for an interesting files set membership rule.
* The immutability of a file name condition object allows it to be
* safely published to multiple threads.
*/
static final class FullNameFilter extends AbstractTextFilter implements FileNameFilter {
static final class FullNameCondition extends AbstractTextCondition implements FileNameCondition {
private static final long serialVersionUID = 1L;
/**
* Construct a case-insensitive full file name filter.
* Construct a case-insensitive full file name condition.
*
* @param name The file name to be matched.
*/
FullNameFilter(String name) {
FullNameCondition(String name) {
super(name, false);
}
/**
* Construct a full file name regular expression filter.
* Construct a full file name regular expression condition.
*
* @param name The file name regular expression to be matched.
*/
FullNameFilter(Pattern name) {
FullNameCondition(Pattern name) {
super(name);
}
@ -652,18 +658,20 @@ final class FilesSet {
}
/**
* A file name extension filter for an interesting files set membership
* rule. The immutability of a file name extension filter object allows
* it to be safely published to multiple threads.
* A file name extension condition for an interesting files set
* membership rule. The immutability of a file name extension condition
* object allows it to be safely published to multiple threads.
*/
static final class ExtensionFilter extends AbstractTextFilter implements FileNameFilter {
static final class ExtensionCondition extends AbstractTextCondition implements FileNameCondition {
private static final long serialVersionUID = 1L;
/**
* Construct a case-insensitive file name extension filter.
* Construct a case-insensitive file name extension condition.
*
* @param extension The file name extension to be matched.
*/
ExtensionFilter(String extension) {
ExtensionCondition(String extension) {
// If there is a leading ".", strip it since
// AbstractFile.getFileNameExtension() returns just the
// extension chars and not the dot.
@ -671,12 +679,12 @@ final class FilesSet {
}
/**
* Construct a file name extension regular expression filter.
* Construct a file name extension regular expression condition.
*
* @param extension The file name extension regular expression to be
* matched.
*/
ExtensionFilter(Pattern extension) {
ExtensionCondition(Pattern extension) {
super(extension.pattern(), false);
}
@ -692,7 +700,7 @@ final class FilesSet {
/**
* An interface for objects that do textual matches, used to compose a
* text filter.
* text condition.
*/
private static interface TextMatcher {

View File

@ -71,9 +71,9 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
FilesSetRulePanel(FilesSet.Rule rule) {
initComponents();
populateRuleNameComponent(rule);
populateTypeFilterComponents(rule);
populateNameFilterComponents(rule);
populatePathFilterComponents(rule);
populateTypeConditionComponents(rule);
populateNameConditionComponents(rule);
populatePathConditionComponents(rule);
customInit();
}
@ -131,9 +131,9 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
*
* @param rule The files set rule to be edited.
*/
private void populateTypeFilterComponents(FilesSet.Rule rule) {
FilesSet.Rule.MetaTypeCondition typeFilter = rule.getMetaTypeFilter();
switch (typeFilter.getMetaType()) {
private void populateTypeConditionComponents(FilesSet.Rule rule) {
FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
switch (typeCondition.getMetaType()) {
case FILES:
this.filesRadioButton.setSelected(true);
break;
@ -151,11 +151,11 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
*
* @param rule The files set rule to be edited.
*/
private void populateNameFilterComponents(FilesSet.Rule rule) {
FilesSet.Rule.FileNameFilter nameFilter = rule.getFileNameFilter();
this.nameTextField.setText(nameFilter.getTextToMatch());
this.nameRegexCheckbox.setSelected(nameFilter.isRegex());
if (nameFilter instanceof FilesSet.Rule.FullNameFilter) {
private void populateNameConditionComponents(FilesSet.Rule rule) {
FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
this.nameTextField.setText(nameCondition.getTextToMatch());
this.nameRegexCheckbox.setSelected(nameCondition.isRegex());
if (nameCondition instanceof FilesSet.Rule.FullNameCondition) {
this.fullNameRadioButton.setSelected(true);
} else {
this.extensionRadioButton.setSelected(true);
@ -168,11 +168,11 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
*
* @param rule The files set rule to be edited.
*/
private void populatePathFilterComponents(FilesSet.Rule rule) {
FilesSet.Rule.ParentPathFilter pathFilter = rule.getPathFilter();
if (pathFilter != null) {
this.pathTextField.setText(pathFilter.getTextToMatch());
this.pathRegexCheckBox.setSelected(pathFilter.isRegex());
private void populatePathConditionComponents(FilesSet.Rule rule) {
FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
if (pathCondition != null) {
this.pathTextField.setText(pathCondition.getTextToMatch());
this.pathRegexCheckBox.setSelected(pathCondition.isRegex());
}
}
@ -188,7 +188,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
// The rule must have name condition text.
if (this.nameTextField.getText().isEmpty()) {
NotifyDescriptor notifyDesc = new NotifyDescriptor.Message(
NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.emptyNameFilter"),
NbBundle.getMessage(FilesSetPanel.class, "FilesSetRulePanel.messages.emptyNameCondition"),
NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(notifyDesc);
return false;
@ -260,35 +260,35 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
*
* @throws IllegalStateException if the specified name condition is not valid.
*/
FilesSet.Rule.FileNameFilter getFileNameFilter() throws IllegalStateException {
FilesSet.Rule.FileNameFilter filter = null;
FilesSet.Rule.FileNameCondition getFileNameCondition() throws IllegalStateException {
FilesSet.Rule.FileNameCondition condition = null;
if (!this.nameTextField.getText().isEmpty()) {
if (this.nameRegexCheckbox.isSelected()) {
try {
Pattern pattern = Pattern.compile(this.nameTextField.getText());
if (this.fullNameRadioButton.isSelected()) {
filter = new FilesSet.Rule.FullNameFilter(pattern);
condition = new FilesSet.Rule.FullNameCondition(pattern);
} else {
filter = new FilesSet.Rule.ExtensionFilter(pattern);
condition = new FilesSet.Rule.ExtensionCondition(pattern);
}
} catch (PatternSyntaxException ex) {
logger.log(Level.SEVERE, "Attempt to get regex name filter that does not compile", ex); // NON-NLS
throw new IllegalStateException("The files set rule panel name filter is not in a valid state"); // NON-NLS
logger.log(Level.SEVERE, "Attempt to get regex name condition that does not compile", ex); // NON-NLS
throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
}
} else {
if (FilesSetRulePanel.containsOnlyLegalChars(this.nameTextField.getText(), FilesSetRulePanel.ILLEGAL_FILE_NAME_CHARS)) {
if (this.fullNameRadioButton.isSelected()) {
filter = new FilesSet.Rule.FullNameFilter(this.nameTextField.getText());
condition = new FilesSet.Rule.FullNameCondition(this.nameTextField.getText());
} else {
filter = new FilesSet.Rule.ExtensionFilter(this.nameTextField.getText());
condition = new FilesSet.Rule.ExtensionCondition(this.nameTextField.getText());
}
} else {
logger.log(Level.SEVERE, "Attempt to get name filter with illegal chars"); // NON-NLS
throw new IllegalStateException("The files set rule panel name filter is not in a valid state"); // NON-NLS
logger.log(Level.SEVERE, "Attempt to get name condition with illegal chars"); // NON-NLS
throw new IllegalStateException("The files set rule panel name condition is not in a valid state"); // NON-NLS
}
}
}
return filter;
return condition;
}
/**
@ -329,7 +329,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
*
* @return A type condition.
*/
FilesSet.Rule.MetaTypeCondition getMetaTypeFilter() {
FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
if (this.filesRadioButton.isSelected()) {
return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
} else if (this.dirsRadioButton.isSelected()) {
@ -347,15 +347,15 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
*
* @throws IllegalStateException if the specified path condition is not valid.
*/
FilesSet.Rule.ParentPathFilter getPathFilter() throws IllegalStateException {
FilesSet.Rule.ParentPathFilter filter = null;
FilesSet.Rule.ParentPathCondition getPathCondition() throws IllegalStateException {
FilesSet.Rule.ParentPathCondition condition = null;
if (!this.pathTextField.getText().isEmpty()) {
if (this.pathRegexCheckBox.isSelected()) {
try {
filter = new FilesSet.Rule.ParentPathFilter(Pattern.compile(this.pathTextField.getText()));
condition = new FilesSet.Rule.ParentPathCondition(Pattern.compile(this.pathTextField.getText()));
} catch (PatternSyntaxException ex) {
logger.log(Level.SEVERE, "Attempt to get malformed path filter", ex); // NON-NLS
throw new IllegalStateException("The files set rule panel path filter is not in a valid state"); // NON-NLS
logger.log(Level.SEVERE, "Attempt to get malformed path condition", ex); // NON-NLS
throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
}
} else {
String path = this.pathTextField.getText();
@ -368,14 +368,14 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
if (!path.endsWith(FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR)) {
path += FilesSetRulePanel.SLEUTHKIT_PATH_SEPARATOR;
}
filter = new FilesSet.Rule.ParentPathFilter(path);
condition = new FilesSet.Rule.ParentPathCondition(path);
} else {
logger.log(Level.SEVERE, "Attempt to get path filter with illegal chars"); // NON-NLS
throw new IllegalStateException("The files set rule panel path filter is not in a valid state"); // NON-NLS
logger.log(Level.SEVERE, "Attempt to get path condition with illegal chars"); // NON-NLS
throw new IllegalStateException("The files set rule panel path condition is not in a valid state"); // NON-NLS
}
}
}
return filter;
return condition;
}
/**

View File

@ -140,11 +140,11 @@ final class InterestingItemDefsManager extends Observable {
// to allow Autopsy to use TSK Framework interesting files set
// definitions.
// 2. The TSK Framework has an interesting files module that supports
// simple globbing with "*" characters. Name rules and path filters with
// simple globbing with "*" characters. Name rules and path conditions with
// "*" characters will be converted to regexes to allow Autopsy to use
// TSK Framework interesting files set definitions.
// 3. Type filters are required by Autopsy, but not by TSK Frmaework.
// Missing type filters will defualt to "files" filters.
// 3. Type conditions are required by Autopsy, but not by TSK Frmaework.
// Missing type conditions will defualt to "files" conditions.
private static final String REGEX_ATTR = "regex"; //NON-NLS
private static final String PATH_REGEX_ATTR = "pathRegex"; //NON-NLS
private static final String TYPE_FILTER_VALUE_FILES_AND_DIRS = "files_and_dirs"; //NON-NLS
@ -288,16 +288,16 @@ final class InterestingItemDefsManager extends Observable {
private static FilesSet.Rule readFileNameRule(Element elem) {
String ruleName = FilesSetXML.readRuleName(elem);
// The content of the rule tag is a file name filter. It may be a
// The content of the rule tag is a file name condition. It may be a
// regex, or it may be from a TSK Framework rule definition with a
// "*" globbing char, or it may be simple text.
String content = elem.getTextContent();
FilesSet.Rule.FullNameFilter nameFilter;
FilesSet.Rule.FullNameCondition namecondition;
String regex = elem.getAttribute(FilesSetXML.REGEX_ATTR);
if ((!regex.isEmpty() && regex.equalsIgnoreCase("true")) || content.contains("*")) { // NON-NLS
Pattern pattern = compileRegex(content);
if (pattern != null) {
nameFilter = new FilesSet.Rule.FullNameFilter(pattern);
namecondition = new FilesSet.Rule.FullNameCondition(pattern);
} else {
logger.log(Level.SEVERE, "Error compiling " + FilesSetXML.NAME_RULE_TAG + " regex, ignoring malformed '{0}' rule definition", ruleName); // NON-NLS
return null;
@ -309,29 +309,29 @@ final class InterestingItemDefsManager extends Observable {
return null;
}
}
nameFilter = new FilesSet.Rule.FullNameFilter(content);
namecondition = new FilesSet.Rule.FullNameCondition(content);
}
// Read in the type filter.
FilesSet.Rule.MetaTypeCondition metaTypeFilter = FilesSetXML.readMetaTypeFilter(elem);
if (metaTypeFilter == null) {
// Read in the type condition.
FilesSet.Rule.MetaTypeCondition metaTypecondition = FilesSetXML.readMetaTypecondition(elem);
if (metaTypecondition == null) {
// Malformed attribute.
return null;
}
// Read in the optional path filter. Null is o.k., but if the attribute
// Read in the optional path condition. Null is o.k., but if the attribute
// is there, be sure it is not malformed.
FilesSet.Rule.ParentPathFilter pathFilter = null;
FilesSet.Rule.ParentPathCondition pathcondition = null;
if (!elem.getAttribute(FilesSetXML.PATH_FILTER_ATTR).isEmpty()
|| !elem.getAttribute(FilesSetXML.PATH_REGEX_ATTR).isEmpty()) {
pathFilter = FilesSetXML.readPathFilter(elem);
if (pathFilter == null) {
pathcondition = FilesSetXML.readPathcondition(elem);
if (pathcondition == null) {
// Malformed attribute.
return null;
}
}
return new FilesSet.Rule(ruleName, nameFilter, metaTypeFilter, pathFilter, null, null);
return new FilesSet.Rule(ruleName, namecondition, metaTypecondition, pathcondition, null, null);
}
/**
@ -346,16 +346,16 @@ final class InterestingItemDefsManager extends Observable {
private static FilesSet.Rule readFileExtensionRule(Element elem) {
String ruleName = FilesSetXML.readRuleName(elem);
// The content of the rule tag is a file name extension filter. It may
// The content of the rule tag is a file name extension condition. It may
// be a regex, or it may be from a TSK Framework rule definition
// with a "*" globbing char.
String content = elem.getTextContent();
FilesSet.Rule.ExtensionFilter extFilter;
FilesSet.Rule.ExtensionCondition extcondition;
String regex = elem.getAttribute(FilesSetXML.REGEX_ATTR);
if ((!regex.isEmpty() && regex.equalsIgnoreCase("true")) || content.contains("*")) { // NON-NLS
Pattern pattern = compileRegex(content);
if (pattern != null) {
extFilter = new FilesSet.Rule.ExtensionFilter(pattern);
extcondition = new FilesSet.Rule.ExtensionCondition(pattern);
} else {
logger.log(Level.SEVERE, "Error compiling " + FilesSetXML.EXTENSION_RULE_TAG + " regex, ignoring malformed {0} rule definition", ruleName); // NON-NLS
return null;
@ -367,35 +367,35 @@ final class InterestingItemDefsManager extends Observable {
return null;
}
}
extFilter = new FilesSet.Rule.ExtensionFilter(content);
extcondition = new FilesSet.Rule.ExtensionCondition(content);
}
// The rule must have a meta-type filter, unless a TSK Framework
// The rule must have a meta-type condition, unless a TSK Framework
// definitions file is being read.
FilesSet.Rule.MetaTypeCondition metaTypeFilter = null;
FilesSet.Rule.MetaTypeCondition metaTypecondition = null;
if (!elem.getAttribute(FilesSetXML.TYPE_FILTER_ATTR).isEmpty()) {
metaTypeFilter = FilesSetXML.readMetaTypeFilter(elem);
if (metaTypeFilter == null) {
metaTypecondition = FilesSetXML.readMetaTypecondition(elem);
if (metaTypecondition == null) {
// Malformed attribute.
return null;
}
} else {
metaTypeFilter = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
metaTypecondition = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
}
// The rule may have a path filter. Null is o.k., but if the attribute
// The rule may have a path condition. Null is o.k., but if the attribute
// is there, it must not be malformed.
FilesSet.Rule.ParentPathFilter pathFilter = null;
FilesSet.Rule.ParentPathCondition pathcondition = null;
if (!elem.getAttribute(FilesSetXML.PATH_FILTER_ATTR).isEmpty()
|| !elem.getAttribute(FilesSetXML.PATH_REGEX_ATTR).isEmpty()) {
pathFilter = FilesSetXML.readPathFilter(elem);
if (pathFilter == null) {
pathcondition = FilesSetXML.readPathcondition(elem);
if (pathcondition == null) {
// Malformed attribute.
return null;
}
}
return new FilesSet.Rule(ruleName, extFilter, metaTypeFilter, pathFilter, null, null);
return new FilesSet.Rule(ruleName, extcondition, metaTypecondition, pathcondition, null, null);
}
/**
@ -428,62 +428,62 @@ final class InterestingItemDefsManager extends Observable {
}
/**
* Construct a meta-type filter for an interesting files set membership
* Construct a meta-type condition for an interesting files set membership
* rule from data in an XML element.
*
* @param ruleElement The XML element.
*
* @return The meta-type filter, or null if there is an error (logged).
* @return The meta-type condition, or null if there is an error (logged).
*/
private static FilesSet.Rule.MetaTypeCondition readMetaTypeFilter(Element ruleElement) {
FilesSet.Rule.MetaTypeCondition filter = null;
String filterAttribute = ruleElement.getAttribute(FilesSetXML.TYPE_FILTER_ATTR);
if (!filterAttribute.isEmpty()) {
switch (filterAttribute) {
private static FilesSet.Rule.MetaTypeCondition readMetaTypecondition(Element ruleElement) {
FilesSet.Rule.MetaTypeCondition condition = null;
String conditionAttribute = ruleElement.getAttribute(FilesSetXML.TYPE_FILTER_ATTR);
if (!conditionAttribute.isEmpty()) {
switch (conditionAttribute) {
case FilesSetXML.TYPE_FILTER_VALUE_FILES:
filter = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
condition = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
break;
case FilesSetXML.TYPE_FILTER_VALUE_DIRS:
filter = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
condition = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
break;
case FilesSetXML.TYPE_FILTER_VALUE_FILES_AND_DIRS:
filter = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES);
condition = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES);
break;
default:
logger.log(Level.SEVERE, "Found {0} " + FilesSetXML.TYPE_FILTER_ATTR + " attribute with unrecognized value ''{0}'', ignoring malformed rule definition", filterAttribute); // NON-NLS
logger.log(Level.SEVERE, "Found {0} " + FilesSetXML.TYPE_FILTER_ATTR + " attribute with unrecognized value ''{0}'', ignoring malformed rule definition", conditionAttribute); // NON-NLS
break;
}
} else {
// Accept TSK Framework interesting files set definitions,
// default to files.
filter = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
condition = new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
}
return filter;
return condition;
}
/**
* Construct a path filter for an interesting files set membership rule
* Construct a path condition for an interesting files set membership rule
* from data in an XML element.
*
* @param ruleElement The XML element.
*
* @return The path filter, or null if there is an error (logged).
* @return The path condition, or null if there is an error (logged).
*/
private static FilesSet.Rule.ParentPathFilter readPathFilter(Element ruleElement) {
FilesSet.Rule.ParentPathFilter filter = null;
private static FilesSet.Rule.ParentPathCondition readPathcondition(Element ruleElement) {
FilesSet.Rule.ParentPathCondition condition = null;
String path = ruleElement.getAttribute(FilesSetXML.PATH_FILTER_ATTR);
String pathRegex = ruleElement.getAttribute(FilesSetXML.PATH_REGEX_ATTR);
if (!pathRegex.isEmpty() && path.isEmpty()) {
try {
Pattern pattern = Pattern.compile(pathRegex);
filter = new FilesSet.Rule.ParentPathFilter(pattern);
condition = new FilesSet.Rule.ParentPathCondition(pattern);
} catch (PatternSyntaxException ex) {
logger.log(Level.SEVERE, "Error compiling " + FilesSetXML.PATH_REGEX_ATTR + " regex, ignoring malformed path filter definition", ex); // NON-NLS
logger.log(Level.SEVERE, "Error compiling " + FilesSetXML.PATH_REGEX_ATTR + " regex, ignoring malformed path condition definition", ex); // NON-NLS
}
} else if (!path.isEmpty() && pathRegex.isEmpty()) {
filter = new FilesSet.Rule.ParentPathFilter(path);
condition = new FilesSet.Rule.ParentPathCondition(path);
}
return filter;
return condition;
}
/**
@ -517,11 +517,11 @@ final class InterestingItemDefsManager extends Observable {
// Add the child elements for the set membership rules.
for (FilesSet.Rule rule : set.getRules().values()) {
// Add a rule element with the appropriate name filter
// Add a rule element with the appropriate name condition
// type tag.
FilesSet.Rule.FileNameFilter nameFilter = rule.getFileNameFilter();
FilesSet.Rule.FileNameCondition namecondition = rule.getFileNameCondition();
Element ruleElement;
if (nameFilter instanceof FilesSet.Rule.FullNameFilter) {
if (namecondition instanceof FilesSet.Rule.FullNameCondition) {
ruleElement = doc.createElement(FilesSetXML.NAME_RULE_TAG);
} else {
ruleElement = doc.createElement(FilesSetXML.EXTENSION_RULE_TAG);
@ -530,12 +530,12 @@ final class InterestingItemDefsManager extends Observable {
// Add the rule name attribute.
ruleElement.setAttribute(FilesSetXML.NAME_ATTR, rule.getName());
// Add the name filter regex attribute
ruleElement.setAttribute(FilesSetXML.REGEX_ATTR, Boolean.toString(nameFilter.isRegex()));
// Add the name condition regex attribute
ruleElement.setAttribute(FilesSetXML.REGEX_ATTR, Boolean.toString(namecondition.isRegex()));
// Add the type filter attribute.
FilesSet.Rule.MetaTypeCondition typeFilter = rule.getMetaTypeFilter();
switch (typeFilter.getMetaType()) {
// Add the type condition attribute.
FilesSet.Rule.MetaTypeCondition typecondition = rule.getMetaTypeCondition();
switch (typecondition.getMetaType()) {
case FILES:
ruleElement.setAttribute(FilesSetXML.TYPE_FILTER_ATTR, FilesSetXML.TYPE_FILTER_VALUE_FILES);
break;
@ -547,18 +547,18 @@ final class InterestingItemDefsManager extends Observable {
break;
}
// Add the optional path filter.
FilesSet.Rule.ParentPathFilter pathFilter = rule.getPathFilter();
if (pathFilter != null) {
if (pathFilter.isRegex()) {
ruleElement.setAttribute(FilesSetXML.PATH_REGEX_ATTR, pathFilter.getTextToMatch());
// Add the optional path condition.
FilesSet.Rule.ParentPathCondition pathcondition = rule.getPathCondition();
if (pathcondition != null) {
if (pathcondition.isRegex()) {
ruleElement.setAttribute(FilesSetXML.PATH_REGEX_ATTR, pathcondition.getTextToMatch());
} else {
ruleElement.setAttribute(FilesSetXML.PATH_FILTER_ATTR, pathFilter.getTextToMatch());
ruleElement.setAttribute(FilesSetXML.PATH_FILTER_ATTR, pathcondition.getTextToMatch());
}
}
// Add the name filter text as the rule element content.
ruleElement.setTextContent(nameFilter.getTextToMatch());
// Add the name condition text as the rule element content.
ruleElement.setTextContent(namecondition.getTextToMatch());
setElement.appendChild(ruleElement);
}

View File

@ -113,7 +113,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="fileNameRegexCheckbox" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="rulePathFilterRegexCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="rulePathConditionRegexCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
@ -125,7 +125,7 @@
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="rulePathFilterTextField" linkSize="4" alignment="0" min="-2" pref="250" max="-2" attributes="0"/>
<Component id="rulePathConditionTextField" linkSize="4" alignment="0" min="-2" pref="250" max="-2" attributes="0"/>
<Component id="mimeTypeComboBox" linkSize="4" alignment="0" min="-2" pref="248" max="-2" attributes="0"/>
<Component id="fileNameTextField" linkSize="4" alignment="0" min="-2" pref="244" max="-2" attributes="0"/>
<Group type="102" attributes="0">
@ -224,10 +224,10 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="rulePathFilterTextField" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
<Component id="rulePathConditionTextField" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="rulePathFilterRegexCheckBox" min="-2" max="-2" attributes="0"/>
<Component id="rulePathConditionRegexCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
@ -518,16 +518,16 @@
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="rulePathFilterTextField">
<Component class="javax.swing.JTextField" name="rulePathConditionTextField">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="rulePathFilterTextField" property="font" relativeSize="false" size="11"/>
<Font bold="false" component="rulePathConditionTextField" property="font" relativeSize="false" size="11"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties" key="InterestingItemDefsPanel.rulePathFilterTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties" key="InterestingItemDefsPanel.rulePathConditionTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
@ -698,15 +698,15 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="rulePathFilterRegexCheckBox">
<Component class="javax.swing.JCheckBox" name="rulePathConditionRegexCheckBox">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="false" component="rulePathFilterRegexCheckBox" property="font" relativeSize="false" size="11"/>
<Font bold="false" component="rulePathConditionRegexCheckBox" property="font" relativeSize="false" size="11"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties" key="InterestingItemDefsPanel.rulePathFilterRegexCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
<ResourceString bundle="org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties" key="InterestingItemDefsPanel.rulePathConditionRegexCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>

View File

@ -177,8 +177,8 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
this.fileNameRadioButton.setSelected(true);
this.fileNameRegexCheckbox.setSelected(false);
this.filesRadioButton.setSelected(true);
this.rulePathFilterTextField.setText("");
this.rulePathFilterRegexCheckBox.setSelected(false);
this.rulePathConditionTextField.setText("");
this.rulePathConditionRegexCheckBox.setSelected(false);
this.newRuleButton.setEnabled(!this.setsListModel.isEmpty());
this.editRuleButton.setEnabled(false);
this.deleteRuleButton.setEnabled(false);
@ -242,19 +242,19 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
// Get the selected rule and populate the rule components.
FilesSet.Rule rule = InterestingItemDefsPanel.this.rulesList.getSelectedValue();
if (rule != null) {
// Get the filters that make up the rule.
FilesSet.Rule.FileNameFilter nameFilter = rule.getFileNameFilter();
FilesSet.Rule.MetaTypeCondition typeFilter = rule.getMetaTypeFilter();
FilesSet.Rule.ParentPathFilter pathFilter = rule.getPathFilter();
FilesSet.Rule.MimeTypeCondition mimeTypeFilter = rule.getMimeTypeFilter();
// Get the conditions that make up the rule.
FilesSet.Rule.FileNameCondition nameCondition = rule.getFileNameCondition();
FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
FilesSet.Rule.ParentPathCondition pathCondition = rule.getPathCondition();
FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
// Populate the components that display the properties of the
// selected rule.
InterestingItemDefsPanel.this.fileNameTextField.setText(nameFilter.getTextToMatch());
InterestingItemDefsPanel.this.fileNameRadioButton.setSelected(nameFilter instanceof FilesSet.Rule.FullNameFilter);
InterestingItemDefsPanel.this.fileNameExtensionRadioButton.setSelected(nameFilter instanceof FilesSet.Rule.ExtensionFilter);
InterestingItemDefsPanel.this.fileNameRegexCheckbox.setSelected(nameFilter.isRegex());
switch (typeFilter.getMetaType()) {
InterestingItemDefsPanel.this.fileNameTextField.setText(nameCondition.getTextToMatch());
InterestingItemDefsPanel.this.fileNameRadioButton.setSelected(nameCondition instanceof FilesSet.Rule.FullNameCondition);
InterestingItemDefsPanel.this.fileNameExtensionRadioButton.setSelected(nameCondition instanceof FilesSet.Rule.ExtensionCondition);
InterestingItemDefsPanel.this.fileNameRegexCheckbox.setSelected(nameCondition.isRegex());
switch (typeCondition.getMetaType()) {
case FILES:
InterestingItemDefsPanel.this.filesRadioButton.setSelected(true);
break;
@ -265,14 +265,14 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
InterestingItemDefsPanel.this.bothRadioButton.setSelected(true);
break;
}
if (pathFilter != null) {
InterestingItemDefsPanel.this.rulePathFilterTextField.setText(pathFilter.getTextToMatch());
InterestingItemDefsPanel.this.rulePathFilterRegexCheckBox.setSelected(pathFilter.isRegex());
if (pathCondition != null) {
InterestingItemDefsPanel.this.rulePathConditionTextField.setText(pathCondition.getTextToMatch());
InterestingItemDefsPanel.this.rulePathConditionRegexCheckBox.setSelected(pathCondition.isRegex());
} else {
InterestingItemDefsPanel.this.rulePathFilterTextField.setText("");
InterestingItemDefsPanel.this.rulePathFilterRegexCheckBox.setSelected(false);
InterestingItemDefsPanel.this.rulePathConditionTextField.setText("");
InterestingItemDefsPanel.this.rulePathConditionRegexCheckBox.setSelected(false);
}
InterestingItemDefsPanel.this.mimeTypeComboBox.setSelectedItem(mimeTypeFilter.getMimeType());
InterestingItemDefsPanel.this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
// Enable the new, edit and delete rule buttons.
InterestingItemDefsPanel.this.newRuleButton.setEnabled(true);
@ -371,7 +371,7 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
if (selectedRule != null) {
rules.remove(selectedRule.getUuid());
}
FilesSet.Rule newRule = new FilesSet.Rule(panel.getRuleName(), panel.getFileNameFilter(), panel.getMetaTypeFilter(), panel.getPathFilter(), panel.getMimeTypeCondition(), panel.getFileSizeCondition());
FilesSet.Rule newRule = new FilesSet.Rule(panel.getRuleName(), panel.getFileNameCondition(), panel.getMetaTypeCondition(), panel.getPathCondition(), panel.getMimeTypeCondition(), panel.getFileSizeCondition());
rules.put(newRule.getUuid(), newRule);
// Add the new/edited files set definition, replacing any previous
@ -454,7 +454,7 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
fileNameTextField = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
fileNameRadioButton = new javax.swing.JRadioButton();
rulePathFilterTextField = new javax.swing.JTextField();
rulePathConditionTextField = new javax.swing.JTextField();
ignoreKnownFilesCheckbox = new javax.swing.JCheckBox();
fileNameRegexCheckbox = new javax.swing.JCheckBox();
separator = new javax.swing.JSeparator();
@ -467,7 +467,7 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
dirsRadioButton = new javax.swing.JRadioButton();
jLabel1 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
rulePathFilterRegexCheckBox = new javax.swing.JCheckBox();
rulePathConditionRegexCheckBox = new javax.swing.JCheckBox();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel7 = new javax.swing.JLabel();
@ -566,9 +566,9 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
org.openide.awt.Mnemonics.setLocalizedText(fileNameRadioButton, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.fileNameRadioButton.text")); // NOI18N
fileNameRadioButton.setEnabled(false);
rulePathFilterTextField.setEditable(false);
rulePathFilterTextField.setFont(rulePathFilterTextField.getFont().deriveFont(rulePathFilterTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
rulePathFilterTextField.setText(org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.rulePathFilterTextField.text")); // NOI18N
rulePathConditionTextField.setEditable(false);
rulePathConditionTextField.setFont(rulePathConditionTextField.getFont().deriveFont(rulePathConditionTextField.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
rulePathConditionTextField.setText(org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.rulePathConditionTextField.text")); // NOI18N
ignoreKnownFilesCheckbox.setFont(ignoreKnownFilesCheckbox.getFont().deriveFont(ignoreKnownFilesCheckbox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
org.openide.awt.Mnemonics.setLocalizedText(ignoreKnownFilesCheckbox, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.ignoreKnownFilesCheckbox.text")); // NOI18N
@ -639,9 +639,9 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
jLabel4.setFont(jLabel4.getFont().deriveFont(jLabel4.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.jLabel4.text")); // NOI18N
rulePathFilterRegexCheckBox.setFont(rulePathFilterRegexCheckBox.getFont().deriveFont(rulePathFilterRegexCheckBox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
org.openide.awt.Mnemonics.setLocalizedText(rulePathFilterRegexCheckBox, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.rulePathFilterRegexCheckBox.text")); // NOI18N
rulePathFilterRegexCheckBox.setEnabled(false);
rulePathConditionRegexCheckBox.setFont(rulePathConditionRegexCheckBox.getFont().deriveFont(rulePathConditionRegexCheckBox.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
org.openide.awt.Mnemonics.setLocalizedText(rulePathConditionRegexCheckBox, org.openide.util.NbBundle.getMessage(InterestingItemDefsPanel.class, "InterestingItemDefsPanel.rulePathConditionRegexCheckBox.text")); // NOI18N
rulePathConditionRegexCheckBox.setEnabled(false);
jScrollPane2.setFont(jScrollPane2.getFont().deriveFont(jScrollPane2.getFont().getStyle() & ~java.awt.Font.BOLD, 11));
@ -713,7 +713,7 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
.addComponent(fileNameExtensionRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(fileNameRegexCheckbox))
.addComponent(rulePathFilterRegexCheckBox)))
.addComponent(rulePathConditionRegexCheckBox)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(354, 354, 354)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -722,7 +722,7 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(rulePathFilterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(rulePathConditionTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(mimeTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fileNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
@ -762,7 +762,7 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
.addContainerGap(26, Short.MAX_VALUE))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {fileNameTextField, mimeTypeComboBox, rulePathFilterTextField});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {fileNameTextField, mimeTypeComboBox, rulePathConditionTextField});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -806,9 +806,9 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(rulePathFilterTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(rulePathConditionTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rulePathFilterRegexCheckBox)
.addComponent(rulePathConditionRegexCheckBox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
@ -937,8 +937,8 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
private javax.swing.JComboBox mimeTypeComboBox;
private javax.swing.JButton newRuleButton;
private javax.swing.JButton newSetButton;
private javax.swing.JCheckBox rulePathFilterRegexCheckBox;
private javax.swing.JTextField rulePathFilterTextField;
private javax.swing.JCheckBox rulePathConditionRegexCheckBox;
private javax.swing.JTextField rulePathConditionTextField;
private javax.swing.JList<FilesSet.Rule> rulesList;
private javax.swing.JLabel rulesListLabel;
private javax.swing.JScrollPane rulesListScrollPane;