TSK-263: Be capable of searching file names of 'known files'

Also remove state tracking of KW lists from panels,
have them rely on KeywordSearchListsXML entirely
This commit is contained in:
Dick Fickling 2012-06-04 10:47:42 -04:00
parent b985d61457
commit 3abef13f6d
9 changed files with 116 additions and 276 deletions

View File

@ -50,3 +50,5 @@ ExtractedContentPanel.pageTotalLabel.text=-
ExtractedContentPanel.hitLabel.toolTipText= ExtractedContentPanel.hitLabel.toolTipText=
KeywordSearchEditListPanel.ingestMessagesCheckbox.text=Send messages during triage / ingest KeywordSearchEditListPanel.ingestMessagesCheckbox.text=Send messages during triage / ingest
KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText=Send messages during triage / ingest when hits on keyword from this list occur KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText=Send messages during triage / ingest when hits on keyword from this list occur
KeywordSearchIngestSimplePanel.skipKnownCheckBox.text=Skip files in NSRL
KeywordSearchIngestSimplePanel.skipKnownCheckBox.toolTipText=Please make sure you have either selected to run or have previously run the Hash DB Ingest Service.

View File

@ -122,7 +122,6 @@ public class KeywordSearchConfigurationPanel extends javax.swing.JPanel {
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
void save() { void save() {
editListPanel.save();
KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent();
KeywordSearchIngestService service = KeywordSearchIngestService.getDefault(); KeywordSearchIngestService service = KeywordSearchIngestService.getDefault();
if (IngestManager.getDefault().isServiceRunning(service)) { if (IngestManager.getDefault().isServiceRunning(service)) {

View File

@ -280,6 +280,9 @@
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ingestMessagesCheckboxActionPerformed"/>
</Events>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>

View File

@ -27,10 +27,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -58,11 +55,10 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
private static Logger logger = Logger.getLogger(KeywordSearchEditListPanel.class.getName()); private static Logger logger = Logger.getLogger(KeywordSearchEditListPanel.class.getName());
private KeywordTableModel tableModel; private KeywordTableModel tableModel;
private String currentKeywordList; private KeywordSearchList currentKeywordList;
private boolean ingestRunning; private boolean ingestRunning;
private boolean locked;
private static KeywordSearchEditListPanel instance = null; private static KeywordSearchEditListPanel instance = null;
/** Creates new form KeywordSearchEditListPanel */ /** Creates new form KeywordSearchEditListPanel */
@ -81,11 +77,11 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
private void customizeComponents() { private void customizeComponents() {
locked = false;
chRegex.setToolTipText("Keyword is a regular expression"); chRegex.setToolTipText("Keyword is a regular expression");
addWordButton.setToolTipText(("Add a new word to the keyword search list")); addWordButton.setToolTipText(("Add a new word to the keyword search list"));
addWordField.setToolTipText("Enter a new word or regex to search"); addWordField.setToolTipText("Enter a new word or regex to search");
saveListButton.setToolTipText("Save the current keyword list to a file"); exportButton.setToolTipText("Export the current keyword list to a file");
saveListButton.setToolTipText("Save the current keyword list with a new name");
deleteWordButton.setToolTipText("Remove selected keyword(s) from the list"); deleteWordButton.setToolTipText("Remove selected keyword(s) from the list");
//keywordTable.setAutoscrolls(true); //keywordTable.setAutoscrolls(true);
@ -115,7 +111,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
@Override @Override
public void valueChanged(ListSelectionEvent e) { public void valueChanged(ListSelectionEvent e) {
if (lsm.isSelectionEmpty() || locked) { if (lsm.isSelectionEmpty() || currentKeywordList.isLocked()) {
deleteWordButton.setEnabled(false); deleteWordButton.setEnabled(false);
} else { } else {
deleteWordButton.setEnabled(true); deleteWordButton.setEnabled(true);
@ -124,7 +120,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
//show selector if available //show selector if available
DefaultListSelectionModel selModel = (DefaultListSelectionModel) e.getSource(); DefaultListSelectionModel selModel = (DefaultListSelectionModel) e.getSource();
if (!selModel.getValueIsAdjusting()) { if (!selModel.getValueIsAdjusting()) {
List<Keyword> keywords = tableModel.getAllKeywords(); List<Keyword> keywords = currentKeywordList.getKeywords();
final int minIndex = selModel.getMinSelectionIndex(); final int minIndex = selModel.getMinSelectionIndex();
final int maxIndex = selModel.getMaxSelectionIndex(); final int maxIndex = selModel.getMaxSelectionIndex();
int selected = -1; int selected = -1;
@ -239,24 +235,29 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
// Certain buttons will be disabled if ingest is ongoing // Certain buttons will be disabled if ingest is ongoing
boolean ingestOngoing = this.ingestRunning; boolean ingestOngoing = this.ingestRunning;
// Certain buttons will be disabled if ingest is ongoing on this list // Certain buttons will be disabled if ingest is ongoing on this list
boolean inIngest = false; boolean useForIngest = !listSet ? false : currentKeywordList.getUseForIngest();
// Certain buttons will be disabled if the list shouldn't send ingest messages
boolean sendIngestMessages = !listSet ? false : currentKeywordList.getIngestMessages();
// Certain buttons will be disabled if the selected list is locked // Certain buttons will be disabled if the selected list is locked
boolean isLocked = this.locked; boolean isLocked = !listSet ? true : currentKeywordList.isLocked();
// Certain buttons will be disabled if no keywords are set // Certain buttons will be disabled if no keywords are set
boolean noKeywords = getAllKeywords().isEmpty(); boolean noKeywords = !listSet ? true : currentKeywordList.getKeywords().isEmpty();
// Certain buttons will be disabled if ingest is ongoing on this list
List<String> ingestLists = new ArrayList<String>(); List<String> ingestLists = new ArrayList<String>();
if (ingestOngoing) { if (ingestOngoing) {
ingestLists = KeywordSearchIngestService.getDefault().getKeywordLists(); ingestLists = KeywordSearchIngestService.getDefault().getKeywordLists();
} }
inIngest = ingestLists.contains(currentKeywordList); boolean inIngest = !listSet ? false : ingestLists.contains(currentKeywordList.getName());
addWordButton.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked); addWordButton.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked);
addWordField.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked); addWordField.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked);
chRegex.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked); chRegex.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked);
selectorsCombo.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked && chRegex.isSelected()); selectorsCombo.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked && chRegex.isSelected());
useForIngestCheckbox.setEnabled(listSet && (!ingestOngoing || !inIngest)); useForIngestCheckbox.setEnabled(listSet && (!ingestOngoing || !inIngest));
useForIngestCheckbox.setSelected(useForIngest);
ingestMessagesCheckbox.setEnabled(useForIngestCheckbox.isEnabled() && useForIngestCheckbox.isSelected()); ingestMessagesCheckbox.setEnabled(useForIngestCheckbox.isEnabled() && useForIngestCheckbox.isSelected());
ingestMessagesCheckbox.setSelected(sendIngestMessages);
saveListButton.setEnabled(listSet); saveListButton.setEnabled(listSet);
exportButton.setEnabled(listSet); exportButton.setEnabled(listSet);
deleteListButton.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked); deleteListButton.setEnabled(listSet && (!ingestOngoing || !inIngest) && !isLocked);
@ -398,6 +399,11 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
ingestMessagesCheckbox.setText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.ingestMessagesCheckbox.text")); // NOI18N ingestMessagesCheckbox.setText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.ingestMessagesCheckbox.text")); // NOI18N
ingestMessagesCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText")); // NOI18N ingestMessagesCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchEditListPanel.class, "KeywordSearchEditListPanel.ingestMessagesCheckbox.toolTipText")); // NOI18N
ingestMessagesCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ingestMessagesCheckboxActionPerformed(evt);
}
});
javax.swing.GroupLayout listEditorPanelLayout = new javax.swing.GroupLayout(listEditorPanel); javax.swing.GroupLayout listEditorPanelLayout = new javax.swing.GroupLayout(listEditorPanel);
listEditorPanel.setLayout(listEditorPanelLayout); listEditorPanel.setLayout(listEditorPanelLayout);
@ -500,7 +506,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
if (newWord.equals("")) { if (newWord.equals("")) {
return; return;
} else if (keywordExists(keyword)) { } else if (currentKeywordList.hasKeyword(keyword)) {
KeywordSearchUtil.displayDialog("New Keyword Entry", "Keyword already exists in the list.", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO); KeywordSearchUtil.displayDialog("New Keyword Entry", "Keyword already exists in the list.", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
return; return;
} }
@ -532,7 +538,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
final String FEATURE_NAME = "Save Keyword List"; final String FEATURE_NAME = "Save Keyword List";
KeywordSearchListsXML writer = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML writer = KeywordSearchListsXML.getCurrent();
List<Keyword> keywords = tableModel.getAllKeywords(); List<Keyword> keywords = currentKeywordList.getKeywords();
if (keywords.isEmpty()) { if (keywords.isEmpty()) {
KeywordSearchUtil.displayDialog(FEATURE_NAME, "Keyword List is empty and cannot be saved", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO); KeywordSearchUtil.displayDialog(FEATURE_NAME, "Keyword List is empty and cannot be saved", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
return; return;
@ -570,7 +576,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
writer.addList(listName, keywords); writer.addList(listName, keywords);
} }
currentKeywordList = listName; currentKeywordList = writer.getList(listName);
KeywordSearchUtil.displayDialog(FEATURE_NAME, "Keyword List <" + listName + "> saved", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO); KeywordSearchUtil.displayDialog(FEATURE_NAME, "Keyword List <" + listName + "> saved", KeywordSearchUtil.DIALOG_MESSAGE_TYPE.INFO);
}//GEN-LAST:event_saveListButtonActionPerformed }//GEN-LAST:event_saveListButtonActionPerformed
@ -585,7 +591,6 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
}//GEN-LAST:event_addWordFieldActionPerformed }//GEN-LAST:event_addWordFieldActionPerformed
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed
save();
final String FEATURE_NAME = "Keyword List Export"; final String FEATURE_NAME = "Keyword List Export";
@ -594,7 +599,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
FileNameExtensionFilter filter = new FileNameExtensionFilter( FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Keyword List XML file", EXTENSION); "Keyword List XML file", EXTENSION);
chooser.setFileFilter(filter); chooser.setFileFilter(filter);
chooser.setSelectedFile(new File(currentKeywordList)); chooser.setSelectedFile(new File(currentKeywordList.getName()));
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
int returnVal = chooser.showSaveDialog(this); int returnVal = chooser.showSaveDialog(this);
@ -623,7 +628,7 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
KeywordSearchListsXML reader = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML reader = KeywordSearchListsXML.getCurrent();
List<KeywordSearchList> toWrite = new ArrayList<KeywordSearchList>(); List<KeywordSearchList> toWrite = new ArrayList<KeywordSearchList>();
toWrite.add(reader.getList(currentKeywordList)); toWrite.add(reader.getList(currentKeywordList.getName()));
final KeywordSearchListsXML exporter = new KeywordSearchListsXML(fileAbs); final KeywordSearchListsXML exporter = new KeywordSearchListsXML(fileAbs);
boolean written = exporter.writeLists(toWrite); boolean written = exporter.writeLists(toWrite);
if (written) { if (written) {
@ -635,11 +640,11 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
private void deleteListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteListButtonActionPerformed private void deleteListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteListButtonActionPerformed
KeywordSearchListsXML deleter = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML deleter = KeywordSearchListsXML.getCurrent();
String toDelete = currentKeywordList; String toDelete = currentKeywordList.getName();
currentKeywordList = null; currentKeywordList = null;
tableModel.deleteAll();
initButtons(); initButtons();
deleter.deleteList(toDelete); deleter.deleteList(toDelete);
tableModel.resync();
}//GEN-LAST:event_deleteListButtonActionPerformed }//GEN-LAST:event_deleteListButtonActionPerformed
private void chRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chRegexActionPerformed private void chRegexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chRegexActionPerformed
@ -648,8 +653,13 @@ class KeywordSearchEditListPanel extends javax.swing.JPanel implements ListSelec
private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useForIngestCheckboxActionPerformed private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useForIngestCheckboxActionPerformed
ingestMessagesCheckbox.setEnabled(useForIngestCheckbox.isSelected()); ingestMessagesCheckbox.setEnabled(useForIngestCheckbox.isSelected());
currentKeywordList.setUseForIngest(useForIngestCheckbox.isSelected());
}//GEN-LAST:event_useForIngestCheckboxActionPerformed }//GEN-LAST:event_useForIngestCheckboxActionPerformed
private void ingestMessagesCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ingestMessagesCheckboxActionPerformed
currentKeywordList.setIngestMessages(ingestMessagesCheckbox.isSelected());
}//GEN-LAST:event_ingestMessagesCheckboxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel addKeywordPanel; private javax.swing.JPanel addKeywordPanel;
private javax.swing.JButton addWordButton; private javax.swing.JButton addWordButton;
@ -679,66 +689,23 @@ private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt)
ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource(); ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
if (!listSelectionModel.isSelectionEmpty()) { if (!listSelectionModel.isSelectionEmpty()) {
int index = listSelectionModel.getMinSelectionIndex(); int index = listSelectionModel.getMinSelectionIndex();
KeywordSearchListsManagementPanel listsPanel = KeywordSearchListsManagementPanel.getDefault();
save();
listSelectionModel.setSelectionInterval(index, index); listSelectionModel.setSelectionInterval(index, index);
currentKeywordList = listsPanel.getAllLists().get(index);
KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent();
KeywordSearchList currentList = loader.getList(currentKeywordList); currentKeywordList = loader.getListsL().get(index);
if (currentList != null) { tableModel.resync();
locked = currentList.isLocked();
}
tableModel.resync(currentKeywordList);
initButtons(); initButtons();
} else { } else {
currentKeywordList = null; currentKeywordList = null;
tableModel.deleteAll();
initButtons(); initButtons();
} }
} }
List<Keyword> getAllKeywords() {
return tableModel.getAllKeywords();
}
List<Keyword> getSelectedKeywords() {
return tableModel.getSelectedKeywords(keywordTable.getSelectedRows());
}
private boolean keywordExists(Keyword keyword) {
return tableModel.keywordExists(keyword);
}
void save() {
if (currentKeywordList != null && !currentKeywordList.equals("")) {
KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent();
KeywordSearchList oldList = loader.getList(currentKeywordList);
List<Keyword> oldKeywords = oldList.getKeywords();
boolean oldIngest = oldList.getUseForIngest();
boolean oldIngestMessages = oldList.getIngestMessages();
List<Keyword> newKeywords = getAllKeywords();
boolean newIngest = useForIngestCheckbox.isSelected();
boolean newIngestMessages = ingestMessagesCheckbox.isSelected();
if (!oldKeywords.equals(newKeywords) || oldIngest != newIngest || oldIngestMessages != newIngestMessages) {
/*boolean save = KeywordSearchUtil.displayConfirmDialog("Save List Changes",
"Do you want to save the changes you made to list " + currentKeywordList + "?",
KeywordSearchUtil.DIALOG_MESSAGE_TYPE.WARN);*/
boolean save = true;
if (save) {
loader.addList(currentKeywordList, newKeywords, newIngest, newIngestMessages, oldList.isLocked());
}
}
}
}
private class KeywordTableModel extends AbstractTableModel { private class KeywordTableModel extends AbstractTableModel {
//data //data
private Set<TableEntry> keywordData = new TreeSet<TableEntry>();
@Override @Override
public int getColumnCount() { public int getColumnCount() {
return 2; return 2;
@ -746,7 +713,7 @@ private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt)
@Override @Override
public int getRowCount() { public int getRowCount() {
return keywordData.size(); return currentKeywordList == null ? 0 : currentKeywordList.getKeywords().size();
} }
@Override @Override
@ -770,18 +737,13 @@ private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt)
@Override @Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
Object ret = null; Object ret = null;
TableEntry entry = null; Keyword word = currentKeywordList.getKeywords().get(rowIndex);
//iterate until row
Iterator<TableEntry> it = keywordData.iterator();
for (int i = 0; i <= rowIndex; ++i) {
entry = it.next();
}
switch (columnIndex) { switch (columnIndex) {
case 0: case 0:
ret = (Object) entry.keyword.getQuery(); ret = (Object) word.getQuery();
break; break;
case 1: case 1:
ret = (Object) !entry.keyword.isLiteral(); ret = (Object) !word.isLiteral();
break; break;
default: default:
logger.log(Level.SEVERE, "Invalid table column index: " + columnIndex); logger.log(Level.SEVERE, "Invalid table column index: " + columnIndex);
@ -804,95 +766,24 @@ private void useForIngestCheckboxActionPerformed(java.awt.event.ActionEvent evt)
return getValueAt(0, c).getClass(); return getValueAt(0, c).getClass();
} }
List<Keyword> getAllKeywords() {
List<Keyword> ret = new ArrayList<Keyword>();
for (TableEntry e : keywordData) {
ret.add(e.keyword);
}
return ret;
}
List<Keyword> getSelectedKeywords(int[] selected) {
List<Keyword> ret = new ArrayList<Keyword>();
Keyword[] in = keywordData.toArray(new Keyword[keywordData.size()]);
for (int i = 0; i < selected.length; i++) {
ret.add(in[selected[i]]);
}
return ret;
}
boolean keywordExists(Keyword keyword) {
List<Keyword> all = getAllKeywords();
return all.contains(keyword);
}
void addKeyword(Keyword keyword) { void addKeyword(Keyword keyword) {
if (!keywordExists(keyword)) { if(!currentKeywordList.hasKeyword(keyword)) {
keywordData.add(new TableEntry(keyword)); currentKeywordList.getKeywords().add(keyword);
} }
fireTableDataChanged(); fireTableDataChanged();
} }
void addKeywords(List<Keyword> keywords) { void resync() {
for (Keyword keyword : keywords) {
if (!keywordExists(keyword)) {
keywordData.add(new TableEntry(keyword));
}
}
fireTableDataChanged();
}
void resync(String listName) {
KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent();
KeywordSearchList list = loader.getList(listName);
List<Keyword> keywords = list.getKeywords();
deleteAll();
addKeywords(keywords);
boolean useForIngest = list.getUseForIngest();
useForIngestCheckbox.setSelected(useForIngest);
ingestMessagesCheckbox.setEnabled(useForIngest);
ingestMessagesCheckbox.setSelected(list.getIngestMessages());
}
void deleteAll() {
keywordData.clear();
fireTableDataChanged(); fireTableDataChanged();
} }
//delete selected from handle, events are fired from the handle //delete selected from handle, events are fired from the handle
void deleteSelected(int[] selected) { void deleteSelected(int[] selected) {
List<TableEntry> toDel = new ArrayList<TableEntry>(); List<Keyword> keywords = currentKeywordList.getKeywords();
TableEntry [] in = keywordData.toArray(new TableEntry[keywordData.size()]); keywords.remove(selected[0]);
for (int i = 0; i < selected.length; i++) { resync();
Keyword word = in[selected[i]].keyword;
toDel.add(new TableEntry(word));
}
for (TableEntry del : toDel) {
keywordData.remove(del);
}
fireTableDataChanged();
} }
class TableEntry implements Comparable<TableEntry> {
Keyword keyword;
TableEntry(Keyword keyword) {
this.keyword = keyword;
}
@Override
public int compareTo(TableEntry te) {
int keywords = this.keyword.getQuery().compareTo(te.keyword.getQuery());
if (keywords != 0) {
return keywords;
} else {
return Boolean.valueOf(keyword.isLiteral()).compareTo(te.keyword.isLiteral());
}
}
}
} }
private class CheckBoxRenderer extends JCheckBox implements TableCellRenderer { private class CheckBoxRenderer extends JCheckBox implements TableCellRenderer {

View File

@ -78,6 +78,7 @@ public final class KeywordSearchIngestService implements IngestServiceAbstractFi
private volatile boolean finalSearcherDone = false; private volatile boolean finalSearcherDone = false;
private final String hashDBServiceName = "Hash Lookup"; private final String hashDBServiceName = "Hash Lookup";
private SleuthkitCase caseHandle = null; private SleuthkitCase caseHandle = null;
private boolean skipKnown = false;
boolean initialized = false; boolean initialized = false;
public enum IngestStatus { public enum IngestStatus {
@ -105,7 +106,7 @@ public final class KeywordSearchIngestService implements IngestServiceAbstractFi
//if so do not index it, also postpone indexing and keyword search threads to later //if so do not index it, also postpone indexing and keyword search threads to later
IngestServiceAbstractFile.ProcessResult hashDBResult = managerProxy.getAbstractFileServiceResult(hashDBServiceName); IngestServiceAbstractFile.ProcessResult hashDBResult = managerProxy.getAbstractFileServiceResult(hashDBServiceName);
//logger.log(Level.INFO, "hashdb result: " + hashDBResult + "file: " + AbstractFile.getName()); //logger.log(Level.INFO, "hashdb result: " + hashDBResult + "file: " + AbstractFile.getName());
if (hashDBResult == IngestServiceAbstractFile.ProcessResult.COND_STOP) { if (hashDBResult == IngestServiceAbstractFile.ProcessResult.COND_STOP && skipKnown) {
return ProcessResult.OK; return ProcessResult.OK;
} else if (hashDBResult == IngestServiceAbstractFile.ProcessResult.ERROR) { } else if (hashDBResult == IngestServiceAbstractFile.ProcessResult.ERROR) {
//notify depending service that keyword search (would) encountered error for this file //notify depending service that keyword search (would) encountered error for this file
@ -275,7 +276,6 @@ public final class KeywordSearchIngestService implements IngestServiceAbstractFi
@Override @Override
public void saveAdvancedConfiguration() { public void saveAdvancedConfiguration() {
KeywordSearchConfigurationPanel.getDefault().editListPanel.save();
} }
@Override @Override
@ -760,4 +760,8 @@ public final class KeywordSearchIngestService implements IngestServiceAbstractFi
} }
return ret; return ret;
} }
void setSkipKnown(boolean skip) {
this.skipKnown = skip;
}
} }

