Merge pull request #4711 from wschaeferB/4943-TabsOrCommasForReportDelimiting

4943 tabs or commas for report delimiting
This commit is contained in:
Richard Cordovano 2019-04-12 13:25:51 -04:00 committed by GitHub
commit 0876b2e5ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 195 additions and 13 deletions

View File

@ -37,7 +37,7 @@ FileReportDataTypes.knownStatus.text=Known Status
FileReportDataTypes.perms.text=Permissions
FileReportDataTypes.path.text=Full Path
FileReportText.getName.text=Files - Text
FileReportText.getDesc.text=A tab delimited text file containing information about individual files in the case.
FileReportText.getDesc.text=A delimited text file containing information about individual files in the case.
ReportBodyFile.progress.querying=Querying files...
ReportBodyFile.ingestWarning.text=Warning, this report was run before ingest services completed\!
ReportBodyFile.progress.loading=Loading files...
@ -258,3 +258,5 @@ CreatePortableCasePanel.outputFolderTextField.text=jTextField1
CreatePortableCasePanel.chooseOutputFolderButton.text=Choose folder
CreatePortableCasePanel.jLabel1.text=Export files tagged as:
CreatePortableCasePanel.jLabel2.text=Select output folder:
ReportFileTextConfigurationPanel.tabDelimitedButton.text=Tab delimited
ReportFileTextConfigurationPanel.commaDelimitedButton.text=Comma delimited

View File

@ -85,7 +85,7 @@ FileReportDataTypes.knownStatus.text=Known Status
FileReportDataTypes.perms.text=Permissions
FileReportDataTypes.path.text=Full Path
FileReportText.getName.text=Files - Text
FileReportText.getDesc.text=A tab delimited text file containing information about individual files in the case.
FileReportText.getDesc.text=A delimited text file containing information about individual files in the case.
ReportBodyFile.progress.querying=Querying files...
ReportBodyFile.ingestWarning.text=Warning, this report was run before ingest services completed\!
ReportBodyFile.progress.loading=Loading files...
@ -306,4 +306,6 @@ CreatePortableCasePanel.outputFolderTextField.text=jTextField1
CreatePortableCasePanel.chooseOutputFolderButton.text=Choose folder
CreatePortableCasePanel.jLabel1.text=Export files tagged as:
CreatePortableCasePanel.jLabel2.text=Select output folder:
ReportFileTextConfigurationPanel.tabDelimitedButton.text=Tab delimited
ReportFileTextConfigurationPanel.commaDelimitedButton.text=Comma delimited
TableReportGenerator.StatusColumn.Header=Review Status

View File

