Merge remote-tracking branch 'upstream/develop' into 3583_AutoIngestDashboardInstances

This commit is contained in:
U-BASIS\dgrove 2018-03-13 17:57:50 -04:00
commit a4374da87e
2 changed files with 77 additions and 73 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2014 Basis Technology Corp. * Copyright 2014-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -22,74 +22,75 @@ package org.sleuthkit.autopsy.ingest;
* Combines an ingest module factory with ingest module settings and an enabled * Combines an ingest module factory with ingest module settings and an enabled
* flag to create a template for creating fully configured ingest modules. * flag to create a template for creating fully configured ingest modules.
*/ */
final class IngestModuleTemplate { public final class IngestModuleTemplate {
private final IngestModuleFactory moduleFactory; private final IngestModuleFactory moduleFactory;
private IngestModuleIngestJobSettings settings = null; private IngestModuleIngestJobSettings settings = null;
private boolean enabled = true; private boolean enabled = true;
IngestModuleTemplate(IngestModuleFactory moduleFactory, IngestModuleIngestJobSettings settings) { public IngestModuleTemplate(IngestModuleFactory moduleFactory, IngestModuleIngestJobSettings settings) {
this.moduleFactory = moduleFactory; this.moduleFactory = moduleFactory;
this.settings = settings; this.settings = settings;
} }
IngestModuleFactory getModuleFactory() { public IngestModuleFactory getModuleFactory() {
return moduleFactory; return moduleFactory;
} }
String getModuleName() { public String getModuleName() {
return moduleFactory.getModuleDisplayName(); return moduleFactory.getModuleDisplayName();
} }
String getModuleDescription() { public String getModuleDescription() {
return moduleFactory.getModuleDescription(); return moduleFactory.getModuleDescription();
} }
IngestModuleIngestJobSettings getModuleSettings() { public IngestModuleIngestJobSettings getModuleSettings() {
return settings; return settings;
} }
void setModuleSettings(IngestModuleIngestJobSettings settings) { public void setModuleSettings(IngestModuleIngestJobSettings settings) {
this.settings = settings; this.settings = settings;
} }
boolean hasModuleSettingsPanel() { public boolean hasModuleSettingsPanel() {
return moduleFactory.hasIngestJobSettingsPanel(); return moduleFactory.hasIngestJobSettingsPanel();
} }
IngestModuleIngestJobSettingsPanel getModuleSettingsPanel() { public IngestModuleIngestJobSettingsPanel getModuleSettingsPanel() {
return moduleFactory.getIngestJobSettingsPanel(settings); return moduleFactory.getIngestJobSettingsPanel(settings);
} }
boolean hasGlobalSettingsPanel() { public boolean hasGlobalSettingsPanel() {
return moduleFactory.hasGlobalSettingsPanel(); return moduleFactory.hasGlobalSettingsPanel();
} }
IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() { public IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() {
return moduleFactory.getGlobalSettingsPanel(); return moduleFactory.getGlobalSettingsPanel();
} }
boolean isDataSourceIngestModuleTemplate() { public boolean isDataSourceIngestModuleTemplate() {
return moduleFactory.isDataSourceIngestModuleFactory(); return moduleFactory.isDataSourceIngestModuleFactory();
} }
DataSourceIngestModule createDataSourceIngestModule() { public DataSourceIngestModule createDataSourceIngestModule() {
return moduleFactory.createDataSourceIngestModule(settings); return moduleFactory.createDataSourceIngestModule(settings);
} }
boolean isFileIngestModuleTemplate() { public boolean isFileIngestModuleTemplate() {
return moduleFactory.isFileIngestModuleFactory(); return moduleFactory.isFileIngestModuleFactory();
} }
FileIngestModule createFileIngestModule() { public FileIngestModule createFileIngestModule() {
return moduleFactory.createFileIngestModule(settings); return moduleFactory.createFileIngestModule(settings);
} }
void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
this.enabled = enabled; this.enabled = enabled;
} }
boolean isEnabled() { public boolean isEnabled() {
return enabled; return enabled;
} }
} }

View File

