mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
Extracted various Keyword settings to KeywordSearchSettings.java.
KeywordSearchIngestModule.java has nothing to do with its panels, and vice versa.
This commit is contained in:
parent
7294f3ca54
commit
24b8de63b3
@ -43,14 +43,13 @@ public class KeywordSearchConfigurationPanel2 extends javax.swing.JPanel impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void activateWidgets() {
|
private void activateWidgets() {
|
||||||
final KeywordSearchIngestModule service = KeywordSearchIngestModule.getDefault();
|
skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
|
||||||
skipNSRLCheckBox.setSelected(service.getSkipKnown());
|
|
||||||
boolean enable = !IngestManager.getDefault().isIngestRunning()
|
boolean enable = !IngestManager.getDefault().isIngestRunning()
|
||||||
&& !IngestManager.getDefault().isModuleRunning(KeywordSearchIngestModule.getDefault());
|
&& !IngestManager.getDefault().isModuleRunning(KeywordSearchSettings.getDefault());
|
||||||
skipNSRLCheckBox.setEnabled(enable);
|
skipNSRLCheckBox.setEnabled(enable);
|
||||||
setTimeSettingEnabled(enable);
|
setTimeSettingEnabled(enable);
|
||||||
|
|
||||||
final UpdateFrequency curFreq = service.getUpdateFrequency();
|
final UpdateFrequency curFreq = KeywordSearchSettings.getUpdateFrequency();
|
||||||
switch (curFreq) {
|
switch (curFreq) {
|
||||||
case FAST:
|
case FAST:
|
||||||
timeRadioButton1.setSelected(true);
|
timeRadioButton1.setSelected(true);
|
||||||
@ -206,11 +205,8 @@ public class KeywordSearchConfigurationPanel2 extends javax.swing.JPanel impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void store() {
|
public void store() {
|
||||||
final KeywordSearchIngestModule km =
|
KeywordSearchSettings.setSkipKnown(skipNSRLCheckBox.isSelected());
|
||||||
KeywordSearchIngestModule.getDefault();
|
KeywordSearchSettings.setUpdateFrequency(getSelectedTimeValue());
|
||||||
|
|
||||||
km.setSkipKnown(skipNSRLCheckBox.isSelected());
|
|
||||||
km.setUpdateFrequency(getSelectedTimeValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -241,7 +237,7 @@ public class KeywordSearchConfigurationPanel2 extends javax.swing.JPanel impleme
|
|||||||
timeGroup.add(timeRadioButton2);
|
timeGroup.add(timeRadioButton2);
|
||||||
timeGroup.add(timeRadioButton3);
|
timeGroup.add(timeRadioButton3);
|
||||||
|
|
||||||
this.skipNSRLCheckBox.setSelected(KeywordSearchIngestModule.getDefault().getSkipKnown());
|
this.skipNSRLCheckBox.setSelected(KeywordSearchSettings.getSkipKnown());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
|
filesIndexedValue.setText(Integer.toString(KeywordSearch.getServer().queryNumIndexedFiles()));
|
||||||
|
@ -74,8 +74,6 @@ public class KeywordSearchConfigurationPanel3 extends javax.swing.JPanel impleme
|
|||||||
toUpdate.add(s);
|
toUpdate.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//KeywordSearchIngestModule.getDefault().setStringExtractScripts(toUpdate);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,18 +112,17 @@ public class KeywordSearchConfigurationPanel3 extends javax.swing.JPanel impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void reloadScriptsCheckBoxes() {
|
private void reloadScriptsCheckBoxes() {
|
||||||
final KeywordSearchIngestModule service = KeywordSearchIngestModule.getDefault();
|
|
||||||
|
|
||||||
boolean utf16 =
|
boolean utf16 =
|
||||||
Boolean.parseBoolean(service.getStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString()));
|
Boolean.parseBoolean(KeywordSearchSettings.getStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString()));
|
||||||
|
|
||||||
enableUTF16Checkbox.setSelected(utf16);
|
enableUTF16Checkbox.setSelected(utf16);
|
||||||
|
|
||||||
boolean utf8 =
|
boolean utf8 =
|
||||||
Boolean.parseBoolean(service.getStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString()));
|
Boolean.parseBoolean(KeywordSearchSettings.getStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString()));
|
||||||
enableUTF8Checkbox.setSelected(utf8);
|
enableUTF8Checkbox.setSelected(utf8);
|
||||||
|
|
||||||
final List<SCRIPT> serviceScripts = service.getStringExtractScripts();
|
final List<SCRIPT> serviceScripts = KeywordSearchSettings.getStringExtractScripts();
|
||||||
final int components = checkPanel.getComponentCount();
|
final int components = checkPanel.getComponentCount();
|
||||||
|
|
||||||
for (int i = 0; i < components; ++i) {
|
for (int i = 0; i < components; ++i) {
|
||||||
@ -141,20 +138,19 @@ public class KeywordSearchConfigurationPanel3 extends javax.swing.JPanel impleme
|
|||||||
private void activateWidgets() {
|
private void activateWidgets() {
|
||||||
reloadScriptsCheckBoxes();
|
reloadScriptsCheckBoxes();
|
||||||
|
|
||||||
final KeywordSearchIngestModule service = KeywordSearchIngestModule.getDefault();
|
|
||||||
|
|
||||||
boolean utf16 =
|
boolean utf16 =
|
||||||
Boolean.parseBoolean(service.getStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString()));
|
Boolean.parseBoolean(KeywordSearchSettings.getStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString()));
|
||||||
|
|
||||||
enableUTF16Checkbox.setSelected(utf16);
|
enableUTF16Checkbox.setSelected(utf16);
|
||||||
|
|
||||||
boolean utf8 =
|
boolean utf8 =
|
||||||
Boolean.parseBoolean(service.getStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString()));
|
Boolean.parseBoolean(KeywordSearchSettings.getStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString()));
|
||||||
enableUTF8Checkbox.setSelected(utf8);
|
enableUTF8Checkbox.setSelected(utf8);
|
||||||
final boolean extractEnabled = utf16 || utf8;
|
final boolean extractEnabled = utf16 || utf8;
|
||||||
|
|
||||||
boolean ingestNotRunning = !IngestManager.getDefault().isIngestRunning()
|
boolean ingestNotRunning = !IngestManager.getDefault().isIngestRunning()
|
||||||
&& ! IngestManager.getDefault().isModuleRunning(KeywordSearchIngestModule.getDefault());;
|
&& ! IngestManager.getDefault().isModuleRunning(KeywordSearchSettings.getDefault());;
|
||||||
//enable / disable checboxes
|
//enable / disable checboxes
|
||||||
activateScriptsCheckboxes(extractEnabled && ingestNotRunning);
|
activateScriptsCheckboxes(extractEnabled && ingestNotRunning);
|
||||||
enableUTF16Checkbox.setEnabled(ingestNotRunning);
|
enableUTF16Checkbox.setEnabled(ingestNotRunning);
|
||||||
@ -273,14 +269,13 @@ public class KeywordSearchConfigurationPanel3 extends javax.swing.JPanel impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void store() {
|
public void store() {
|
||||||
final KeywordSearchIngestModule service = KeywordSearchIngestModule.getDefault();
|
KeywordSearchSettings.setStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString(),
|
||||||
service.setStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString(),
|
|
||||||
Boolean.toString(enableUTF8Checkbox.isSelected()));
|
Boolean.toString(enableUTF8Checkbox.isSelected()));
|
||||||
service.setStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString(),
|
KeywordSearchSettings.setStringExtractOption(AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString(),
|
||||||
Boolean.toString(enableUTF16Checkbox.isSelected()));
|
Boolean.toString(enableUTF16Checkbox.isSelected()));
|
||||||
|
|
||||||
if(toUpdate!=null) {
|
if(toUpdate!=null) {
|
||||||
KeywordSearchIngestModule.getDefault().setStringExtractScripts(toUpdate);
|
KeywordSearchSettings.setStringExtractScripts(toUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -288,5 +283,6 @@ public class KeywordSearchConfigurationPanel3 extends javax.swing.JPanel impleme
|
|||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
activateWidgets();
|
activateWidgets();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,12 +119,10 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
|
|||||||
private volatile boolean finalSearcherDone = true; //mark as done, until it's inited
|
private volatile boolean finalSearcherDone = true; //mark as done, until it's inited
|
||||||
private final String hashDBModuleName = "Hash Lookup"; //NOTE this needs to match the HashDB module getName()
|
private final String hashDBModuleName = "Hash Lookup"; //NOTE this needs to match the HashDB module getName()
|
||||||
private SleuthkitCase caseHandle = null;
|
private SleuthkitCase caseHandle = null;
|
||||||
private boolean skipKnown = true;
|
private static List<AbstractFileExtract> textExtractors;
|
||||||
|
private static AbstractFileStringExtract stringExtractor;
|
||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
private List<AbstractFileExtract> textExtractors;
|
|
||||||
private AbstractFileStringExtract stringExtractor;
|
|
||||||
private final List<SCRIPT> stringExtractScripts = new ArrayList<SCRIPT>();
|
|
||||||
private Map<String,String> stringExtractOptions = new HashMap<String,String>();
|
|
||||||
|
|
||||||
|
|
||||||
private final GetIsFileKnownV getIsFileKnown = new GetIsFileKnownV();
|
private final GetIsFileKnownV getIsFileKnown = new GetIsFileKnownV();
|
||||||
@ -141,14 +139,15 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
|
|||||||
//set default script
|
//set default script
|
||||||
|
|
||||||
if(ModuleSettings.getConfigSetting(PROP_OPTIONS, AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString()) == null){
|
if(ModuleSettings.getConfigSetting(PROP_OPTIONS, AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString()) == null){
|
||||||
stringExtractOptions.put(AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString(), Boolean.TRUE.toString());
|
KeywordSearchSettings.stringExtractOptions.put(AbstractFileExtract.ExtractOptions.EXTRACT_UTF8.toString(), Boolean.TRUE.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
if(ModuleSettings.getConfigSetting(PROP_SCRIPTS, SCRIPT.LATIN_1.name()) == null){
|
if(ModuleSettings.getConfigSetting(PROP_SCRIPTS, SCRIPT.LATIN_1.name()) == null){
|
||||||
ModuleSettings.setConfigSetting(PROP_SCRIPTS, SCRIPT.LATIN_1.name(), Boolean.toString(true));
|
ModuleSettings.setConfigSetting(PROP_SCRIPTS, SCRIPT.LATIN_1.name(), Boolean.toString(true));
|
||||||
stringExtractScripts.add(SCRIPT.LATIN_1);
|
KeywordSearchSettings.stringExtractScripts.add(SCRIPT.LATIN_1);
|
||||||
}
|
}
|
||||||
if(ModuleSettings.getConfigSetting(PROP_OPTIONS, AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString()) == null){
|
if(ModuleSettings.getConfigSetting(PROP_OPTIONS, AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString()) == null){
|
||||||
stringExtractOptions.put(AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString(), Boolean.TRUE.toString());
|
KeywordSearchSettings.stringExtractOptions.put(AbstractFileExtract.ExtractOptions.EXTRACT_UTF16.toString(), Boolean.TRUE.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -206,7 +205,7 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
|
|||||||
//notify depending module that keyword search (would) encountered error for this file
|
//notify depending module that keyword search (would) encountered error for this file
|
||||||
return ProcessResult.ERROR;
|
return ProcessResult.ERROR;
|
||||||
}
|
}
|
||||||
else if (skipKnown && abstractFile.accept(getIsFileKnown) == true) {
|
else if (KeywordSearchSettings.getSkipKnown() && abstractFile.accept(getIsFileKnown) == true) {
|
||||||
//index meta-data only
|
//index meta-data only
|
||||||
indexer.indexFile(abstractFile, false);
|
indexer.indexFile(abstractFile, false);
|
||||||
return ProcessResult.OK;
|
return ProcessResult.OK;
|
||||||
@ -377,7 +376,7 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
|
|||||||
//Grabbing skipKnown
|
//Grabbing skipKnown
|
||||||
if(! ModuleSettings.getConfigSettings(PROP_NSRL).isEmpty()){
|
if(! ModuleSettings.getConfigSettings(PROP_NSRL).isEmpty()){
|
||||||
try{
|
try{
|
||||||
skipKnown = Boolean.parseBoolean(ModuleSettings.getConfigSetting(PROP_NSRL, "SkipKnown"));
|
KeywordSearchSettings.setSkipKnown(Boolean.parseBoolean(ModuleSettings.getConfigSetting(PROP_NSRL, "SkipKnown")));
|
||||||
}
|
}
|
||||||
catch(Exception e){
|
catch(Exception e){
|
||||||
Logger.getLogger(KeywordSearchIngestModule.class.getName()).log(Level.WARNING, "Could not parse boolean value from properties file.", e);
|
Logger.getLogger(KeywordSearchIngestModule.class.getName()).log(Level.WARNING, "Could not parse boolean value from properties file.", e);
|
||||||
@ -387,7 +386,7 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
|
|||||||
|
|
||||||
//populating stringExtractOptions
|
//populating stringExtractOptions
|
||||||
if(! ModuleSettings.getConfigSettings(PROP_OPTIONS).isEmpty()){
|
if(! ModuleSettings.getConfigSettings(PROP_OPTIONS).isEmpty()){
|
||||||
stringExtractOptions = ModuleSettings.getConfigSettings(PROP_OPTIONS);
|
KeywordSearchSettings.stringExtractOptions = ModuleSettings.getConfigSettings(PROP_OPTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
//populating stringExtractScripts
|
//populating stringExtractScripts
|
||||||
@ -395,7 +394,7 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
|
|||||||
try{
|
try{
|
||||||
for(Map.Entry<String,String> kvp: ModuleSettings.getConfigSettings(PROP_SCRIPTS).entrySet()){
|
for(Map.Entry<String,String> kvp: ModuleSettings.getConfigSettings(PROP_SCRIPTS).entrySet()){
|
||||||
if(kvp.getKey() != null && Boolean.parseBoolean(kvp.getValue())){
|
if(kvp.getKey() != null && Boolean.parseBoolean(kvp.getValue())){
|
||||||
stringExtractScripts.add(SCRIPT.valueOf(kvp.getKey()));
|
KeywordSearchSettings.stringExtractScripts.add(SCRIPT.valueOf(kvp.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,13 +406,13 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
|
|||||||
|
|
||||||
//initialize extractors
|
//initialize extractors
|
||||||
stringExtractor = new AbstractFileStringExtract();
|
stringExtractor = new AbstractFileStringExtract();
|
||||||
stringExtractor.setScripts(stringExtractScripts);
|
stringExtractor.setScripts(KeywordSearchSettings.stringExtractScripts);
|
||||||
stringExtractor.setOptions(stringExtractOptions);
|
stringExtractor.setOptions(KeywordSearchSettings.stringExtractOptions);
|
||||||
|
|
||||||
|
|
||||||
//log the scripts used for debugging
|
//log the scripts used for debugging
|
||||||
final StringBuilder sbScripts = new StringBuilder();
|
final StringBuilder sbScripts = new StringBuilder();
|
||||||
for (SCRIPT s : stringExtractScripts) {
|
for (SCRIPT s : KeywordSearchSettings.stringExtractScripts) {
|
||||||
sbScripts.append(s.name()).append(" ");
|
sbScripts.append(s.name()).append(" ");
|
||||||
}
|
}
|
||||||
logger.log(Level.INFO, "Using string extract scripts: " + sbScripts.toString());
|
logger.log(Level.INFO, "Using string extract scripts: " + sbScripts.toString());
|
||||||
@ -1152,94 +1151,4 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the skip known files setting on the module
|
|
||||||
*
|
|
||||||
* @param skip true if skip, otherwise, will process known files as well, as
|
|
||||||
* reported by HashDB module
|
|
||||||
*/
|
|
||||||
void setSkipKnown(boolean skip) {
|
|
||||||
ModuleSettings.setConfigSetting(PROP_NSRL, "SkipKnown", Boolean.toString(skip));
|
|
||||||
skipKnown = skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean getSkipKnown() {
|
|
||||||
try{
|
|
||||||
if(ModuleSettings.getConfigSetting(PROP_NSRL, "SkipKnown") != null){
|
|
||||||
skipKnown = Boolean.parseBoolean(ModuleSettings.getConfigSetting(PROP_NSRL, "SkipKnown"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception e ){
|
|
||||||
Logger.getLogger(KeywordSearchIngestModule.class.getName()).log(Level.WARNING, "Could not parse boolean value from properties file.", e);
|
|
||||||
}
|
|
||||||
return skipKnown;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the scripts to use for string extraction. Takes effect on next ingest
|
|
||||||
* start / at init(), not in effect if ingest is running
|
|
||||||
*
|
|
||||||
* @param scripts scripts to use for string extraction next time ingest
|
|
||||||
* inits and runs
|
|
||||||
*/
|
|
||||||
void setStringExtractScripts(List<SCRIPT> scripts) {
|
|
||||||
this.stringExtractScripts.clear();
|
|
||||||
this.stringExtractScripts.addAll(scripts);
|
|
||||||
|
|
||||||
for(String s : ModuleSettings.getConfigSettings(PROP_SCRIPTS).keySet()){
|
|
||||||
if (! scripts.contains(SCRIPT.valueOf(s))){
|
|
||||||
ModuleSettings.setConfigSetting(PROP_SCRIPTS, s, "false");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(SCRIPT s : stringExtractScripts){
|
|
||||||
ModuleSettings.setConfigSetting(PROP_SCRIPTS, s.name(), "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gets the currently set scripts to use
|
|
||||||
*
|
|
||||||
* @return the list of currently used script
|
|
||||||
*/
|
|
||||||
List<SCRIPT> getStringExtractScripts(){
|
|
||||||
if(ModuleSettings.getConfigSettings(PROP_SCRIPTS) != null && !ModuleSettings.getConfigSettings(PROP_SCRIPTS).isEmpty()){
|
|
||||||
List<SCRIPT> scripts = new ArrayList<SCRIPT>();
|
|
||||||
for(Map.Entry<String,String> kvp : ModuleSettings.getConfigSettings(PROP_SCRIPTS).entrySet()){
|
|
||||||
if(kvp.getValue().equals("true")){
|
|
||||||
scripts.add(SCRIPT.valueOf(kvp.getKey()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return scripts;
|
|
||||||
}
|
|
||||||
//if it failed, try to return the built-in list maintained by the singleton.
|
|
||||||
return new ArrayList<SCRIPT>(this.stringExtractScripts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set / override string extract option
|
|
||||||
* @param key option name to set
|
|
||||||
* @param val option value to set
|
|
||||||
*/
|
|
||||||
void setStringExtractOption(String key, String val) {
|
|
||||||
this.stringExtractOptions.put(key, val);
|
|
||||||
ModuleSettings.setConfigSetting(PROP_OPTIONS, key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get string extract option for the key
|
|
||||||
* @param key option name
|
|
||||||
* @return option string value, or empty string if the option is not set
|
|
||||||
*/
|
|
||||||
String getStringExtractOption(String key) {
|
|
||||||
if (ModuleSettings.getConfigSetting(PROP_OPTIONS, key) != null){
|
|
||||||
return ModuleSettings.getConfigSetting(PROP_OPTIONS, key);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return this.stringExtractOptions.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public class KeywordSearchIngestSimplePanel extends javax.swing.JPanel {
|
|||||||
|
|
||||||
private void reloadLangs() {
|
private void reloadLangs() {
|
||||||
//TODO multiple
|
//TODO multiple
|
||||||
List<SCRIPT> scripts = KeywordSearchIngestModule.getDefault().getStringExtractScripts();
|
List<SCRIPT> scripts = KeywordSearchSettings.getStringExtractScripts();
|
||||||
StringBuilder langs = new StringBuilder();
|
StringBuilder langs = new StringBuilder();
|
||||||
langs.append("<html>");
|
langs.append("<html>");
|
||||||
for (SCRIPT s : scripts) {
|
for (SCRIPT s : scripts) {
|
||||||
|
@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2012 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.keywordsearch;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.StringExtract;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.StringExtract.StringExtractUnicodeTable.SCRIPT;
|
||||||
|
import org.sleuthkit.autopsy.keywordsearch.KeywordSearchIngestModule.UpdateFrequency;
|
||||||
|
|
||||||
|
|
||||||
|
//This file contains constants and settings for KeywordSearch
|
||||||
|
public class KeywordSearchSettings {
|
||||||
|
public static final String MODULE_NAME = "KeywordSearch";
|
||||||
|
static final String PROPERTIES_OPTIONS = MODULE_NAME+"_Options";
|
||||||
|
static final String PROPERTIES_NSRL = MODULE_NAME+"_NSRL";
|
||||||
|
static final String PROPERTIES_SCRIPTS = MODULE_NAME+"_Scripts";
|
||||||
|
private static boolean skipKnown = true;
|
||||||
|
static List<StringExtract.StringExtractUnicodeTable.SCRIPT> stringExtractScripts = new ArrayList<StringExtract.StringExtractUnicodeTable.SCRIPT>();
|
||||||
|
static Map<String,String> stringExtractOptions = new HashMap<String,String>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static KeywordSearchIngestModule getDefault(){
|
||||||
|
return KeywordSearchIngestModule.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
static UpdateFrequency getUpdateFrequency(){
|
||||||
|
return KeywordSearchIngestModule.getDefault().getUpdateFrequency();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setUpdateFrequency(UpdateFrequency c){
|
||||||
|
KeywordSearchIngestModule.getDefault().setUpdateFrequency(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void setSkipKnown(boolean skip) {
|
||||||
|
ModuleSettings.setConfigSetting(PROPERTIES_NSRL, "SkipKnown", Boolean.toString(skip));
|
||||||
|
skipKnown = skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void setStringExtractScripts(List<StringExtract.StringExtractUnicodeTable.SCRIPT> scripts) {
|
||||||
|
stringExtractScripts.clear();
|
||||||
|
stringExtractScripts.addAll(scripts);
|
||||||
|
|
||||||
|
for(String s : ModuleSettings.getConfigSettings(PROPERTIES_SCRIPTS).keySet()){
|
||||||
|
if (! scripts.contains(StringExtract.StringExtractUnicodeTable.SCRIPT.valueOf(s))){
|
||||||
|
ModuleSettings.setConfigSetting(PROPERTIES_SCRIPTS, s, "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(StringExtract.StringExtractUnicodeTable.SCRIPT s : stringExtractScripts){
|
||||||
|
ModuleSettings.setConfigSetting(PROPERTIES_SCRIPTS, s.name(), "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set / override string extract option
|
||||||
|
* @param key option name to set
|
||||||
|
* @param val option value to set
|
||||||
|
*/
|
||||||
|
static void setStringExtractOption(String key, String val) {
|
||||||
|
stringExtractOptions.put(key, val);
|
||||||
|
ModuleSettings.setConfigSetting(PROPERTIES_OPTIONS, key, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the currently set scripts to use
|
||||||
|
*
|
||||||
|
* @return the list of currently used script
|
||||||
|
*/
|
||||||
|
static List<SCRIPT> getStringExtractScripts(){
|
||||||
|
if(ModuleSettings.getConfigSettings(PROPERTIES_SCRIPTS) != null && !ModuleSettings.getConfigSettings(PROPERTIES_SCRIPTS).isEmpty()){
|
||||||
|
List<SCRIPT> scripts = new ArrayList<SCRIPT>();
|
||||||
|
for(Map.Entry<String,String> kvp : ModuleSettings.getConfigSettings(PROPERTIES_SCRIPTS).entrySet()){
|
||||||
|
if(kvp.getValue().equals("true")){
|
||||||
|
scripts.add(SCRIPT.valueOf(kvp.getKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scripts;
|
||||||
|
}
|
||||||
|
//if it failed, try to return the built-in list maintained by the singleton.
|
||||||
|
return new ArrayList<SCRIPT>(stringExtractScripts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get string extract option for the key
|
||||||
|
* @param key option name
|
||||||
|
* @return option string value, or empty string if the option is not set
|
||||||
|
*/
|
||||||
|
static String getStringExtractOption(String key) {
|
||||||
|
if (ModuleSettings.getConfigSetting(PROPERTIES_OPTIONS, key) != null){
|
||||||
|
return ModuleSettings.getConfigSetting(PROPERTIES_OPTIONS, key);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return stringExtractOptions.get(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean getSkipKnown() {
|
||||||
|
try{
|
||||||
|
if(ModuleSettings.getConfigSetting(PROPERTIES_NSRL, "SkipKnown") != null){
|
||||||
|
skipKnown = Boolean.parseBoolean(ModuleSettings.getConfigSetting(PROPERTIES_NSRL, "SkipKnown"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e ){
|
||||||
|
Logger.getLogger(KeywordSearchIngestModule.class.getName()).log(Level.WARNING, "Could not parse boolean value from properties file.", e);
|
||||||
|
}
|
||||||
|
return skipKnown;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user