mirror of
https://github.com/elisspace/autopsy.git
synced 2026-09-02 17:45:51 +00:00
Work on ingest framework API
This commit is contained in:
@@ -70,7 +70,7 @@ public class IngestConfigurator {
|
||||
// NOTE: In the future, this code will be modified to get the ingest
|
||||
// options for each module for the current context; for now just
|
||||
// get the default ingest options.
|
||||
IngestModuleTemplate moduleTemplate = new IngestModuleTemplate(moduleFactory, moduleFactory.getDefaultPerIngestJobOptions());
|
||||
IngestModuleTemplate moduleTemplate = new IngestModuleTemplate(moduleFactory, moduleFactory.getDefaultIngestOptions());
|
||||
String moduleName = moduleTemplate.getIngestModuleFactory().getModuleDisplayName();
|
||||
if (enabledModuleNames.contains(moduleName)) {
|
||||
moduleTemplate.setEnabled(true);
|
||||
|
||||
@@ -82,7 +82,7 @@ public interface IngestModuleFactory {
|
||||
*
|
||||
* @return The ingest options.
|
||||
*/
|
||||
IngestModuleOptions getDefaultPerIngestJobOptions();
|
||||
IngestModuleOptions getDefaultIngestOptions();
|
||||
|
||||
/**
|
||||
* Queries the factory to determine if it provides user interface panels to
|
||||
|
||||
@@ -34,7 +34,7 @@ public abstract class IngestModuleFactoryAdapter implements IngestModuleFactory
|
||||
public abstract String getModuleVersionNumber();
|
||||
|
||||
@Override
|
||||
public IngestModuleOptions getDefaultPerIngestJobOptions() {
|
||||
public IngestModuleOptions getDefaultIngestOptions() {
|
||||
return new NoIngestOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class FileExtMismatchDetectorModuleFactory extends IngestModuleFactoryAda
|
||||
}
|
||||
|
||||
@Override
|
||||
public IngestModuleOptions getDefaultPerIngestJobOptions() {
|
||||
public IngestModuleOptions getDefaultIngestOptions() {
|
||||
return new FileExtMismatchDetectorOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,17 +38,17 @@ import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.autopsy.hashdatabase.HashDbManager.HashDb;
|
||||
import org.sleuthkit.autopsy.hashdatabase.HashDbManager.HashDb.KnownFilesType;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleResourcesConfigPanel;
|
||||
|
||||
/**
|
||||
* Instances of this class provide a comprehensive UI for managing the hash sets configuration.
|
||||
*/
|
||||
public final class HashDbConfigPanel extends javax.swing.JPanel implements OptionsPanel {
|
||||
public final class HashDbConfigPanel extends IngestModuleResourcesConfigPanel {
|
||||
private static final String NO_SELECTION_TEXT = NbBundle
|
||||
.getMessage(HashDbConfigPanel.class, "HashDbConfigPanel.noSelectionText");
|
||||
private static final String ERROR_GETTING_PATH_TEXT = NbBundle
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011 - 2013 Basis Technology Corp.
|
||||
* Copyright 2011 - 2014 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package org.sleuthkit.autopsy.hashdatabase;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.JOptionPane;
|
||||
@@ -34,11 +32,13 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.autopsy.hashdatabase.HashDbManager.HashDb;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleOptions;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleOptionsPanel;
|
||||
|
||||
/**
|
||||
* Instances of this class provide a simplified UI for managing the hash sets configuration.
|
||||
*/
|
||||
public class HashDbSimpleConfigPanel extends javax.swing.JPanel {
|
||||
public class HashDbSimpleConfigPanel extends IngestModuleOptionsPanel {
|
||||
|
||||
private HashDatabasesTableModel knownTableModel;
|
||||
private HashDatabasesTableModel knownBadTableModel;
|
||||
@@ -54,16 +54,6 @@ public class HashDbSimpleConfigPanel extends javax.swing.JPanel {
|
||||
customizeHashDbsTable(jScrollPane1, knownHashTable, knownTableModel);
|
||||
customizeHashDbsTable(jScrollPane2, knownBadHashTable, knownBadTableModel);
|
||||
alwaysCalcHashesCheckbox.setSelected(HashDbManager.getInstance().getAlwaysCalculateHashes());
|
||||
|
||||
// Add a listener to the always calculate hashes checkbox component.
|
||||
// The listener passes the user's selection on to the hash database manager.
|
||||
alwaysCalcHashesCheckbox.addActionListener( new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
HashDbManager.getInstance().setAlwaysCalculateHashes(alwaysCalcHashesCheckbox.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -85,6 +75,15 @@ public class HashDbSimpleConfigPanel extends javax.swing.JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IngestModuleOptions getIngestOptions() {
|
||||
// RJCTODO: Work out how this works, load() and store(), etc.
|
||||
HashDbManager hashDbManager = HashDbManager.getInstance();
|
||||
List<HashDbManager.HashDb> knownFileHashSets = hashDbManager.getKnownFileHashSets();
|
||||
List<HashDbManager.HashDb> knownBadFileHashSets = hashDbManager.getKnownBadFileHashSets();
|
||||
return new HashLookupOptions(alwaysCalcHashesCheckbox.isSelected(), knownFileHashSets, knownBadFileHashSets);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
knownTableModel.load();
|
||||
knownBadTableModel.load();
|
||||
@@ -256,7 +255,7 @@ public class HashDbSimpleConfigPanel extends javax.swing.JPanel {
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void alwaysCalcHashesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alwaysCalcHashesCheckboxActionPerformed
|
||||
// TODO add your handling code here:
|
||||
HashDbManager.getInstance().setAlwaysCalculateHashes(alwaysCalcHashesCheckbox.isSelected());
|
||||
}//GEN-LAST:event_alwaysCalcHashesCheckboxActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
||||
@@ -16,107 +16,79 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.sleuthkit.autopsy.hashdatabase;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.JPanel;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.lookup.ServiceProvider;
|
||||
import org.sleuthkit.autopsy.coreutils.Version;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactoryAdapter;
|
||||
import org.sleuthkit.autopsy.ingest.FileIngestModule;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleOptions;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleOptionsPanel;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleResourcesConfigPanel;
|
||||
|
||||
/**
|
||||
* A factory that creates file ingest modules that do hash database lookups.
|
||||
*/
|
||||
@ServiceProvider(service=IngestModuleFactory.class)
|
||||
public class HashLookupModuleFactory extends IngestModuleFactoryAdapter {
|
||||
@ServiceProvider(service = IngestModuleFactory.class)
|
||||
public class HashLookupModuleFactory extends IngestModuleFactoryAdapter {
|
||||
|
||||
@Override
|
||||
public String getModuleDisplayName() {
|
||||
return getModuleName();
|
||||
}
|
||||
|
||||
|
||||
static String getModuleName() {
|
||||
return NbBundle.getMessage(HashDbIngestModule.class, "HashDbIngestModule.moduleName");
|
||||
return NbBundle.getMessage(HashDbIngestModule.class, "HashDbIngestModule.moduleName");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModuleDescription() {
|
||||
return NbBundle.getMessage(HashDbIngestModule.class, "HashDbIngestModule.moduleDescription");
|
||||
return NbBundle.getMessage(HashDbIngestModule.class, "HashDbIngestModule.moduleDescription");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getModuleVersionNumber() {
|
||||
return Version.getVersion();
|
||||
return Version.getVersion();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Serializable getDefaultPerIngestJobOptions() {
|
||||
return new IngestOptions();
|
||||
public IngestModuleOptions getDefaultIngestOptions() {
|
||||
return new HashLookupOptions();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean providesIngestOptionsPanels() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getIngestOptionsPanel(Serializable ingestOptions) {
|
||||
HashDbSimpleConfigPanel ingestOptionsPanel = new HashDbSimpleConfigPanel();
|
||||
ingestOptionsPanel.load();
|
||||
return ingestOptionsPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getIngestOptionsFromPanel(JPanel ingestOptionsPanel) throws InvalidOptionsException {
|
||||
if (!(ingestOptionsPanel instanceof HashDbSimpleConfigPanel)) {
|
||||
throw new IllegalArgumentException("JPanel not a HashDbSimpleConfigPanel");
|
||||
}
|
||||
|
||||
HashDbSimpleConfigPanel panel = (HashDbSimpleConfigPanel)ingestOptionsPanel;
|
||||
panel.store();
|
||||
|
||||
return new IngestOptions(); // RJCTODO
|
||||
@Override
|
||||
public IngestModuleOptionsPanel getIngestOptionsPanel(IngestModuleOptions ingestOptions) {
|
||||
HashDbSimpleConfigPanel ingestOptionsPanel = new HashDbSimpleConfigPanel();
|
||||
ingestOptionsPanel.load();
|
||||
return ingestOptionsPanel;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean providesResourcesConfigPanels() {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JPanel getGlobalOptionsPanel() {
|
||||
HashDbConfigPanel globalOptionsPanel = new HashDbConfigPanel();
|
||||
globalOptionsPanel.load();
|
||||
return globalOptionsPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveGlobalOptionsFromPanel(JPanel globalOptionsPanel) throws InvalidOptionsException {
|
||||
if (!(globalOptionsPanel instanceof HashDbConfigPanel)) {
|
||||
throw new IllegalArgumentException("JPanel not a HashDbConfigPanel");
|
||||
}
|
||||
|
||||
HashDbConfigPanel panel = (HashDbConfigPanel)globalOptionsPanel;
|
||||
panel.store();
|
||||
public IngestModuleResourcesConfigPanel getResourcesConfigPanel() {
|
||||
HashDbConfigPanel resourcesConfigPanel = new HashDbConfigPanel();
|
||||
resourcesConfigPanel.load();
|
||||
return resourcesConfigPanel;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isFileIngestModuleFactory() {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FileIngestModule createFileIngestModule(Serializable ingestOptions) throws InvalidOptionsException {
|
||||
public FileIngestModule createFileIngestModule(IngestModuleOptions ingestOptions) throws InvalidOptionsException {
|
||||
return new HashDbIngestModule();
|
||||
}
|
||||
|
||||
private static class IngestOptions implements Serializable {
|
||||
// RJCTODO: fill out
|
||||
boolean alwaysCalcHashes = true;
|
||||
ArrayList<String> hashSetNames = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
76
HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashLookupOptions.java
Executable file
76
HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashLookupOptions.java
Executable file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2014 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.hashdatabase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleOptions;
|
||||
|
||||
/**
|
||||
* Ingest options for the hash lookup file ingest module.
|
||||
*/
|
||||
// Note that this class is not yet used as intended.
|
||||
public class HashLookupOptions implements IngestModuleOptions {
|
||||
|
||||
private boolean shouldCalculateHashes = true;
|
||||
private ArrayList<HashDbManager.HashDb> knownFileHashSets;
|
||||
private ArrayList<HashDbManager.HashDb> knownBadFileHashSets;
|
||||
|
||||
HashLookupOptions() {
|
||||
shouldCalculateHashes = true;
|
||||
knownFileHashSets = new ArrayList<>();
|
||||
knownBadFileHashSets = new ArrayList<>();
|
||||
}
|
||||
|
||||
HashLookupOptions(boolean shouldCalculateHashes, List<HashDbManager.HashDb> knownFileHashSets, List<HashDbManager.HashDb> knownBadFileHashSets) {
|
||||
this.shouldCalculateHashes = shouldCalculateHashes;
|
||||
this.knownFileHashSets = new ArrayList<>(knownFileHashSets);
|
||||
this.knownBadFileHashSets = new ArrayList<>(knownBadFileHashSets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areValid() {
|
||||
// RJCTODO: Verify that hash sets are present in hash db manager
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean shouldCalculateHashes() {
|
||||
return shouldCalculateHashes;
|
||||
}
|
||||
|
||||
void setShouldCalculateHashes(boolean shouldCalculateHashes) {
|
||||
this.shouldCalculateHashes = shouldCalculateHashes;
|
||||
}
|
||||
|
||||
List<HashDbManager.HashDb> getKnownFileHashSets() {
|
||||
return new ArrayList<>(knownFileHashSets);
|
||||
}
|
||||
|
||||
void setKnownFileHashSets(List<HashDbManager.HashDb> hashSets) {
|
||||
knownFileHashSets = new ArrayList<>(hashSets);
|
||||
}
|
||||
|
||||
List<HashDbManager.HashDb> getKnownBadFileHashSets() {
|
||||
return new ArrayList<>(knownBadFileHashSets);
|
||||
}
|
||||
|
||||
void setKnownBadFileHashSets(List<HashDbManager.HashDb> hashSets) {
|
||||
knownBadFileHashSets = new ArrayList<>(hashSets);
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class KeywordSearchModuleFactory extends IngestModuleFactoryAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getDefaultPerIngestJobOptions() {
|
||||
public Serializable getDefaultIngestOptions() {
|
||||
return new IngestOptions();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user