@ -98,7 +98,7 @@ public final class FilesSet implements Serializable {
* *
* @return True if known files are ignored, false otherwise. * @return True if known files are ignored, false otherwise.
*/ */
boolean ignoresKnownFiles() { public boolean ignoresKnownFiles() {
return this.ignoreKnownFiles; return this.ignoreKnownFiles;
} }
@ -117,7 +117,7 @@ public final class FilesSet implements Serializable {
* *
* @return A map of set membership rule names to rules, possibly empty. * @return A map of set membership rule names to rules, possibly empty.
*/ */
Map<String, Rule> getRules() { public Map<String, Rule> getRules() {
return new HashMap<>(this.rules); return new HashMap<>(this.rules);
} }
@ -160,7 +160,7 @@ public final class FilesSet implements Serializable {
* A set membership rule for an interesting files set. The immutability of a * A set membership rule for an interesting files set. The immutability of a
* rule object allows it to be safely published to multiple threads. * rule object allows it to be safely published to multiple threads.
*/ */
static class Rule implements Serializable { public final static class Rule implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final String uuid; private final String uuid;
@ -185,7 +185,7 @@ public final class FilesSet implements Serializable {
* @param dateCondition A file date created or modified condition, * @param dateCondition A file date created or modified condition,
* may be null * may be null
*/ */
Rule(String ruleName, FileNameCondition fileNameCondition, MetaTypeCondition metaTypeCondition, ParentPathCondition pathCondition, MimeTypeCondition mimeTypeCondition, FileSizeCondition fileSizeCondition, DateCondition dateCondition) { public Rule(String ruleName, FileNameCondition fileNameCondition, MetaTypeCondition metaTypeCondition, ParentPathCondition pathCondition, MimeTypeCondition mimeTypeCondition, FileSizeCondition fileSizeCondition, DateCondition dateCondition) {
// since ruleName is optional, ruleUUID can be used to uniquely identify a rule. // since ruleName is optional, ruleUUID can be used to uniquely identify a rule.
this.uuid = UUID.randomUUID().toString(); this.uuid = UUID.randomUUID().toString();
if (metaTypeCondition == null) { if (metaTypeCondition == null) {
@ -231,7 +231,7 @@ public final class FilesSet implements Serializable {
* *
* @return A name string. * @return A name string.
*/ */
String getName() { public String getName() {
return ruleName; return ruleName;
} }
@ -240,7 +240,7 @@ public final class FilesSet implements Serializable {
* *
* @return A file name condition. Can be null. * @return A file name condition. Can be null.
*/ */
FileNameCondition getFileNameCondition() { public FileNameCondition getFileNameCondition() {
return this.fileNameCondition; return this.fileNameCondition;
} }
@ -249,7 +249,7 @@ public final class FilesSet implements Serializable {
* *
* @return A meta-type condition. Can be null. * @return A meta-type condition. Can be null.
*/ */
MetaTypeCondition getMetaTypeCondition() { public MetaTypeCondition getMetaTypeCondition() {
return this.metaTypeCondition; return this.metaTypeCondition;
} }
@ -258,11 +258,11 @@ public final class FilesSet implements Serializable {
* *
* @return A path condition, may be null. * @return A path condition, may be null.
*/ */
ParentPathCondition getPathCondition() { public ParentPathCondition getPathCondition() {
return this.pathCondition; return this.pathCondition;
} }
DateCondition getDateCondition() { public DateCondition getDateCondition() {
return this.dateCondition; return this.dateCondition;
} }
@ -273,7 +273,7 @@ public final class FilesSet implements Serializable {
* *
* @return True if the rule is satisfied, false otherwise. * @return True if the rule is satisfied, false otherwise.
*/ */
boolean isSatisfied(AbstractFile file) { public boolean isSatisfied(AbstractFile file) {
for (FileAttributeCondition condition : conditions) { for (FileAttributeCondition condition : conditions) {
if (!condition.passes(file)) { if (!condition.passes(file)) {
return false; return false;
@ -317,14 +317,14 @@ public final class FilesSet implements Serializable {
/** /**
* @return the mime type condition. Can be null. * @return the mime type condition. Can be null.
*/ */
MimeTypeCondition getMimeTypeCondition() { public MimeTypeCondition getMimeTypeCondition() {
return mimeTypeCondition; return mimeTypeCondition;
} }
/** /**
* @return the file size condition. Can be null. * @return the file size condition. Can be null.
*/ */
FileSizeCondition getFileSizeCondition() { public FileSizeCondition getFileSizeCondition() {
return fileSizeCondition; return fileSizeCondition;
} }
@ -347,7 +347,7 @@ public final class FilesSet implements Serializable {
/** /**
* A class for checking files based upon their MIME types. * A class for checking files based upon their MIME types.
*/ */
static final class MimeTypeCondition implements FileAttributeCondition { public static final class MimeTypeCondition implements FileAttributeCondition {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final String mimeType; private final String mimeType;
@ -357,7 +357,7 @@ public final class FilesSet implements Serializable {
* *
* @param mimeType The mime type to condition for * @param mimeType The mime type to condition for
*/ */
MimeTypeCondition(String mimeType) { public MimeTypeCondition(String mimeType) {
this.mimeType = mimeType; this.mimeType = mimeType;
} }
@ -371,7 +371,7 @@ public final class FilesSet implements Serializable {
* *
* @return the mime type * @return the mime type
*/ */
String getMimeType() { public String getMimeType() {
return this.mimeType; return this.mimeType;
} }
@ -381,14 +381,14 @@ public final class FilesSet implements Serializable {
* A class for checking whether a file's size is within the * A class for checking whether a file's size is within the
* specifications given (i.e. < N Bytes). * specifications given (i.e. < N Bytes).
*/ */
static final class FileSizeCondition implements FileAttributeCondition { public static final class FileSizeCondition implements FileAttributeCondition {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* Represents a comparison item for file size * Represents a comparison item for file size
*/ */
static enum COMPARATOR { public static enum COMPARATOR {
LESS_THAN("<"), LESS_THAN("<"),
LESS_THAN_EQUAL(""), LESS_THAN_EQUAL(""),
@ -398,23 +398,27 @@ public final class FilesSet implements Serializable {
private String symbol; private String symbol;
COMPARATOR(String symbol) { private COMPARATOR(String symbol) {
this.symbol = symbol; this.symbol = symbol;
} }
public static COMPARATOR fromSymbol(String symbol) { public static COMPARATOR fromSymbol(String symbol) {
if (symbol.equals("<=") || symbol.equals("")) { switch (symbol) {
return LESS_THAN_EQUAL; case "<=":
} else if (symbol.equals("<")) { case "":
return LESS_THAN; return LESS_THAN_EQUAL;
} else if (symbol.equals("==") || symbol.equals("=")) { case "<":
return EQUAL; return LESS_THAN;
} else if (symbol.equals(">")) { case "==":
return GREATER_THAN; case "=":
} else if (symbol.equals(">=") || symbol.equals("")) { return EQUAL;
return GREATER_THAN_EQUAL; case ">":
} else { return GREATER_THAN;
throw new IllegalArgumentException("Invalid symbol"); case ">=":
case "":
return GREATER_THAN_EQUAL;
default:
throw new IllegalArgumentException("Invalid symbol");
} }
} }
@ -429,7 +433,7 @@ public final class FilesSet implements Serializable {
/** /**
* Represents the units of size * Represents the units of size
*/ */
static enum SIZE_UNIT { public static enum SIZE_UNIT {
BYTE(1, "Bytes"), BYTE(1, "Bytes"),
KILOBYTE(1024, "Kilobytes"), KILOBYTE(1024, "Kilobytes"),
@ -467,7 +471,7 @@ public final class FilesSet implements Serializable {
private final SIZE_UNIT unit; private final SIZE_UNIT unit;
private final int sizeValue; private final int sizeValue;
FileSizeCondition(COMPARATOR comparator, SIZE_UNIT unit, int sizeValue) { public FileSizeCondition(COMPARATOR comparator, SIZE_UNIT unit, int sizeValue) {
this.comparator = comparator; this.comparator = comparator;
this.unit = unit; this.unit = unit;
this.sizeValue = sizeValue; this.sizeValue = sizeValue;
@ -478,7 +482,7 @@ public final class FilesSet implements Serializable {
* *
* @return the comparator * @return the comparator
*/ */
COMPARATOR getComparator() { public COMPARATOR getComparator() {
return comparator; return comparator;
} }
@ -487,7 +491,7 @@ public final class FilesSet implements Serializable {
* *
* @return the unit * @return the unit
*/ */
SIZE_UNIT getUnit() { public SIZE_UNIT getUnit() {
return unit; return unit;
} }
@ -496,7 +500,7 @@ public final class FilesSet implements Serializable {
* *
* @return the size value * @return the size value
*/ */
int getSizeValue() { public int getSizeValue() {
return sizeValue; return sizeValue;
} }
@ -526,11 +530,11 @@ public final class FilesSet implements Serializable {
* rule. The immutability of a meta-type condition object allows it to * rule. The immutability of a meta-type condition object allows it to
* be safely published to multiple threads. * be safely published to multiple threads.
*/ */
static final class MetaTypeCondition implements FileAttributeCondition { public static final class MetaTypeCondition implements FileAttributeCondition {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
enum Type { public enum Type {
FILES, FILES,
DIRECTORIES, DIRECTORIES,
@ -545,7 +549,7 @@ public final class FilesSet implements Serializable {
* *
* @param metaType The meta-type to match, must. * @param metaType The meta-type to match, must.
*/ */
MetaTypeCondition(Type type) { public MetaTypeCondition(Type type) {
this.type = type; this.type = type;
} }
@ -573,7 +577,7 @@ public final class FilesSet implements Serializable {
* *
* @return A member of the MetaTypeCondition.Type enumeration. * @return A member of the MetaTypeCondition.Type enumeration.
*/ */
Type getMetaType() { public Type getMetaType() {
return this.type; return this.type;
} }
} }
@ -616,6 +620,7 @@ public final class FilesSet implements Serializable {
*/ */
private static abstract class AbstractTextCondition implements TextCondition { private static abstract class AbstractTextCondition implements TextCondition {
private static final long serialVersionUID = 1L;
private final TextMatcher textMatcher; private final TextMatcher textMatcher;
/** /**
@ -684,7 +689,7 @@ public final class FilesSet implements Serializable {
* The immutability of a path condition object allows it to be safely * The immutability of a path condition object allows it to be safely
* published to multiple threads. * published to multiple threads.
*/ */
static final class ParentPathCondition extends AbstractTextCondition { public static final class ParentPathCondition extends AbstractTextCondition {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -693,7 +698,7 @@ public final class FilesSet implements Serializable {
* *
* @param path The path to be matched. * @param path The path to be matched.
*/ */
ParentPathCondition(String path) { public ParentPathCondition(String path) {
super(path, true); super(path, true);
} }
@ -702,7 +707,7 @@ public final class FilesSet implements Serializable {
* *
* @param path The path regular expression to be matched. * @param path The path regular expression to be matched.
*/ */
ParentPathCondition(Pattern path) { public ParentPathCondition(Pattern path) {
super(path); super(path);
} }
@ -726,7 +731,7 @@ public final class FilesSet implements Serializable {
* The immutability of a file name condition object allows it to be * The immutability of a file name condition object allows it to be
* safely published to multiple threads. * safely published to multiple threads.
*/ */
static final class FullNameCondition extends AbstractTextCondition implements FileNameCondition { public static final class FullNameCondition extends AbstractTextCondition implements FileNameCondition {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -735,7 +740,7 @@ public final class FilesSet implements Serializable {
* *
* @param name The file name to be matched. * @param name The file name to be matched.
*/ */
FullNameCondition(String name) { public FullNameCondition(String name) {
super(name, false); super(name, false);
} }
@ -744,7 +749,7 @@ public final class FilesSet implements Serializable {
* *
* @param name The file name regular expression to be matched. * @param name The file name regular expression to be matched.
*/ */
FullNameCondition(Pattern name) { public FullNameCondition(Pattern name) {
super(name); super(name);
} }
@ -759,8 +764,9 @@ public final class FilesSet implements Serializable {
* A class for checking whether a file's creation or modification * A class for checking whether a file's creation or modification
* occured in a specific range of time * occured in a specific range of time
*/ */
static final class DateCondition implements FileAttributeCondition { public static final class DateCondition implements FileAttributeCondition {
private static final long serialVersionUID = 1L;
private final static long SECS_PER_DAY = 60 * 60 * 24; private final static long SECS_PER_DAY = 60 * 60 * 24;
private int daysIncluded; private int daysIncluded;
@ -771,7 +777,7 @@ public final class FilesSet implements Serializable {
* @param days - files created or modified more recently than this * @param days - files created or modified more recently than this
* number of days will pass * number of days will pass
*/ */
DateCondition(int days) { public DateCondition(int days) {
daysIncluded = days; daysIncluded = days;
} }
@ -780,17 +786,14 @@ public final class FilesSet implements Serializable {
* *
* @return integer value of the number days which will pass * @return integer value of the number days which will pass
*/ */
int getDaysIncluded() { public int getDaysIncluded() {
return daysIncluded; return daysIncluded;
} }
@Override @Override
public boolean passes(AbstractFile file) { public boolean passes(AbstractFile file) {
long dateThreshold = System.currentTimeMillis() / 1000 - daysIncluded * SECS_PER_DAY; long dateThreshold = System.currentTimeMillis() / 1000 - daysIncluded * SECS_PER_DAY;
if (file.getCrtime() > dateThreshold || file.getMtime() > dateThreshold) { return file.getCrtime() > dateThreshold || file.getMtime() > dateThreshold;
return true;
}
return false;
} }
} }
@ -800,7 +803,7 @@ public final class FilesSet implements Serializable {
* membership rule. The immutability of a file name extension condition * membership rule. The immutability of a file name extension condition
* object allows it to be safely published to multiple threads. * object allows it to be safely published to multiple threads.
*/ */
static final class ExtensionCondition extends AbstractTextCondition implements FileNameCondition { public static final class ExtensionCondition extends AbstractTextCondition implements FileNameCondition {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -809,7 +812,7 @@ public final class FilesSet implements Serializable {
* *
* @param extension The file name extension to be matched. * @param extension The file name extension to be matched.
*/ */
ExtensionCondition(String extension) { public ExtensionCondition(String extension) {
// If there is a leading ".", strip it since // If there is a leading ".", strip it since
// AbstractFile.getFileNameExtension() returns just the // AbstractFile.getFileNameExtension() returns just the
// extension chars and not the dot. // extension chars and not the dot.
@ -822,7 +825,7 @@ public final class FilesSet implements Serializable {
* @param extension The file name extension regular expression to be * @param extension The file name extension regular expression to be
* matched. * matched.
*/ */
ExtensionCondition(Pattern extension) { public ExtensionCondition(Pattern extension) {
super(extension); super(extension);
} }