1903 re-implementation of isFile() check before checking membership

This commit is contained in:
William Schaefer 2017-01-31 15:00:56 -05:00
parent 816725a70b
commit 725f0905a8
2 changed files with 15 additions and 34 deletions

View File

@ -348,7 +348,7 @@ final class IngestTasksScheduler {
// Try to add the most recently added directory from the // Try to add the most recently added directory from the
// directory tasks queue to the pending file tasks queue. // directory tasks queue to the pending file tasks queue.
FileIngestTask directoryTask = this.directoryTasks.remove(this.directoryTasks.size() - 1); FileIngestTask directoryTask = this.directoryTasks.remove(this.directoryTasks.size() - 1);
if (shouldEnqueueTerminalFileTask(directoryTask)) { if (shouldEnqueueFileTask(directoryTask)) {
addToPendingFileTasksQueue(directoryTask); addToPendingFileTasksQueue(directoryTask);
} else { } else {
this.tasksInProgress.remove(directoryTask); this.tasksInProgress.remove(directoryTask);
@ -370,7 +370,7 @@ final class IngestTasksScheduler {
// first appearance of this task in the queues. // first appearance of this task in the queues.
this.tasksInProgress.add(childTask); this.tasksInProgress.add(childTask);
this.directoryTasks.add(childTask); this.directoryTasks.add(childTask);
} else if (shouldEnqueueTerminalFileTask(childTask)) { } else if (shouldEnqueueFileTask(childTask)) {
// Found a file, put the task directly into the // Found a file, put the task directly into the
// pending file tasks queue. // pending file tasks queue.
this.tasksInProgress.add(childTask); this.tasksInProgress.add(childTask);
@ -385,26 +385,6 @@ final class IngestTasksScheduler {
} }
} }
/**
* Check whether a file task with no children should be enqueued by checking
* if the file meets any of the rules of the selected file ingest filter.
*/
private static boolean shouldEnqueueTerminalFileTask(final FileIngestTask task) {
final AbstractFile file = task.getFile();
/**
* Check if the file is a member of the file ingest filter that is being
* applied to the current run of ingest, checks if unallocated space
* should be processed inside call to fileIsMemberOf
*/
if (task.getIngestJob().getFileIngestFilter().fileIsMemberOf(file) == null) {
return false;
} else {
return shouldEnqueueFileTask(task);
}
}
/** /**
* Examines the file associated with a file ingest task to determine whether * Examines the file associated with a file ingest task to determine whether
* or not the file should be processed and therefore whether or not the task * or not the file should be processed and therefore whether or not the task
@ -420,10 +400,20 @@ final class IngestTasksScheduler {
// Skip the task if the file is actually the pseudo-file for the parent // Skip the task if the file is actually the pseudo-file for the parent
// or current directory. // or current directory.
String fileName = file.getName(); String fileName = file.getName();
if (fileName.equals(".") || fileName.equals("..")) { if (fileName.equals(".") || fileName.equals("..")) {
return false; return false;
} }
/**
* Check if the file is a member of the file ingest filter that is being
* applied to the current run of ingest, checks if unallocated space
* should be processed inside call to fileIsMemberOf
*/
if (file.isFile() && task.getIngestJob().getFileIngestFilter().fileIsMemberOf(file) == null) {
return false;
}
// Skip the task if the file is one of a select group of special, large // Skip the task if the file is one of a select group of special, large
// NTFS or FAT file system files. // NTFS or FAT file system files.
if (file instanceof org.sleuthkit.datamodel.File) { if (file instanceof org.sleuthkit.datamodel.File) {

View File

@ -67,7 +67,6 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
*/ */
FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) { FilesSetRulePanel(JButton okButton, JButton cancelButton, PANEL_TYPE panelType) {
initComponents(); initComponents();
populateComponentsWithDefaultValues();
if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) { //Hide the mimetype settings when this is displaying a FileSet rule instead of a interesting item rule if (panelType == FilesSetDefsPanel.PANEL_TYPE.FILE_INGEST_FILTERS) { //Hide the mimetype settings when this is displaying a FileSet rule instead of a interesting item rule
mimeTypeComboBox.setVisible(false); mimeTypeComboBox.setVisible(false);
mimeCheck.setVisible(false); mimeCheck.setVisible(false);
@ -76,7 +75,6 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
equalitySymbolComboBox.setVisible(false); equalitySymbolComboBox.setVisible(false);
fileSizeSpinner.setVisible(false); fileSizeSpinner.setVisible(false);
jLabel1.setVisible(false); jLabel1.setVisible(false);
allRadioButton.setSelected(true); //Force selection of the all option when doing File Ingest Filter Rules
filesRadioButton.setVisible(false); filesRadioButton.setVisible(false);
dirsRadioButton.setVisible(false); dirsRadioButton.setVisible(false);
allRadioButton.setVisible(false); allRadioButton.setVisible(false);
@ -85,7 +83,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
} else { } else {
populateMimeTypesComboBox(); populateMimeTypesComboBox();
} }
populateComponentsWithDefaultValues();
this.setButtons(okButton, cancelButton); this.setButtons(okButton, cancelButton);
} }
@ -103,6 +101,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
fileSizeCheck.setVisible(false); fileSizeCheck.setVisible(false);
equalitySymbolComboBox.setVisible(false); equalitySymbolComboBox.setVisible(false);
fileSizeSpinner.setVisible(false); fileSizeSpinner.setVisible(false);
jLabel1.setVisible(false);
filesRadioButton.setVisible(false); filesRadioButton.setVisible(false);
dirsRadioButton.setVisible(false); dirsRadioButton.setVisible(false);
allRadioButton.setVisible(false); allRadioButton.setVisible(false);
@ -556,7 +555,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
private void setComponentsForSearchType() { private void setComponentsForSearchType() {
if (!this.filesRadioButton.isSelected()) { if (!this.filesRadioButton.isSelected()) {
this.fullNameRadioButton.setSelected(true); this.fullNameRadioButton.setSelected(true);
this.extensionRadioButton.setEnabled(false);
this.mimeTypeComboBox.setEnabled(false); this.mimeTypeComboBox.setEnabled(false);
this.mimeTypeComboBox.setSelectedIndex(0); this.mimeTypeComboBox.setSelectedIndex(0);
this.equalitySymbolComboBox.setEnabled(false); this.equalitySymbolComboBox.setEnabled(false);
@ -567,12 +566,6 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
this.fileSizeCheck.setSelected(false); this.fileSizeCheck.setSelected(false);
this.mimeCheck.setEnabled(false); this.mimeCheck.setEnabled(false);
this.mimeCheck.setSelected(false); this.mimeCheck.setSelected(false);
if (this.filesRadioButton.isVisible()) { //If the filesRadioButton is not visibile then we can let the user do extension based rules
this.extensionRadioButton.setEnabled(false);
} else {
this.extensionRadioButton.setEnabled(true);
}
} else { } else {
if (this.nameCheck.isSelected()) { if (this.nameCheck.isSelected()) {
this.extensionRadioButton.setEnabled(true); this.extensionRadioButton.setEnabled(true);
@ -844,8 +837,6 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
this.fullNameRadioButton.setEnabled(true); this.fullNameRadioButton.setEnabled(true);
if (this.filesRadioButton.isSelected()) { if (this.filesRadioButton.isSelected()) {
this.extensionRadioButton.setEnabled(true); this.extensionRadioButton.setEnabled(true);
} else if (!this.filesRadioButton.isVisible()) { //If the filesRadioButton is not visibile then we can let the user do extension based rules
this.extensionRadioButton.setEnabled(true);
} }
this.nameRegexCheckbox.setEnabled(true); this.nameRegexCheckbox.setEnabled(true);
} }