View File

@ -21,11 +21,16 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jSeparator1" alignment="0" pref="172" max="32767" attributes="0"/> <Component id="jSeparator1" alignment="0" pref="295" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace pref="133" max="32767" attributes="0"/>
</Group>
<Component id="jSeparator2" alignment="1" pref="295" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="skipKnownCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="listsScrollPane" alignment="0" min="0" pref="0" max="32767" attributes="1"/> <Component id="listsScrollPane" alignment="0" min="0" pref="0" max="32767" attributes="1"/>
</Group> </Group>
@ -36,8 +41,13 @@
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator1" min="-2" pref="4" max="-2" attributes="0"/> <Component id="jSeparator1" min="-2" pref="4" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="listsScrollPane" pref="118" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator2" min="-2" max="-2" attributes="1"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="skipKnownCheckBox" min="-2" max="-2" attributes="1"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/> <EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="listsScrollPane" pref="33" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -80,5 +90,20 @@
</Component> </Component>
<Component class="javax.swing.JSeparator" name="jSeparator1"> <Component class="javax.swing.JSeparator" name="jSeparator1">
</Component> </Component>
<Component class="javax.swing.JSeparator" name="jSeparator2">
</Component>
<Component class="javax.swing.JCheckBox" name="skipKnownCheckBox">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchIngestSimplePanel.skipKnownCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/keywordsearch/Bundle.properties" key="KeywordSearchIngestSimplePanel.skipKnownCheckBox.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="skipKnownCheckBoxActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -81,6 +81,8 @@ public class KeywordSearchIngestSimplePanel extends javax.swing.JPanel {
listsTable = new javax.swing.JTable(); listsTable = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator(); jSeparator1 = new javax.swing.JSeparator();
jSeparator2 = new javax.swing.JSeparator();
skipKnownCheckBox = new javax.swing.JCheckBox();
setPreferredSize(new java.awt.Dimension(172, 57)); setPreferredSize(new java.awt.Dimension(172, 57));
@ -101,15 +103,27 @@ public class KeywordSearchIngestSimplePanel extends javax.swing.JPanel {
jLabel1.setText(org.openide.util.NbBundle.getMessage(KeywordSearchIngestSimplePanel.class, "KeywordSearchIngestSimplePanel.jLabel1.text")); // NOI18N jLabel1.setText(org.openide.util.NbBundle.getMessage(KeywordSearchIngestSimplePanel.class, "KeywordSearchIngestSimplePanel.jLabel1.text")); // NOI18N
skipKnownCheckBox.setText(org.openide.util.NbBundle.getMessage(KeywordSearchIngestSimplePanel.class, "KeywordSearchIngestSimplePanel.skipKnownCheckBox.text")); // NOI18N
skipKnownCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(KeywordSearchIngestSimplePanel.class, "KeywordSearchIngestSimplePanel.skipKnownCheckBox.toolTipText")); // NOI18N
skipKnownCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
skipKnownCheckBoxActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE) .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1) .addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(133, Short.MAX_VALUE))
.addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(skipKnownCheckBox)
.addContainerGap())
.addComponent(listsScrollPane, 0, 0, Short.MAX_VALUE) .addComponent(listsScrollPane, 0, 0, Short.MAX_VALUE)
); );
layout.setVerticalGroup( layout.setVerticalGroup(
@ -118,15 +132,27 @@ public class KeywordSearchIngestSimplePanel extends javax.swing.JPanel {
.addComponent(jLabel1) .addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 4, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 4, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(listsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 33, Short.MAX_VALUE)) .addComponent(listsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(skipKnownCheckBox)
.addGap(0, 0, 0))
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void skipKnownCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skipKnownCheckBoxActionPerformed
KeywordSearchIngestService.getDefault().setSkipKnown(skipKnownCheckBox.isSelected());
}//GEN-LAST:event_skipKnownCheckBoxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JScrollPane listsScrollPane; private javax.swing.JScrollPane listsScrollPane;
private javax.swing.JTable listsTable; private javax.swing.JTable listsTable;
private javax.swing.JCheckBox skipKnownCheckBox;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
private void reloadLists() { private void reloadLists() {
@ -163,6 +189,7 @@ public class KeywordSearchIngestSimplePanel extends javax.swing.JPanel {
@Override @Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
KeywordSearchList list = KeywordSearchIngestSimplePanel.this.lists.get(rowIndex); KeywordSearchList list = KeywordSearchIngestSimplePanel.this.lists.get(rowIndex);
if(columnIndex == 0){ if(columnIndex == 0){
KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML loader = KeywordSearchListsXML.getCurrent();

View File

@ -81,29 +81,6 @@ class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
listsTable.setRowSelectionAllowed(true); listsTable.setRowSelectionAllowed(true);
tableModel.resync(); tableModel.resync();
KeywordSearchListsXML.getCurrent().addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(KeywordSearchListsXML.ListsEvt.LIST_ADDED.toString())) {
tableModel.resync();
for(int i = 0; i<listsTable.getRowCount(); i++){
String name = (String) listsTable.getValueAt(i, 0);
if(((String) evt.getNewValue()).equals(name))
listsTable.getSelectionModel().setSelectionInterval(i, i);
}
} else if (evt.getPropertyName().equals(KeywordSearchListsXML.ListsEvt.LIST_DELETED.toString())) {
tableModel.resync();
if(listsTable.getRowCount() > 0)
listsTable.getSelectionModel().setSelectionInterval(0, 0);
else
listsTable.getSelectionModel().clearSelection();
} else if (evt.getPropertyName().equals(KeywordSearchListsXML.ListsEvt.LIST_UPDATED.toString())) {
tableModel.resync((String) evt.getNewValue()); //changed list name
}
}
});
} }
/** This method is called from within the constructor to /** This method is called from within the constructor to
@ -173,7 +150,6 @@ class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void newListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newListButtonActionPerformed private void newListButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newListButtonActionPerformed
KeywordSearchEditListPanel.getDefault().save();
KeywordSearchListsXML writer = KeywordSearchListsXML.getCurrent(); KeywordSearchListsXML writer = KeywordSearchListsXML.getCurrent();
String listName = (String) JOptionPane.showInputDialog(null, "New keyword list name:", "New Keyword List", JOptionPane.PLAIN_MESSAGE, null, null, ""); String listName = (String) JOptionPane.showInputDialog(null, "New keyword list name:", "New Keyword List", JOptionPane.PLAIN_MESSAGE, null, null, "");
if (listName == null || listName.trim().equals("")) { if (listName == null || listName.trim().equals("")) {
@ -199,7 +175,6 @@ class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
}//GEN-LAST:event_newListButtonActionPerformed }//GEN-LAST:event_newListButtonActionPerformed
private void importButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importButtonActionPerformed private void importButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importButtonActionPerformed
KeywordSearchEditListPanel.getDefault().save();
final String FEATURE_NAME = "Keyword List Import"; final String FEATURE_NAME = "Keyword List Import";
JFileChooser chooser = new JFileChooser(); JFileChooser chooser = new JFileChooser();
@ -280,7 +255,6 @@ class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
//data //data
private KeywordSearchListsXML listsHandle = KeywordSearchListsXML.getCurrent(); private KeywordSearchListsXML listsHandle = KeywordSearchListsXML.getCurrent();
private Set<TableEntry> listData = new TreeSet<TableEntry>();
@Override @Override
public int getColumnCount() { public int getColumnCount() {
@ -289,7 +263,7 @@ class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
@Override @Override
public int getRowCount() { public int getRowCount() {
return listData.size(); return listsHandle.getNumberLists();
} }
@Override @Override
@ -299,13 +273,7 @@ class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
@Override @Override
public Object getValueAt(int rowIndex, int columnIndex) { public Object getValueAt(int rowIndex, int columnIndex) {
TableEntry entry = null; return listsHandle.getListNames().get(rowIndex);
//iterate until row
Iterator<TableEntry> it = listData.iterator();
for (int i = 0; i <= rowIndex; ++i) {
entry = it.next();
}
return (Object) entry.name;
} }
@Override @Override
@ -323,27 +291,6 @@ class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
return getValueAt(0, c).getClass(); return getValueAt(0, c).getClass();
} }
List<String> getAllLists() {
List<String> ret = new ArrayList<String>();
for (TableEntry e : listData) {
ret.add(e.name);
}
return ret;
}
List<String> getSelectedLists(int[] selected) {
List<String> ret = new ArrayList<String>();
for(int i = 0; i < selected.length; i++){
ret.add((String) getValueAt(0, selected[i]));
}
return ret;
}
boolean listExists(String list) {
List<String> all = getAllLists();
return all.contains(list);
}
//delete selected from handle, events are fired from the handle //delete selected from handle, events are fired from the handle
void deleteSelected(int[] selected) { void deleteSelected(int[] selected) {
List<String> toDel = new ArrayList<String>(); List<String> toDel = new ArrayList<String>();
@ -353,68 +300,15 @@ class KeywordSearchListsManagementPanel extends javax.swing.JPanel {
for (String del : toDel) { for (String del : toDel) {
listsHandle.deleteList(del); listsHandle.deleteList(del);
} }
} }
//resync model from handle, then update table //resync model from handle, then update table
void resync() { void resync() {
listData.clear();
addLists(listsHandle.getListsL());
fireTableDataChanged(); fireTableDataChanged();
} }
//resync single model entry from handle
void resync(String listName) {
TableEntry found = null;
for (TableEntry e : listData) {
if (e.name.equals(listName)) {
found = e;
break;
}
}
if (found != null) {
listData.remove(found);
addList(listsHandle.getList(listName));
}
}
//add list to the model
private void addList(KeywordSearchList list) {
if (!listExists(list.getName())) {
listData.add(new TableEntry(list));
}
}
//add lists to the model
private void addLists(List<KeywordSearchList> lists) {
for (KeywordSearchList list : lists) {
if (!listExists(list.getName())) {
listData.add(new TableEntry(list));
}
}
}
//single model entry
class TableEntry implements Comparable<TableEntry> {
String name;
TableEntry(KeywordSearchList list) {
this.name = list.getName();
}
@Override
public int compareTo(TableEntry te) {
return this.name.compareTo(te.name);
}
}
} }
void addListSelectionListener(ListSelectionListener l) { void addListSelectionListener(ListSelectionListener l) {
listsTable.getSelectionModel().addListSelectionListener(l); listsTable.getSelectionModel().addListSelectionListener(l);
} }
List<String> getAllLists() {
return tableModel.getAllLists();
}
} }

View File

@ -267,12 +267,7 @@ public class KeywordSearchListsXML {
} }
boolean addList(String name, List<Keyword> newList, boolean useForIngest, boolean ingestMessages) { boolean addList(String name, List<Keyword> newList, boolean useForIngest, boolean ingestMessages) {
KeywordSearchList curList = getList(name); return addList(name, newList, useForIngest, ingestMessages, false);
if (curList == null) {
return addList(name, newList, useForIngest, ingestMessages, false);
} else {
return addList(name, newList, curList.getUseForIngest(), ingestMessages, false);
}
} }
boolean addList(String name, List<Keyword> newList) { boolean addList(String name, List<Keyword> newList) {