@ -1,7 +1,7 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2013 - 2018 Basis Technology Corp.
* Copyright 2013 - 2019 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -19,6 +19,7 @@
package org.sleuthkit.autopsy.report;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
@ -27,6 +28,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import javax.swing.JPanel;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.util.NbBundle;
@ -36,18 +38,18 @@ import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.TskCoreException;
/**
* A Tab-delimited text report of the files in the case.
* A delimited text report of the files in the case.
*
* @author jwallace
*/
class FileReportText implements FileReportModule {
private static final Logger logger = Logger.getLogger(FileReportText.class.getName());
private static final String FILE_NAME = "file-report.txt"; //NON-NLS
private static FileReportText instance;
private String reportPath;
private Writer out;
private static final String FILE_NAME = "file-report.txt"; //NON-NLS
private static FileReportText instance;
private ReportFileTextConfigurationPanel configPanel;
// Get the default implementation of this report
public static synchronized FileReportText getDefault() {
@ -62,7 +64,7 @@ class FileReportText implements FileReportModule {
this.reportPath = baseReportDir + FILE_NAME;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.reportPath)));
} catch (IOException ex) {
} catch (FileNotFoundException ex) {
logger.log(Level.WARNING, "Failed to create report text file", ex); //NON-NLS
}
}
@ -85,11 +87,12 @@ class FileReportText implements FileReportModule {
}
}
private String getTabDelimitedList(List<String> list) {
StringBuilder output = new StringBuilder();
private String getDelimitedList(List<String> list, String delimiter) {
StringBuilder output;
output = new StringBuilder();
Iterator<String> it = list.iterator();
while (it.hasNext()) {
output.append(it.next()).append((it.hasNext() ? "\t" : System.lineSeparator()));
output.append('"').append(it.next()).append('"').append((it.hasNext() ? delimiter : System.lineSeparator()));
}
return output.toString();
}
@ -101,7 +104,7 @@ class FileReportText implements FileReportModule {
titles.add(col.getName());
}
try {
out.write(getTabDelimitedList(titles));
out.write(getDelimitedList(titles, configPanel.getDelimiter()));
} catch (IOException ex) {
logger.log(Level.WARNING, "Error when writing headers to report file: {0}", ex); //NON-NLS
}
@ -114,7 +117,7 @@ class FileReportText implements FileReportModule {
cells.add(type.getValue(toAdd));
}
try {
out.write(getTabDelimitedList(cells));
out.write(getDelimitedList(cells, configPanel.getDelimiter()));
} catch (IOException ex) {
logger.log(Level.WARNING, "Error when writing row to report file: {0}", ex); //NON-NLS
}
@ -143,4 +146,12 @@ class FileReportText implements FileReportModule {
public String getRelativeFilePath() {
return FILE_NAME;
}
@Override
public JPanel getConfigurationPanel() {
if (configPanel == null) {
configPanel = new ReportFileTextConfigurationPanel();
}
return configPanel;
}
}

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="delimiterGroup">
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="tabDelimitedButton" min="-2" pref="116" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="commaDelimitedButton" min="-2" pref="133" max="-2" attributes="0"/>
<EmptySpace pref="166" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="tabDelimitedButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="commaDelimitedButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="78" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JRadioButton" name="tabDelimitedButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="delimiterGroup"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportFileTextConfigurationPanel.tabDelimitedButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="commaDelimitedButton">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="delimiterGroup"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/report/Bundle.properties" key="ReportFileTextConfigurationPanel.commaDelimitedButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@ -0,0 +1,99 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2019 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.report;
/**
* Panel for configuring settings for the file text report
*/
class ReportFileTextConfigurationPanel extends javax.swing.JPanel {
private static final long serialVersionUID = 1L;
private static final String TAB_DELIMITER = "\t"; //NON-NLS
private static final String COMMA_DELIMITER = ","; //NON-NLS
/**
* Creates new form ReportFileTextConfigurationPanel
*/
ReportFileTextConfigurationPanel() {
initComponents();
}
/**
* Get the delimiter that was selected on this panel
*
* @return the selected delimiter
*/
String getDelimiter() {
if (commaDelimitedButton.isSelected()) {
return COMMA_DELIMITER;
} else {
//if the comma button is not selected default to tab since it was previously the only option
return TAB_DELIMITER;
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
delimiterGroup = new javax.swing.ButtonGroup();
tabDelimitedButton = new javax.swing.JRadioButton();
commaDelimitedButton = new javax.swing.JRadioButton();
delimiterGroup.add(tabDelimitedButton);
tabDelimitedButton.setSelected(true);
org.openide.awt.Mnemonics.setLocalizedText(tabDelimitedButton, org.openide.util.NbBundle.getMessage(ReportFileTextConfigurationPanel.class, "ReportFileTextConfigurationPanel.tabDelimitedButton.text")); // NOI18N
delimiterGroup.add(commaDelimitedButton);
org.openide.awt.Mnemonics.setLocalizedText(commaDelimitedButton, org.openide.util.NbBundle.getMessage(ReportFileTextConfigurationPanel.class, "ReportFileTextConfigurationPanel.commaDelimitedButton.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(tabDelimitedButton, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(commaDelimitedButton, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(166, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tabDelimitedButton)
.addComponent(commaDelimitedButton))
.addContainerGap(78, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton commaDelimitedButton;
private javax.swing.ButtonGroup delimiterGroup;
private javax.swing.JRadioButton tabDelimitedButton;
// End of variables declaration//GEN-END:variables
}