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
*
* Copyright 2014 Basis Technology Corp.
* Copyright 2014-2018 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* 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
* flag to create a template for creating fully configured ingest modules.
*/
final class IngestModuleTemplate {
public final class IngestModuleTemplate {
private final IngestModuleFactory moduleFactory;
private IngestModuleIngestJobSettings settings = null;
private boolean enabled = true;
IngestModuleTemplate(IngestModuleFactory moduleFactory, IngestModuleIngestJobSettings settings) {
public IngestModuleTemplate(IngestModuleFactory moduleFactory, IngestModuleIngestJobSettings settings) {
this.moduleFactory = moduleFactory;
this.settings = settings;
}
IngestModuleFactory getModuleFactory() {
public IngestModuleFactory getModuleFactory() {
return moduleFactory;
}
String getModuleName() {
public String getModuleName() {
return moduleFactory.getModuleDisplayName();
}
String getModuleDescription() {
public String getModuleDescription() {
return moduleFactory.getModuleDescription();
}
IngestModuleIngestJobSettings getModuleSettings() {
public IngestModuleIngestJobSettings getModuleSettings() {
return settings;
}
void setModuleSettings(IngestModuleIngestJobSettings settings) {
public void setModuleSettings(IngestModuleIngestJobSettings settings) {
this.settings = settings;
}
boolean hasModuleSettingsPanel() {
public boolean hasModuleSettingsPanel() {
return moduleFactory.hasIngestJobSettingsPanel();
}
IngestModuleIngestJobSettingsPanel getModuleSettingsPanel() {
public IngestModuleIngestJobSettingsPanel getModuleSettingsPanel() {
return moduleFactory.getIngestJobSettingsPanel(settings);
}
boolean hasGlobalSettingsPanel() {
public boolean hasGlobalSettingsPanel() {
return moduleFactory.hasGlobalSettingsPanel();
}
IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() {
public IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() {
return moduleFactory.getGlobalSettingsPanel();
}
boolean isDataSourceIngestModuleTemplate() {
public boolean isDataSourceIngestModuleTemplate() {
return moduleFactory.isDataSourceIngestModuleFactory();
}
DataSourceIngestModule createDataSourceIngestModule() {
public DataSourceIngestModule createDataSourceIngestModule() {
return moduleFactory.createDataSourceIngestModule(settings);
}
boolean isFileIngestModuleTemplate() {
public boolean isFileIngestModuleTemplate() {
return moduleFactory.isFileIngestModuleFactory();
}
FileIngestModule createFileIngestModule() {
public FileIngestModule createFileIngestModule() {
return moduleFactory.createFileIngestModule(settings);
}
void setEnabled(boolean enabled) {
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
boolean isEnabled() {
public boolean isEnabled() {
return enabled;
}
}

View File

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