From 0f52eb03549b6d03ff9fd861783f7b49343cfafe Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 28 Jul 2020 10:27:00 -0400 Subject: [PATCH 01/13] use of jfreechart for files by mime type pie chart --- Core/ivy.xml | 3 +++ Core/nbproject/project.xml | 8 ++++++ .../DataSourceSummaryCountsPanel.form | 27 +++++++++++++++---- .../DataSourceSummaryCountsPanel.java | 18 ++++++++++--- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Core/ivy.xml b/Core/ivy.xml index 63fdd9ed92..4c4bef4f9a 100644 --- a/Core/ivy.xml +++ b/Core/ivy.xml @@ -50,6 +50,9 @@ + + + diff --git a/Core/nbproject/project.xml b/Core/nbproject/project.xml index 61e6a86b04..f82ab0c7af 100644 --- a/Core/nbproject/project.xml +++ b/Core/nbproject/project.xml @@ -479,6 +479,14 @@ ext/jxmapviewer2-2.4.jar release/modules/ext/jxmapviewer2-2.4.jar + + ext/jfreechart-1.0.19.jar + release/modules/ext/jfreechart-1.0.19.jar + + + ext/jcommon-1.0.23.jar + release/modules/ext/jcommon-1.0.23.jar + ext/jdom-2.0.5-contrib.jar release/modules/ext/jdom-2.0.5-contrib.jar diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form index b82bd6f3a8..7e2494bcb3 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form @@ -17,7 +17,7 @@ - + @@ -27,12 +27,16 @@ - + - + + + + + - + @@ -47,7 +51,8 @@ - + + @@ -119,5 +124,17 @@ + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java index 44a108d0aa..23bdcc4ee8 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java @@ -65,6 +65,7 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(DataSourceSummaryCountsPanel.class.getName()); private final DefaultTableCellRenderer rightAlignedRenderer = new DefaultTableCellRenderer(); + private FileTypePieChart fileTypePieChart = new FileTypePieChart(); private DataSource dataSource; @@ -78,6 +79,7 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { fileCountsByCategoryTable.getTableHeader().setReorderingAllowed(false); setDataSource(null); } + /** * The datasource currently used as the model in this panel. @@ -104,7 +106,7 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { getFileCategoryModel(dataSource), getArtifactCountsModel(dataSource)); } - + this.fileTypePieChart.setDataSource(dataSource); } /** @@ -269,6 +271,7 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { jLabel1 = new javax.swing.JLabel(); artifactCountsScrollPane = new javax.swing.JScrollPane(); artifactCountsTable = new javax.swing.JTable(); + fileTypePiePanel = fileTypePieChart; fileCountsByMimeTypeScrollPane.setViewportView(fileCountsByMimeTypeTable); @@ -283,6 +286,8 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { artifactCountsTable.setAutoCreateRowSorter(true); artifactCountsScrollPane.setViewportView(artifactCountsTable); + fileTypePiePanel.setPreferredSize(new java.awt.Dimension(298, 309)); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -299,8 +304,11 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(fileTypePiePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 424, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(18, Short.MAX_VALUE)) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {fileCountsByCategoryScrollPane, fileCountsByMimeTypeScrollPane}); @@ -315,7 +323,8 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(fileTypePiePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(fileCountsByMimeTypeScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -338,6 +347,7 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { private javax.swing.JTable fileCountsByCategoryTable; private javax.swing.JScrollPane fileCountsByMimeTypeScrollPane; private javax.swing.JTable fileCountsByMimeTypeTable; + private javax.swing.JPanel fileTypePiePanel; private javax.swing.JLabel jLabel1; // End of variables declaration//GEN-END:variables } From eced733aaf6cb483aa3dcee2362f68a2bc2875fc Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 28 Jul 2020 10:27:12 -0400 Subject: [PATCH 02/13] use of jfreechart for files by mime type pie chart --- .../datasourcesummary/FileTypePieChart.java | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java new file mode 100644 index 0000000000..130d0bf55f --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java @@ -0,0 +1,87 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.casemodule.datasourcesummary; + +import java.awt.BorderLayout; +import javax.swing.JPanel; +import org.sleuthkit.datamodel.DataSource; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.labels.PieSectionLabelGenerator; +import org.jfree.chart.labels.StandardPieSectionLabelGenerator; +import org.jfree.chart.plot.PiePlot; +import org.jfree.data.general.DefaultPieDataset; + +import java.text.DecimalFormat; +import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.coreutils.FileTypeUtils; + +/** + * + * @author gregd + */ +public class FileTypePieChart extends JPanel { + + private DataSource dataSource; + private DefaultPieDataset dataset = new DefaultPieDataset(); + + public FileTypePieChart() { + // Create chart + JFreeChart chart = ChartFactory.createPieChart( + NbBundle.getMessage(DataSourceSummaryCountsPanel.class, "DataSourceSummaryCountsPanel.byMimeTypeLabel.text"), + dataset, + true, + true, + false); + + //Format Label + PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator( + "{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); + ((PiePlot) chart.getPlot()).setLabelGenerator(labelGenerator); + + // Create Panel + ChartPanel panel = new ChartPanel(chart); + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.CENTER); + } + + DataSource getDataSource() { + return this.dataSource; + } + + void setDataSource(DataSource dataSource) { + this.dataSource = dataSource; + this.dataset.clear(); + + if (dataSource != null) { + this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_images_row(), + getCount(dataSource, FileTypeUtils.FileTypeCategory.IMAGE)); + this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_videos_row(), + getCount(dataSource, FileTypeUtils.FileTypeCategory.VIDEO)); + this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_audio_row(), + getCount(dataSource, FileTypeUtils.FileTypeCategory.AUDIO)); + this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_documents_row(), + getCount(dataSource, FileTypeUtils.FileTypeCategory.DOCUMENTS)); + this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_executables_row(), + getCount(dataSource, FileTypeUtils.FileTypeCategory.EXECUTABLE)); + } + } + + /** + * Retrieves the counts of files of a particular mime type for a particular + * DataSource. + * + * @param dataSource The DataSource. + * @param category The mime type category. + * + * @return The count. + */ + private static Long getCount(DataSource dataSource, FileTypeUtils.FileTypeCategory category) { + return DataSourceInfoUtilities.getCountOfFilesForMimeTypes(dataSource, category.getMediaTypes()); + } +} From bf2f2bc5ee731b0d4c5e9dd54dd37885d0f3fb2e Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 29 Jul 2020 09:23:11 -0400 Subject: [PATCH 03/13] some font and color improvements --- .../datasourcesummary/FileTypePieChart.java | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java index 130d0bf55f..b0e7e36fca 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java @@ -1,11 +1,25 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Autopsy Forensic Browser + * + * Copyright 2020 Basis Technology Corp. + * Contact: carrier sleuthkit 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.casemodule.datasourcesummary; import java.awt.BorderLayout; +import java.awt.Font; import javax.swing.JPanel; import org.sleuthkit.datamodel.DataSource; @@ -18,17 +32,20 @@ import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; import java.text.DecimalFormat; +import javax.swing.JLabel; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.coreutils.FileTypeUtils; /** - * - * @author gregd + * A Pie Chart that shows file mime types in a data source. */ public class FileTypePieChart extends JPanel { - + private static final Font DEFAULT_FONT = new JLabel().getFont(); + private static final Font DEFAULT_HEADER_FONT = new Font(DEFAULT_FONT.getName(), DEFAULT_FONT.getStyle(), (int) (DEFAULT_FONT.getSize() * 1.5)); + + private final DefaultPieDataset dataset = new DefaultPieDataset(); private DataSource dataSource; - private DefaultPieDataset dataset = new DefaultPieDataset(); + public FileTypePieChart() { // Create chart @@ -38,12 +55,24 @@ public class FileTypePieChart extends JPanel { true, true, false); - + + chart.setBackgroundPaint(null); + chart.getLegend().setItemFont(DEFAULT_FONT); + chart.getTitle().setFont(DEFAULT_HEADER_FONT); + + PiePlot plot = ((PiePlot) chart.getPlot()); + //Format Label PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator( "{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); - ((PiePlot) chart.getPlot()).setLabelGenerator(labelGenerator); + + plot.setLabelGenerator(labelGenerator); + plot.setLabelFont(DEFAULT_FONT); + plot.setBackgroundPaint(null); + plot.setOutlinePaint(null); + + // Create Panel ChartPanel panel = new ChartPanel(chart); this.setLayout(new BorderLayout()); From 30828f80ab2efb124c7e8a8ac397b8e2383aa10d Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 29 Jul 2020 10:07:09 -0400 Subject: [PATCH 04/13] reworking counts panel --- .../datasourcesummary/Bundle.properties | 1 - .../datasourcesummary/Bundle_ja.properties | 1 - .../DataSourceSummaryCountsPanel.form | 57 ++++-------- .../DataSourceSummaryCountsPanel.java | 91 +++---------------- .../datasourcesummary/FileTypePieChart.java | 13 ++- 5 files changed, 41 insertions(+), 122 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties index 2cb4756460..18000c0650 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties @@ -33,6 +33,5 @@ DataSourceSummaryDetailsPanel.acquisitionDetailsTextArea.text= DataSourceSummaryDetailsPanel.acquisitionDetailsLabel.text=Acquisition Details: DataSourceSummaryDetailsPanel.unallocatedSizeLabel.text=Unallocated Space: DataSourceSummaryDetailsPanel.unallocatedSizeValue.text= -DataSourceSummaryCountsPanel.byMimeTypeLabel.text=Files by MIME Type DataSourceSummaryCountsPanel.byCategoryLabel.text=Files by Category DataSourceSummaryCountsPanel.jLabel1.text=Results by Type diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties index 99fd24c7ef..b3a6b7305d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties @@ -56,7 +56,6 @@ DataSourceSummaryDetailsPanel.acquisitionDetailsTextArea.text= DataSourceSummaryDetailsPanel.acquisitionDetailsLabel.text=\u53d6\u5f97\u306e\u8a73\u7d30: DataSourceSummaryDetailsPanel.unallocatedSizeLabel.text=\u672a\u4f7f\u7528\u9818\u57df: DataSourceSummaryDetailsPanel.unallocatedSizeValue.text= -DataSourceSummaryCountsPanel.byMimeTypeLabel.text=MIME\u30bf\u30a4\u30d7\u5225\u30d5\u30a1\u30a4\u30eb DataSourceSummaryCountsPanel.byCategoryLabel.text=\u30ab\u30c6\u30b4\u30ea\u30fc\u5225\u30d5\u30a1\u30a4\u30eb DataSourceSummaryCountsPanel.jLabel1.text=\u30bf\u30a4\u30d7\u5225\u7d50\u679c DataSourceSummaryDialog.countsTab.title=\u30ab\u30a6\u30f3\u30c8 diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form index 7e2494bcb3..87d4c8e5f5 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form @@ -18,47 +18,40 @@ - - - - - + + - + - - - - - + - + - - - - - - - - - - + + + + + + + + + + + - @@ -67,24 +60,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java index 23bdcc4ee8..8d744f1123 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java @@ -75,7 +75,6 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { DataSourceSummaryCountsPanel() { rightAlignedRenderer.setHorizontalAlignment(JLabel.RIGHT); initComponents(); - fileCountsByMimeTypeTable.getTableHeader().setReorderingAllowed(false); fileCountsByCategoryTable.getTableHeader().setReorderingAllowed(false); setDataSource(null); } @@ -98,13 +97,9 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; if (dataSource == null || !Case.isCaseOpen()) { - updateCountsTableData(EMPTY_PAIRS, - EMPTY_PAIRS, - EMPTY_PAIRS); + updateCountsTableData(EMPTY_PAIRS, EMPTY_PAIRS); } else { - updateCountsTableData(getMimeTypeModel(dataSource), - getFileCategoryModel(dataSource), - getArtifactCountsModel(dataSource)); + updateCountsTableData(getFileCategoryModel(dataSource), getArtifactCountsModel(dataSource)); } this.fileTypePieChart.setDataSource(dataSource); } @@ -112,15 +107,10 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { /** * Specify the DataSource to display file information for. * - * @param mimeTypeDataModel The mime type data model. * @param fileCategoryDataModel The file category data model. * @param artifactDataModel The artifact type data model. */ - private void updateCountsTableData(Object[][] mimeTypeDataModel, Object[][] fileCategoryDataModel, Object[][] artifactDataModel) { - fileCountsByMimeTypeTable.setModel(new DefaultTableModel(mimeTypeDataModel, MIME_TYPE_COLUMN_HEADERS)); - fileCountsByMimeTypeTable.getColumnModel().getColumn(1).setCellRenderer(rightAlignedRenderer); - fileCountsByMimeTypeTable.getColumnModel().getColumn(0).setPreferredWidth(130); - + private void updateCountsTableData(Object[][] fileCategoryDataModel, Object[][] artifactDataModel) { fileCountsByCategoryTable.setModel(new DefaultTableModel(fileCategoryDataModel, FILE_BY_CATEGORY_COLUMN_HEADERS)); fileCountsByCategoryTable.getColumnModel().getColumn(1).setCellRenderer(rightAlignedRenderer); fileCountsByCategoryTable.getColumnModel().getColumn(0).setPreferredWidth(130); @@ -132,35 +122,6 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { this.repaint(); } - /** - * Determines the JTable data model for datasource mime types. - * - * @param dataSource The DataSource. - * - * @return The model to be used with a JTable. - */ - @Messages({ - "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.images.row=Images", - "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.videos.row=Videos", - "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.audio.row=Audio", - "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.documents.row=Documents", - "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.executables.row=Executables" - }) - private static Object[][] getMimeTypeModel(DataSource dataSource) { - return new Object[][]{ - new Object[]{Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_images_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.IMAGE)}, - new Object[]{Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_videos_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.VIDEO)}, - new Object[]{Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_audio_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.AUDIO)}, - new Object[]{Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_documents_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.DOCUMENTS)}, - new Object[]{Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_executables_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.EXECUTABLE)} - }; - } - /** * Retrieves the counts of files of a particular mime type for a particular * DataSource. @@ -262,9 +223,6 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { // //GEN-BEGIN:initComponents private void initComponents() { - fileCountsByMimeTypeScrollPane = new javax.swing.JScrollPane(); - fileCountsByMimeTypeTable = new javax.swing.JTable(); - byMimeTypeLabel = new javax.swing.JLabel(); fileCountsByCategoryScrollPane = new javax.swing.JScrollPane(); fileCountsByCategoryTable = new javax.swing.JTable(); byCategoryLabel = new javax.swing.JLabel(); @@ -273,10 +231,6 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { artifactCountsTable = new javax.swing.JTable(); fileTypePiePanel = fileTypePieChart; - fileCountsByMimeTypeScrollPane.setViewportView(fileCountsByMimeTypeTable); - - org.openide.awt.Mnemonics.setLocalizedText(byMimeTypeLabel, org.openide.util.NbBundle.getMessage(DataSourceSummaryCountsPanel.class, "DataSourceSummaryCountsPanel.byMimeTypeLabel.text")); // NOI18N - fileCountsByCategoryScrollPane.setViewportView(fileCountsByCategoryTable); org.openide.awt.Mnemonics.setLocalizedText(byCategoryLabel, org.openide.util.NbBundle.getMessage(DataSourceSummaryCountsPanel.class, "DataSourceSummaryCountsPanel.byCategoryLabel.text")); // NOI18N @@ -294,47 +248,35 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(fileCountsByMimeTypeScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE) - .addComponent(byMimeTypeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGap(18, 18, 18) + .addComponent(fileTypePiePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 424, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(byCategoryLabel) .addComponent(fileCountsByCategoryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createSequentialGroup() - .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(fileTypePiePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 424, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(18, Short.MAX_VALUE)) + .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(232, Short.MAX_VALUE)) ); - - layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {fileCountsByCategoryScrollPane, fileCountsByMimeTypeScrollPane}); - layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(byMimeTypeLabel) - .addComponent(byCategoryLabel) - .addComponent(jLabel1)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(fileTypePiePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(byCategoryLabel) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(fileCountsByMimeTypeScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(fileCountsByCategoryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(0, 0, Short.MAX_VALUE))) + .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(fileCountsByCategoryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))))) .addContainerGap()) ); - - layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {fileCountsByCategoryScrollPane, fileCountsByMimeTypeScrollPane}); - }// //GEN-END:initComponents @@ -342,11 +284,8 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { private javax.swing.JScrollPane artifactCountsScrollPane; private javax.swing.JTable artifactCountsTable; private javax.swing.JLabel byCategoryLabel; - private javax.swing.JLabel byMimeTypeLabel; private javax.swing.JScrollPane fileCountsByCategoryScrollPane; private javax.swing.JTable fileCountsByCategoryTable; - private javax.swing.JScrollPane fileCountsByMimeTypeScrollPane; - private javax.swing.JTable fileCountsByMimeTypeTable; private javax.swing.JPanel fileTypePiePanel; private javax.swing.JLabel jLabel1; // End of variables declaration//GEN-END:variables diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java index b0e7e36fca..6cd5d2f814 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java @@ -33,7 +33,7 @@ import org.jfree.data.general.DefaultPieDataset; import java.text.DecimalFormat; import javax.swing.JLabel; -import org.openide.util.NbBundle; +import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.coreutils.FileTypeUtils; /** @@ -46,11 +46,18 @@ public class FileTypePieChart extends JPanel { private final DefaultPieDataset dataset = new DefaultPieDataset(); private DataSource dataSource; - + @Messages({ + "DataSourceSummaryCountsPanel.byMimeTypeLabel.text=Files by MIME Type", + "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.audio.row=Audio", + "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.documents.row=Documents", + "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.executables.row=Executables", + "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.images.row=Images", + "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.videos.row=Videos" + }) public FileTypePieChart() { // Create chart JFreeChart chart = ChartFactory.createPieChart( - NbBundle.getMessage(DataSourceSummaryCountsPanel.class, "DataSourceSummaryCountsPanel.byMimeTypeLabel.text"), + Bundle.DataSourceSummaryCountsPanel_byMimeTypeLabel_text(), dataset, true, true, From 4a283add4fdaf50e8ff44c6042354f34fa8d4f12 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 29 Jul 2020 14:21:34 -0400 Subject: [PATCH 05/13] panel resize fixes --- .../datasourcesummary/Bundle.properties | 2 +- .../Bundle.properties-MERGED | 4 +- .../datasourcesummary/Bundle_ja.properties | 4 +- .../DataSourceSummaryCountsPanel.form | 266 ++++++++++++------ .../DataSourceSummaryCountsPanel.java | 135 ++++++--- .../DataSourceSummaryDialog.form | 4 +- .../DataSourceSummaryDialog.java | 4 +- 7 files changed, 286 insertions(+), 133 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties index 18000c0650..ec3f38207c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties @@ -34,4 +34,4 @@ DataSourceSummaryDetailsPanel.acquisitionDetailsLabel.text=Acquisition Details: DataSourceSummaryDetailsPanel.unallocatedSizeLabel.text=Unallocated Space: DataSourceSummaryDetailsPanel.unallocatedSizeValue.text= DataSourceSummaryCountsPanel.byCategoryLabel.text=Files by Category -DataSourceSummaryCountsPanel.jLabel1.text=Results by Type +DataSourceSummaryCountsPanel.resultsByTypeLabel.text=Results by Type diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties-MERGED index eb7affe9ee..5b1f0d5860 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle.properties-MERGED @@ -1,6 +1,7 @@ CTL_DataSourceSummaryAction=Data Source Summary DataSourceSummaryCountsPanel.ArtifactCountsTableModel.count.header=Count DataSourceSummaryCountsPanel.ArtifactCountsTableModel.type.header=Result Type +DataSourceSummaryCountsPanel.byMimeTypeLabel.text=Files by MIME Type DataSourceSummaryCountsPanel.FilesByCategoryTableModel.all.row=All DataSourceSummaryCountsPanel.FilesByCategoryTableModel.allocated.row=Allocated DataSourceSummaryCountsPanel.FilesByCategoryTableModel.count.header=Count @@ -58,9 +59,8 @@ DataSourceSummaryDetailsPanel.acquisitionDetailsTextArea.text= DataSourceSummaryDetailsPanel.acquisitionDetailsLabel.text=Acquisition Details: DataSourceSummaryDetailsPanel.unallocatedSizeLabel.text=Unallocated Space: DataSourceSummaryDetailsPanel.unallocatedSizeValue.text= -DataSourceSummaryCountsPanel.byMimeTypeLabel.text=Files by MIME Type DataSourceSummaryCountsPanel.byCategoryLabel.text=Files by Category -DataSourceSummaryCountsPanel.jLabel1.text=Results by Type +DataSourceSummaryCountsPanel.resultsByTypeLabel.text=Results by Type DataSourceSummaryDialog.countsTab.title=Counts DataSourceSummaryDialog.detailsTab.title=Details DataSourceSummaryDialog.ingestHistoryTab.title=Ingest History diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties index b3a6b7305d..41bb7e4ed8 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties @@ -56,8 +56,6 @@ DataSourceSummaryDetailsPanel.acquisitionDetailsTextArea.text= DataSourceSummaryDetailsPanel.acquisitionDetailsLabel.text=\u53d6\u5f97\u306e\u8a73\u7d30: DataSourceSummaryDetailsPanel.unallocatedSizeLabel.text=\u672a\u4f7f\u7528\u9818\u57df: DataSourceSummaryDetailsPanel.unallocatedSizeValue.text= -DataSourceSummaryCountsPanel.byCategoryLabel.text=\u30ab\u30c6\u30b4\u30ea\u30fc\u5225\u30d5\u30a1\u30a4\u30eb -DataSourceSummaryCountsPanel.jLabel1.text=\u30bf\u30a4\u30d7\u5225\u7d50\u679c DataSourceSummaryDialog.countsTab.title=\u30ab\u30a6\u30f3\u30c8 DataSourceSummaryDialog.detailsTab.title=\u8a73\u7d30 DataSourceSummaryDialog.ingestHistoryTab.title=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8\u5c65\u6b74 @@ -70,3 +68,5 @@ DataSourceSummaryNode.column.tags.header=\u30bf\u30b0 DataSourceSummaryNode.column.type.header=\u30bf\u30a4\u30d7 DataSourceSummaryNode.viewDataSourceAction.text=\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u306b\u79fb\u52d5 ViewSummaryInformationAction.name.text=\u30b5\u30de\u30ea\u30fc\u60c5\u5831\u3092\u8868\u793a +DataSourceSummaryCountsPanel.byCategoryLabel.text=\u30ab\u30c6\u30b4\u30ea\u30fc\u5225\u30d5\u30a1\u30a4\u30eb +DataSourceSummaryCountsPanel.resultsByTypeLabel.text=\u30bf\u30a4\u30d7\u5225\u7d50\u679c diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form index 87d4c8e5f5..173f05e978 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form @@ -1,6 +1,6 @@ -
+ @@ -16,100 +16,208 @@ - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - + - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java index 8d744f1123..f7e87a0533 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java @@ -25,7 +25,6 @@ import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.coreutils.FileTypeUtils; import org.sleuthkit.datamodel.DataSource; /** @@ -122,19 +121,6 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { this.repaint(); } - /** - * Retrieves the counts of files of a particular mime type for a particular - * DataSource. - * - * @param dataSource The DataSource. - * @param category The mime type category. - * - * @return The count. - */ - private static Long getCount(DataSource dataSource, FileTypeUtils.FileTypeCategory category) { - return DataSourceInfoUtilities.getCountOfFilesForMimeTypes(dataSource, category.getMediaTypes()); - } - /** * Determines the JTable data model for datasource file categories. * @@ -223,59 +209,115 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { // //GEN-BEGIN:initComponents private void initComponents() { + javax.swing.JScrollPane scrollParent = new javax.swing.JScrollPane(); + parentPanel = new javax.swing.JPanel(); fileCountsByCategoryScrollPane = new javax.swing.JScrollPane(); fileCountsByCategoryTable = new javax.swing.JTable(); byCategoryLabel = new javax.swing.JLabel(); - jLabel1 = new javax.swing.JLabel(); + resultsByTypeLabel = new javax.swing.JLabel(); artifactCountsScrollPane = new javax.swing.JScrollPane(); artifactCountsTable = new javax.swing.JTable(); fileTypePiePanel = fileTypePieChart; + filesByCatParent = new javax.swing.JPanel(); + resultsByTypeParent = new javax.swing.JPanel(); + + parentPanel.setMinimumSize(new java.awt.Dimension(840, 320)); + parentPanel.setPreferredSize(null); fileCountsByCategoryScrollPane.setViewportView(fileCountsByCategoryTable); org.openide.awt.Mnemonics.setLocalizedText(byCategoryLabel, org.openide.util.NbBundle.getMessage(DataSourceSummaryCountsPanel.class, "DataSourceSummaryCountsPanel.byCategoryLabel.text")); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(DataSourceSummaryCountsPanel.class, "DataSourceSummaryCountsPanel.jLabel1.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(resultsByTypeLabel, org.openide.util.NbBundle.getMessage(DataSourceSummaryCountsPanel.class, "DataSourceSummaryCountsPanel.resultsByTypeLabel.text")); // NOI18N artifactCountsTable.setAutoCreateRowSorter(true); artifactCountsScrollPane.setViewportView(artifactCountsTable); - fileTypePiePanel.setPreferredSize(new java.awt.Dimension(298, 309)); + fileTypePiePanel.setPreferredSize(new java.awt.Dimension(400, 300)); + + javax.swing.GroupLayout filesByCatParentLayout = new javax.swing.GroupLayout(filesByCatParent); + filesByCatParent.setLayout(filesByCatParentLayout); + filesByCatParentLayout.setHorizontalGroup( + filesByCatParentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 0, Short.MAX_VALUE) + ); + filesByCatParentLayout.setVerticalGroup( + filesByCatParentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 0, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout resultsByTypeParentLayout = new javax.swing.GroupLayout(resultsByTypeParent); + resultsByTypeParent.setLayout(resultsByTypeParentLayout); + resultsByTypeParentLayout.setHorizontalGroup( + resultsByTypeParentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 0, Short.MAX_VALUE) + ); + resultsByTypeParentLayout.setVerticalGroup( + resultsByTypeParentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 0, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout parentPanelLayout = new javax.swing.GroupLayout(parentPanel); + parentPanel.setLayout(parentPanelLayout); + parentPanelLayout.setHorizontalGroup( + parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(parentPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(fileTypePiePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(fileCountsByCategoryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(byCategoryLabel) + .addComponent(filesByCatParent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(resultsByTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(parentPanelLayout.createSequentialGroup() + .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(resultsByTypeParent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + parentPanelLayout.setVerticalGroup( + parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(parentPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(parentPanelLayout.createSequentialGroup() + .addComponent(fileTypePiePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(parentPanelLayout.createSequentialGroup() + .addGroup(parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(byCategoryLabel) + .addComponent(resultsByTypeLabel)) + .addGroup(parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, parentPanelLayout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(resultsByTypeParent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(148, 148, 148)) + .addGroup(parentPanelLayout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addGroup(parentPanelLayout.createSequentialGroup() + .addComponent(fileCountsByCategoryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(31, 31, 31) + .addComponent(filesByCatParent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()))))) + ); + + scrollParent.setViewportView(parentPanel); 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(fileTypePiePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 424, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(byCategoryLabel) - .addComponent(fileCountsByCategoryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(232, Short.MAX_VALUE)) + .addComponent(scrollParent) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(fileTypePiePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(byCategoryLabel) - .addComponent(jLabel1)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(artifactCountsScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addComponent(fileCountsByCategoryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, Short.MAX_VALUE))))) - .addContainerGap()) + .addComponent(scrollParent) ); }// //GEN-END:initComponents @@ -287,6 +329,9 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { private javax.swing.JScrollPane fileCountsByCategoryScrollPane; private javax.swing.JTable fileCountsByCategoryTable; private javax.swing.JPanel fileTypePiePanel; - private javax.swing.JLabel jLabel1; + private javax.swing.JPanel filesByCatParent; + private javax.swing.JPanel parentPanel; + private javax.swing.JLabel resultsByTypeLabel; + private javax.swing.JPanel resultsByTypeParent; // End of variables declaration//GEN-END:variables } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryDialog.form b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryDialog.form index 272fc9b041..2ee3ae314a 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryDialog.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryDialog.form @@ -22,7 +22,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryDialog.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryDialog.java index e1197fa83a..eb9e38fa28 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryDialog.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryDialog.java @@ -128,7 +128,7 @@ final class DataSourceSummaryDialog extends javax.swing.JDialog implements Obser .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE) + .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 860, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(closeButton))) @@ -138,7 +138,7 @@ final class DataSourceSummaryDialog extends javax.swing.JDialog implements Obser layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE) + .addComponent(dataSourceSummarySplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 540, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(closeButton) .addContainerGap()) From f5484846df7ae00cd48e3cb1a7525cbdbe6a7b85 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 29 Jul 2020 14:32:13 -0400 Subject: [PATCH 06/13] more commenting --- .../datasourcesummary/FileTypePieChart.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java index 6cd5d2f814..a041793ba8 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java @@ -39,13 +39,16 @@ import org.sleuthkit.autopsy.coreutils.FileTypeUtils; /** * A Pie Chart that shows file mime types in a data source. */ -public class FileTypePieChart extends JPanel { +class FileTypePieChart extends JPanel { private static final Font DEFAULT_FONT = new JLabel().getFont(); private static final Font DEFAULT_HEADER_FONT = new Font(DEFAULT_FONT.getName(), DEFAULT_FONT.getStyle(), (int) (DEFAULT_FONT.getSize() * 1.5)); private final DefaultPieDataset dataset = new DefaultPieDataset(); private DataSource dataSource; + /** + * Default constructor for the pie chart. + */ @Messages({ "DataSourceSummaryCountsPanel.byMimeTypeLabel.text=Files by MIME Type", "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.audio.row=Audio", @@ -54,7 +57,7 @@ public class FileTypePieChart extends JPanel { "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.images.row=Images", "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.videos.row=Videos" }) - public FileTypePieChart() { + FileTypePieChart() { // Create chart JFreeChart chart = ChartFactory.createPieChart( Bundle.DataSourceSummaryCountsPanel_byMimeTypeLabel_text(), @@ -86,10 +89,20 @@ public class FileTypePieChart extends JPanel { this.add(panel, BorderLayout.CENTER); } + /** + * The datasource currently used as the model with this pie chart. + * + * @return The datasource currently being used as the model in this pie chart. + */ DataSource getDataSource() { - return this.dataSource; + return dataSource; } + /** + * Sets datasource to visualize in the pie chart. + * + * @param dataSource The datasource to use in this pie chart. + */ void setDataSource(DataSource dataSource) { this.dataSource = dataSource; this.dataset.clear(); From 17d9bac6d029a6f1cc9730cdc19bc1cdb778c893 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Thu, 30 Jul 2020 12:38:01 -0400 Subject: [PATCH 07/13] updates so empty are excluded --- .../datasourcesummary/FileTypePieChart.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java index a041793ba8..9069a5abbe 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java @@ -108,16 +108,32 @@ class FileTypePieChart extends JPanel { this.dataset.clear(); if (dataSource != null) { - this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_images_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.IMAGE)); - this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_videos_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.VIDEO)); - this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_audio_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.AUDIO)); - this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_documents_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.DOCUMENTS)); - this.dataset.setValue(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_executables_row(), - getCount(dataSource, FileTypeUtils.FileTypeCategory.EXECUTABLE)); + addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_images_row(), + FileTypeUtils.FileTypeCategory.IMAGE); + addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_videos_row(), + FileTypeUtils.FileTypeCategory.VIDEO); + addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_audio_row(), + FileTypeUtils.FileTypeCategory.AUDIO); + addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_documents_row(), + FileTypeUtils.FileTypeCategory.DOCUMENTS); + addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_executables_row(), + FileTypeUtils.FileTypeCategory.EXECUTABLE); + } + } + + /** + * Adds count for file type category if there is a value. Uses fields 'dataSource' and 'dataset'. + * @param label The label for this pie slice. + * @param category The category for the pie slice. + */ + private void addIfPresent(String label, FileTypeUtils.FileTypeCategory category) { + if (this.dataSource == null) { + return; + } + + Long count = getCount(this.dataSource, category); + if (count != null && count > 0) { + this.dataset.setValue(label, count); } } From 5bed31905346f5a385f2e01ae4823bdd8d4671b9 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Fri, 31 Jul 2020 14:49:41 -0400 Subject: [PATCH 08/13] adding in other and unknown categories --- .../DataSourceInfoUtilities.java | 79 ++++++++++++++---- .../datasourcesummary/FileTypePieChart.java | 81 +++++++++++++------ 2 files changed, 121 insertions(+), 39 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java index 662f3739f0..25a3237403 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java @@ -30,6 +30,8 @@ import org.sleuthkit.datamodel.TskCoreException; import java.util.Collections; import java.util.HashMap; import java.util.Set; +import java.util.stream.Collectors; +import org.apache.commons.lang.StringUtils; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -63,7 +65,7 @@ final class DataSourceInfoUtilities { "dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue() + " AND name<>''" + " AND data_source_obj_id=" + currentDataSource.getId() - + " AND " + additionalWhere); + + (StringUtils.isBlank(additionalWhere) ? "" : (" AND " + additionalWhere))); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.WARNING, onError, ex); //unable to get count of files for the specified types cell will be displayed as empty @@ -455,21 +457,66 @@ final class DataSourceInfoUtilities { * source, null if no count was retrieved */ static Long getCountOfFilesForMimeTypes(DataSource currentDataSource, Set setOfMimeTypes) { - if (currentDataSource != null) { - try { - String inClause = String.join("', '", setOfMimeTypes); - SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); - return skCase.countFilesWhere("data_source_obj_id=" + currentDataSource.getId() - + " AND type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() - + " AND dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue() - + " AND mime_type IN ('" + inClause + "')" - + " AND name<>''"); - } catch (TskCoreException | NoCurrentCaseException ex) { - logger.log(Level.WARNING, "Unable to get count of files for specified mime types", ex); - //unable to get count of files for the specified mimetypes cell will be displayed as empty - } - } - return null; + return getCountOfFiles(currentDataSource, + " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + + " AND mime_type IN " + getSqlSet(setOfMimeTypes), + "Unable to get count of files for specified mime types"); + } + + /** + * Get the number of files in the case database for the current data source + * which do not have the specified mimetypes. + * + * @param currentDataSource the data source which we are finding a file + * count + * + * @param setOfMimeTypes the set of mime types that should be excluded. + * + * @return a Long value which represents the number of files that do not + * have the specific mime type, but do have a mime type. + */ + static Long getCountOfFilesNotInMimeTypes(DataSource currentDataSource, Set setOfMimeTypes) { + return getCountOfFiles(currentDataSource, + " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + + " AND mime_type NOT IN " + getSqlSet(setOfMimeTypes) + + " AND mime_type IS NOT NULL AND mime_type <> '' ", + "Unable to get count of files without specified mime types"); + } + + /** + * Gets the number of files in the data source with no assigned mime type. + * + * @param currentDataSource The data source. + * + * @return The number of files with no mime type or null if there is an + * issue searching the data source. + * + */ + static Long getCountOfFilesWithNoMimeType(DataSource currentDataSource) { + return getCountOfFiles(currentDataSource, + " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + + " AND (mime_type IS NULL OR mime_type = '') ", + "Unable to get count of files without a mime type"); + } + + /** + * Derives a sql set string (i.e. "('val1', 'val2', 'val3')"). A naive + * attempt is made to sanitize the strings by removing single quotes from + * values. + * + * @param setValues The values that should be present in the set. Single + * quotes are removed. + * + * @return The sql set string. + */ + private static String getSqlSet(Set setValues) { + List quotedValues = setValues + .stream() + .map(str -> String.format("'%s'", str.replace("'", ""))) + .collect(Collectors.toList()); + + String commaSeparatedQuoted = String.join(", ", quotedValues); + return String.format("(%s) ", commaSeparatedQuoted); } /** diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java index 9069a5abbe..37b1ddceec 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java @@ -32,20 +32,36 @@ import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; import java.text.DecimalFormat; +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; import javax.swing.JLabel; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.coreutils.FileTypeUtils; +import static org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory; /** * A Pie Chart that shows file mime types in a data source. */ class FileTypePieChart extends JPanel { - private static final Font DEFAULT_FONT = new JLabel().getFont(); + + private static final Font DEFAULT_FONT = new JLabel().getFont(); private static final Font DEFAULT_HEADER_FONT = new Font(DEFAULT_FONT.getName(), DEFAULT_FONT.getStyle(), (int) (DEFAULT_FONT.getSize() * 1.5)); - + private final DefaultPieDataset dataset = new DefaultPieDataset(); private DataSource dataSource; + // used for determining mime types that fall in the 'other' category + private static final Set ALL_CATEGORY_MIME_TYPES = Arrays.asList( + FileTypeCategory.IMAGE, + FileTypeCategory.VIDEO, + FileTypeCategory.AUDIO, + FileTypeCategory.DOCUMENTS, + FileTypeCategory.EXECUTABLE) + .stream() + .flatMap((cat) -> cat.getMediaTypes().stream()) + .collect(Collectors.toSet()); + /** * Default constructor for the pie chart. */ @@ -55,7 +71,9 @@ class FileTypePieChart extends JPanel { "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.documents.row=Documents", "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.executables.row=Executables", "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.images.row=Images", - "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.videos.row=Videos" + "DataSourceSummaryCountsPanel.FilesByMimeTypeTableModel.videos.row=Videos", + "DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_other_label=Other", + "DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_notAnalyzed_label=Not Analyzed" }) FileTypePieChart() { // Create chart @@ -65,24 +83,23 @@ class FileTypePieChart extends JPanel { true, true, false); - + chart.setBackgroundPaint(null); chart.getLegend().setItemFont(DEFAULT_FONT); chart.getTitle().setFont(DEFAULT_HEADER_FONT); - + PiePlot plot = ((PiePlot) chart.getPlot()); - + //Format Label PieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator( "{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); - + plot.setLabelGenerator(labelGenerator); plot.setLabelFont(DEFAULT_FONT); plot.setBackgroundPaint(null); plot.setOutlinePaint(null); - // Create Panel ChartPanel panel = new ChartPanel(chart); this.setLayout(new BorderLayout()); @@ -92,7 +109,8 @@ class FileTypePieChart extends JPanel { /** * The datasource currently used as the model with this pie chart. * - * @return The datasource currently being used as the model in this pie chart. + * @return The datasource currently being used as the model in this pie + * chart. */ DataSource getDataSource() { return dataSource; @@ -109,29 +127,46 @@ class FileTypePieChart extends JPanel { if (dataSource != null) { addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_images_row(), - FileTypeUtils.FileTypeCategory.IMAGE); - addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_videos_row(), - FileTypeUtils.FileTypeCategory.VIDEO); + this.dataSource, FileTypeCategory.IMAGE); + addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_videos_row(), + this.dataSource, FileTypeCategory.VIDEO); addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_audio_row(), - FileTypeUtils.FileTypeCategory.AUDIO); + this.dataSource, FileTypeCategory.AUDIO); addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_documents_row(), - FileTypeUtils.FileTypeCategory.DOCUMENTS); + this.dataSource, FileTypeCategory.DOCUMENTS); addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_executables_row(), - FileTypeUtils.FileTypeCategory.EXECUTABLE); + this.dataSource, FileTypeCategory.EXECUTABLE); + addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_other_label(), + DataSourceInfoUtilities.getCountOfFilesNotInMimeTypes(this.dataSource, ALL_CATEGORY_MIME_TYPES)); + addIfPresent(Bundle.DataSourceSummaryCountsPanel_FilesByMimeTypeTableModel_notAnalyzed_label(), + DataSourceInfoUtilities.getCountOfFilesWithNoMimeType(this.dataSource)); } } - + /** - * Adds count for file type category if there is a value. Uses fields 'dataSource' and 'dataset'. - * @param label The label for this pie slice. - * @param category The category for the pie slice. + * Adds count for file type category if there is a value. Uses fields + * 'dataSource' and 'dataset'. + * + * @param label The label for this pie slice. + * @param dataSource The data source. + * @param category The category for the pie slice. */ - private void addIfPresent(String label, FileTypeUtils.FileTypeCategory category) { - if (this.dataSource == null) { + private void addIfPresent(String label, DataSource dataSource, FileTypeUtils.FileTypeCategory category) { + if (dataSource == null) { return; } - - Long count = getCount(this.dataSource, category); + + Long count = getCount(dataSource, category); + addIfPresent(label, count); + } + + /** + * Adds count for a a label if the count is non-null and greater than 0. + * + * @param label The label. + * @param count The count. + */ + private void addIfPresent(String label, Long count) { if (count != null && count > 0) { this.dataset.setValue(label, count); } From a67e5e1e7f1dcf675c986bb5f77ec08525aa52d5 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Mon, 3 Aug 2020 15:22:16 -0400 Subject: [PATCH 09/13] beginning of changing DataSourceInfoUtilities --- .../DataSourceInfoUtilities.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java index 25a3237403..c1ff519e3e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java @@ -38,6 +38,7 @@ import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.DataSource; +import org.sleuthkit.datamodel.TskData.TSK_FS_META_TYPE_ENUM; /** * Utilities for getting information about a data source or all data sources @@ -48,7 +49,7 @@ final class DataSourceInfoUtilities { private static final Logger logger = Logger.getLogger(DataSourceInfoUtilities.class.getName()); /** - * Gets a count of files for a particular datasource where it is not a + * Gets a count of tsk_files for a particular datasource where it is not a * virtual directory and has a name. * * @param currentDataSource The datasource. @@ -57,7 +58,7 @@ final class DataSourceInfoUtilities { * * @return The count of files or null on error. */ - private static Long getCountOfFiles(DataSource currentDataSource, String additionalWhere, String onError) { + private static Long getCountOfTskFiles(DataSource currentDataSource, String additionalWhere, String onError) { if (currentDataSource != null) { try { SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); @@ -73,6 +74,15 @@ final class DataSourceInfoUtilities { } return null; } + + private static Long getCountOfRegularFiles(DataSource currentDataSource, String additionalWhere, String onError) { + String whereClause = "meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue(); + if (StringUtils.isNotBlank(additionalWhere)) { + whereClause += " AND " + additionalWhere; + } + + return getCountOfTskFiles(currentDataSource, whereClause, onError); + } /** * Get count of files in a data source. @@ -82,7 +92,7 @@ final class DataSourceInfoUtilities { * @return The count. */ static Long getCountOfFiles(DataSource currentDataSource) { - return getCountOfFiles(currentDataSource, + return getCountOfRegularFiles(currentDataSource, "type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType(), "Unable to get count of files, providing empty results"); } @@ -95,7 +105,7 @@ final class DataSourceInfoUtilities { * @return The count. */ static Long getCountOfUnallocatedFiles(DataSource currentDataSource) { - return getCountOfFiles(currentDataSource, + return getCountOfRegularFiles(currentDataSource, "type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + " AND dir_flags=" + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue(), "Unable to get counts of unallocated files for datasource, providing empty results"); @@ -109,7 +119,7 @@ final class DataSourceInfoUtilities { * @return The count. */ static Long getCountOfDirectories(DataSource currentDataSource) { - return getCountOfFiles(currentDataSource, + return getCountOfTskFiles(currentDataSource, "type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + " AND meta_type=" + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue(), "Unable to get count of directories for datasource, providing empty results"); @@ -123,7 +133,7 @@ final class DataSourceInfoUtilities { * @return The count. */ static Long getCountOfSlackFiles(DataSource currentDataSource) { - return getCountOfFiles(currentDataSource, + return getCountOfTskFiles(currentDataSource, "type=" + TskData.TSK_DB_FILES_TYPE_ENUM.SLACK.getFileType(), "Unable to get count of slack files for datasources, providing empty results"); } @@ -383,6 +393,7 @@ final class DataSourceInfoUtilities { try { final String countFilesQuery = "data_source_obj_id, COUNT(*) AS value" + " FROM tsk_files WHERE type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + + "AND meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + " AND dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue() + " AND name<>'' GROUP BY data_source_obj_id"; //NON-NLS return getValuesMap(countFilesQuery); @@ -457,7 +468,7 @@ final class DataSourceInfoUtilities { * source, null if no count was retrieved */ static Long getCountOfFilesForMimeTypes(DataSource currentDataSource, Set setOfMimeTypes) { - return getCountOfFiles(currentDataSource, + return getCountOfTskFiles(currentDataSource, " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + " AND mime_type IN " + getSqlSet(setOfMimeTypes), "Unable to get count of files for specified mime types"); @@ -476,7 +487,7 @@ final class DataSourceInfoUtilities { * have the specific mime type, but do have a mime type. */ static Long getCountOfFilesNotInMimeTypes(DataSource currentDataSource, Set setOfMimeTypes) { - return getCountOfFiles(currentDataSource, + return getCountOfTskFiles(currentDataSource, " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + " AND mime_type NOT IN " + getSqlSet(setOfMimeTypes) + " AND mime_type IS NOT NULL AND mime_type <> '' ", @@ -493,7 +504,7 @@ final class DataSourceInfoUtilities { * */ static Long getCountOfFilesWithNoMimeType(DataSource currentDataSource) { - return getCountOfFiles(currentDataSource, + return getCountOfTskFiles(currentDataSource, " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + " AND (mime_type IS NULL OR mime_type = '') ", "Unable to get count of files without a mime type"); From d0f720f8d85da32b97495947f76adc4888eb914e Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Mon, 3 Aug 2020 16:37:19 -0400 Subject: [PATCH 10/13] data source info utilities updates --- .../DataSourceInfoUtilities.java | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java index c1ff519e3e..7d1403ae1d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java @@ -49,8 +49,8 @@ final class DataSourceInfoUtilities { private static final Logger logger = Logger.getLogger(DataSourceInfoUtilities.class.getName()); /** - * Gets a count of tsk_files for a particular datasource where it is not a - * virtual directory and has a name. + * Gets a count of tsk_files for a particular datasource where dir_type is + * not a virtual directory and has a name. * * @param currentDataSource The datasource. * @param additionalWhere Additional sql where clauses. @@ -74,26 +74,37 @@ final class DataSourceInfoUtilities { } return null; } - + + /** + * Gets a count of regular files for a particular datasource where the + * dir_type and type are not a virtual directory and has a name. + * + * @param currentDataSource The datasource. + * @param additionalWhere Additional sql where clauses. + * @param onError The message to log on error. + * + * @return The count of files or null on error. + */ private static Long getCountOfRegularFiles(DataSource currentDataSource, String additionalWhere, String onError) { - String whereClause = "meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue(); + String whereClause = "meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + + " AND type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType(); + if (StringUtils.isNotBlank(additionalWhere)) { whereClause += " AND " + additionalWhere; } - + return getCountOfTskFiles(currentDataSource, whereClause, onError); } /** - * Get count of files in a data source. + * Get count of regular files (not directories) in a data source. * * @param currentDataSource The data source. * * @return The count. */ static Long getCountOfFiles(DataSource currentDataSource) { - return getCountOfRegularFiles(currentDataSource, - "type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType(), + return getCountOfRegularFiles(currentDataSource, null, "Unable to get count of files, providing empty results"); } @@ -106,8 +117,7 @@ final class DataSourceInfoUtilities { */ static Long getCountOfUnallocatedFiles(DataSource currentDataSource) { return getCountOfRegularFiles(currentDataSource, - "type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() - + " AND dir_flags=" + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue(), + "dir_flags=" + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue(), "Unable to get counts of unallocated files for datasource, providing empty results"); } @@ -393,7 +403,7 @@ final class DataSourceInfoUtilities { try { final String countFilesQuery = "data_source_obj_id, COUNT(*) AS value" + " FROM tsk_files WHERE type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() - + "AND meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + + "AND meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + " AND dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue() + " AND name<>'' GROUP BY data_source_obj_id"; //NON-NLS return getValuesMap(countFilesQuery); @@ -468,9 +478,8 @@ final class DataSourceInfoUtilities { * source, null if no count was retrieved */ static Long getCountOfFilesForMimeTypes(DataSource currentDataSource, Set setOfMimeTypes) { - return getCountOfTskFiles(currentDataSource, - " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() - + " AND mime_type IN " + getSqlSet(setOfMimeTypes), + return getCountOfRegularFiles(currentDataSource, + "mime_type IN " + getSqlSet(setOfMimeTypes), "Unable to get count of files for specified mime types"); } @@ -487,9 +496,8 @@ final class DataSourceInfoUtilities { * have the specific mime type, but do have a mime type. */ static Long getCountOfFilesNotInMimeTypes(DataSource currentDataSource, Set setOfMimeTypes) { - return getCountOfTskFiles(currentDataSource, - " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() - + " AND mime_type NOT IN " + getSqlSet(setOfMimeTypes) + return getCountOfRegularFiles(currentDataSource, + "mime_type NOT IN " + getSqlSet(setOfMimeTypes) + " AND mime_type IS NOT NULL AND mime_type <> '' ", "Unable to get count of files without specified mime types"); } @@ -504,9 +512,8 @@ final class DataSourceInfoUtilities { * */ static Long getCountOfFilesWithNoMimeType(DataSource currentDataSource) { - return getCountOfTskFiles(currentDataSource, - " type <> " + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() - + " AND (mime_type IS NULL OR mime_type = '') ", + return getCountOfRegularFiles(currentDataSource, + "(mime_type IS NULL OR mime_type = '') ", "Unable to get count of files without a mime type"); } From ed4cb22bacd8cb0a79f0e16e12e59fb6e1516d19 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 5 Aug 2020 15:40:38 -0400 Subject: [PATCH 11/13] worked through queries --- .../DataSourceInfoUtilities.java | 60 ++++++++++++++----- .../DataSourceSummaryCountsPanel.form | 3 - .../DataSourceSummaryCountsPanel.java | 21 +------ 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java index 0ecd7b11e3..6ad6b7cd5e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceInfoUtilities.java @@ -37,6 +37,8 @@ import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.DataSource; +import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM; +import org.sleuthkit.datamodel.TskData.TSK_FS_META_FLAG_ENUM; import org.sleuthkit.datamodel.TskData.TSK_FS_META_TYPE_ENUM; /** @@ -62,9 +64,9 @@ final class DataSourceInfoUtilities { try { SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase(); return skCase.countFilesWhere( - "dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue() + "data_source_obj_id=" + currentDataSource.getId() + + " AND dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue() + " AND name<>''" - + " AND data_source_obj_id=" + currentDataSource.getId() + (StringUtils.isBlank(additionalWhere) ? "" : (" AND " + additionalWhere))); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.WARNING, onError, ex); @@ -87,7 +89,7 @@ final class DataSourceInfoUtilities { private static Long getCountOfRegularFiles(DataSource currentDataSource, String additionalWhere, String onError) { String whereClause = "meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + " AND type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType(); - + if (StringUtils.isNotBlank(additionalWhere)) { whereClause += " AND " + additionalWhere; } @@ -107,6 +109,19 @@ final class DataSourceInfoUtilities { "Unable to get count of files, providing empty results"); } + /** + * Get count of allocated files in a data source. + * + * @param currentDataSource The data source. + * + * @return The count. + */ + static Long getCountOfAllocatedFiles(DataSource currentDataSource) { + return getCountOfRegularFiles(currentDataSource, + getMetaFlagsContainsStatement(TSK_FS_META_FLAG_ENUM.ALLOC), + "Unable to get counts of unallocated files for datasource, providing empty results"); + } + /** * Get count of unallocated files in a data source. * @@ -116,7 +131,8 @@ final class DataSourceInfoUtilities { */ static Long getCountOfUnallocatedFiles(DataSource currentDataSource) { return getCountOfRegularFiles(currentDataSource, - "dir_flags=" + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue(), + getMetaFlagsContainsStatement(TSK_FS_META_FLAG_ENUM.UNALLOC) + + " AND type<>" + TSK_DB_FILES_TYPE_ENUM.SLACK.getFileType(), "Unable to get counts of unallocated files for datasource, providing empty results"); } @@ -129,8 +145,8 @@ final class DataSourceInfoUtilities { */ static Long getCountOfDirectories(DataSource currentDataSource) { return getCountOfTskFiles(currentDataSource, - "type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() - + " AND meta_type=" + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue(), + "meta_type=" + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_DIR.getValue() + + " AND type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType(), "Unable to get count of directories for datasource, providing empty results"); } @@ -142,8 +158,9 @@ final class DataSourceInfoUtilities { * @return The count. */ static Long getCountOfSlackFiles(DataSource currentDataSource) { - return getCountOfTskFiles(currentDataSource, - "type=" + TskData.TSK_DB_FILES_TYPE_ENUM.SLACK.getFileType(), + return getCountOfRegularFiles(currentDataSource, + getMetaFlagsContainsStatement(TSK_FS_META_FLAG_ENUM.UNALLOC) + + " AND type=" + TskData.TSK_DB_FILES_TYPE_ENUM.SLACK.getFileType(), "Unable to get count of slack files for datasources, providing empty results"); } @@ -195,9 +212,11 @@ final class DataSourceInfoUtilities { final String valueParam = "value"; final String countParam = "count"; String query = "SELECT SUM(size) AS " + valueParam + ", COUNT(*) AS " + countParam - + " FROM tsk_files WHERE type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + + " FROM tsk_files" + + " WHERE " + getMetaFlagsContainsStatement(TSK_FS_META_FLAG_ENUM.UNALLOC) + + " AND type<>" + TSK_DB_FILES_TYPE_ENUM.SLACK.getFileType() + + " AND type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + " AND dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue() - + " AND dir_flags=" + TskData.TSK_FS_NAME_FLAG_ENUM.UNALLOC.getValue() + " AND name<>''" + " AND data_source_obj_id=" + currentDataSource.getId(); @@ -400,11 +419,12 @@ final class DataSourceInfoUtilities { */ static Map getCountsOfFiles() { try { - final String countFilesQuery = "data_source_obj_id, COUNT(*) AS value" - + " FROM tsk_files WHERE type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() - + "AND meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + final String countFilesQuery = "data_source_obj_id, COUNT(*) AS value FROM tsk_files" + + " WHERE meta_type=" + TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue() + + " AND type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType() + " AND dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue() - + " AND name<>'' GROUP BY data_source_obj_id"; //NON-NLS + + " AND name<>''" + + " GROUP BY data_source_obj_id"; //NON-NLS return getValuesMap(countFilesQuery); } catch (TskCoreException | NoCurrentCaseException ex) { logger.log(Level.WARNING, "Unable to get counts of files for all datasources, providing empty results", ex); @@ -536,6 +556,18 @@ final class DataSourceInfoUtilities { return String.format("(%s) ", commaSeparatedQuoted); } + /** + * Creates sql where clause that does a bitwise check to see if flag is + * present. + * + * @param flag The flag for which to check. + * + * @return The clause. + */ + private static String getMetaFlagsContainsStatement(TSK_FS_META_FLAG_ENUM flag) { + return "meta_flags & " + flag.getValue() + " > 0"; + } + /** * Helper method to execute a select query with a * DataSourceSingleValueCallback. diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form index 173f05e978..4b523f1b68 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form @@ -39,9 +39,6 @@ - - - diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java index f9c18d2ed7..9068c3afe1 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java @@ -77,7 +77,6 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { artifactCountsTable.getTableHeader().setReorderingAllowed(false); setDataSource(null); } - /** * The datasource currently used as the model in this panel. @@ -138,7 +137,7 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { private static Object[][] getFileCategoryModel(DataSource selectedDataSource) { Long fileCount = zeroIfNull(DataSourceInfoUtilities.getCountOfFiles(selectedDataSource)); Long unallocatedFiles = zeroIfNull(DataSourceInfoUtilities.getCountOfUnallocatedFiles(selectedDataSource)); - Long allocatedFiles = zeroIfNull(getAllocatedCount(fileCount, unallocatedFiles)); + Long allocatedFiles = zeroIfNull(DataSourceInfoUtilities.getCountOfAllocatedFiles(selectedDataSource)); Long slackFiles = zeroIfNull(DataSourceInfoUtilities.getCountOfSlackFiles(selectedDataSource)); Long directories = zeroIfNull(DataSourceInfoUtilities.getCountOfDirectories(selectedDataSource)); @@ -162,24 +161,6 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { return origValue == null ? 0 : origValue; } - /** - * Safely gets the allocated files count. - * - * @param allFilesCount The count of all files. - * @param unallocatedFilesCount The count of unallocated files. - * - * @return The count of allocated files. - */ - private static long getAllocatedCount(Long allFilesCount, Long unallocatedFilesCount) { - if (allFilesCount == null) { - return 0; - } else if (unallocatedFilesCount == null) { - return allFilesCount; - } else { - return allFilesCount - unallocatedFilesCount; - } - } - /** * The counts of different artifact types found in a DataSource. * From c3c1446d11ce6be71804023d8cb75bb92898c88d Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Wed, 5 Aug 2020 16:01:10 -0400 Subject: [PATCH 12/13] codacy fixes --- .../DataSourceSummaryCountsPanel.form | 2 ++ .../DataSourceSummaryCountsPanel.java | 33 ++++++++----------- .../datasourcesummary/FileTypePieChart.java | 3 +- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form index 4b523f1b68..f922bf9288 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.form @@ -170,6 +170,8 @@ + + diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java index 9068c3afe1..1c3e93c47c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/DataSourceSummaryCountsPanel.java @@ -38,7 +38,8 @@ import org.sleuthkit.datamodel.DataSource; "DataSourceSummaryCountsPanel.FilesByCategoryTableModel.count.header=Count" }) class DataSourceSummaryCountsPanel extends javax.swing.JPanel { - + private static final long serialVersionUID = 1L; + // Result returned for a data model if no data found. private static final Object[][] EMPTY_PAIRS = new Object[][]{}; @@ -60,10 +61,10 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { Bundle.DataSourceSummaryCountsPanel_ArtifactCountsTableModel_count_header() }; - private static final long serialVersionUID = 1L; private static final Logger logger = Logger.getLogger(DataSourceSummaryCountsPanel.class.getName()); private final DefaultTableCellRenderer rightAlignedRenderer = new DefaultTableCellRenderer(); - private FileTypePieChart fileTypePieChart = new FileTypePieChart(); + + private final FileTypePieChart fileTypePieChart = new FileTypePieChart(); private DataSource dataSource; @@ -191,19 +192,18 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { private void initComponents() { javax.swing.JScrollPane scrollParent = new javax.swing.JScrollPane(); - parentPanel = new javax.swing.JPanel(); - fileCountsByCategoryScrollPane = new javax.swing.JScrollPane(); + javax.swing.JPanel parentPanel = new javax.swing.JPanel(); + javax.swing.JScrollPane fileCountsByCategoryScrollPane = new javax.swing.JScrollPane(); fileCountsByCategoryTable = new javax.swing.JTable(); - byCategoryLabel = new javax.swing.JLabel(); - resultsByTypeLabel = new javax.swing.JLabel(); - artifactCountsScrollPane = new javax.swing.JScrollPane(); + javax.swing.JLabel byCategoryLabel = new javax.swing.JLabel(); + javax.swing.JLabel resultsByTypeLabel = new javax.swing.JLabel(); + javax.swing.JScrollPane artifactCountsScrollPane = new javax.swing.JScrollPane(); artifactCountsTable = new javax.swing.JTable(); - fileTypePiePanel = fileTypePieChart; - filesByCatParent = new javax.swing.JPanel(); - resultsByTypeParent = new javax.swing.JPanel(); + javax.swing.JPanel fileTypePiePanel = fileTypePieChart; + javax.swing.JPanel filesByCatParent = new javax.swing.JPanel(); + javax.swing.JPanel resultsByTypeParent = new javax.swing.JPanel(); parentPanel.setMinimumSize(new java.awt.Dimension(840, 320)); - parentPanel.setPreferredSize(null); fileCountsByCategoryScrollPane.setViewportView(fileCountsByCategoryTable); @@ -211,6 +211,7 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { org.openide.awt.Mnemonics.setLocalizedText(resultsByTypeLabel, org.openide.util.NbBundle.getMessage(DataSourceSummaryCountsPanel.class, "DataSourceSummaryCountsPanel.resultsByTypeLabel.text")); // NOI18N + artifactCountsTable.setAutoCreateRowSorter(true); artifactCountsScrollPane.setViewportView(artifactCountsTable); fileTypePiePanel.setPreferredSize(new java.awt.Dimension(400, 300)); @@ -303,15 +304,7 @@ class DataSourceSummaryCountsPanel extends javax.swing.JPanel { // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JScrollPane artifactCountsScrollPane; private javax.swing.JTable artifactCountsTable; - private javax.swing.JLabel byCategoryLabel; - private javax.swing.JScrollPane fileCountsByCategoryScrollPane; private javax.swing.JTable fileCountsByCategoryTable; - private javax.swing.JPanel fileTypePiePanel; - private javax.swing.JPanel filesByCatParent; - private javax.swing.JPanel parentPanel; - private javax.swing.JLabel resultsByTypeLabel; - private javax.swing.JPanel resultsByTypeParent; // End of variables declaration//GEN-END:variables } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java index 37b1ddceec..f7700e2ce3 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/FileTypePieChart.java @@ -44,7 +44,8 @@ import static org.sleuthkit.autopsy.coreutils.FileTypeUtils.FileTypeCategory; * A Pie Chart that shows file mime types in a data source. */ class FileTypePieChart extends JPanel { - + private static final long serialVersionUID = 1L; + private static final Font DEFAULT_FONT = new JLabel().getFont(); private static final Font DEFAULT_HEADER_FONT = new Font(DEFAULT_FONT.getName(), DEFAULT_FONT.getStyle(), (int) (DEFAULT_FONT.getSize() * 1.5)); From 38bf9b9c0373740c6c6290ce36a3e8f9c8c6d334 Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 11 Aug 2020 07:26:41 -0400 Subject: [PATCH 13/13] revert some bundles --- .../casemodule/datasourcesummary/Bundle_ja.properties | 5 +++-- .../modules/photoreccarver/Bundle.properties-MERGED | 10 ++++++++++ .../autopsy/keywordsearch/Bundle.properties-MERGED | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties index 41bb7e4ed8..99fd24c7ef 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/datasourcesummary/Bundle_ja.properties @@ -56,6 +56,9 @@ DataSourceSummaryDetailsPanel.acquisitionDetailsTextArea.text= DataSourceSummaryDetailsPanel.acquisitionDetailsLabel.text=\u53d6\u5f97\u306e\u8a73\u7d30: DataSourceSummaryDetailsPanel.unallocatedSizeLabel.text=\u672a\u4f7f\u7528\u9818\u57df: DataSourceSummaryDetailsPanel.unallocatedSizeValue.text= +DataSourceSummaryCountsPanel.byMimeTypeLabel.text=MIME\u30bf\u30a4\u30d7\u5225\u30d5\u30a1\u30a4\u30eb +DataSourceSummaryCountsPanel.byCategoryLabel.text=\u30ab\u30c6\u30b4\u30ea\u30fc\u5225\u30d5\u30a1\u30a4\u30eb +DataSourceSummaryCountsPanel.jLabel1.text=\u30bf\u30a4\u30d7\u5225\u7d50\u679c DataSourceSummaryDialog.countsTab.title=\u30ab\u30a6\u30f3\u30c8 DataSourceSummaryDialog.detailsTab.title=\u8a73\u7d30 DataSourceSummaryDialog.ingestHistoryTab.title=\u30a4\u30f3\u30b8\u30a7\u30b9\u30c8\u5c65\u6b74 @@ -68,5 +71,3 @@ DataSourceSummaryNode.column.tags.header=\u30bf\u30b0 DataSourceSummaryNode.column.type.header=\u30bf\u30a4\u30d7 DataSourceSummaryNode.viewDataSourceAction.text=\u30c7\u30fc\u30bf\u30bd\u30fc\u30b9\u306b\u79fb\u52d5 ViewSummaryInformationAction.name.text=\u30b5\u30de\u30ea\u30fc\u60c5\u5831\u3092\u8868\u793a -DataSourceSummaryCountsPanel.byCategoryLabel.text=\u30ab\u30c6\u30b4\u30ea\u30fc\u5225\u30d5\u30a1\u30a4\u30eb -DataSourceSummaryCountsPanel.resultsByTypeLabel.text=\u30bf\u30a4\u30d7\u5225\u7d50\u679c diff --git a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/Bundle.properties-MERGED index 87dacfc16c..c107f8f0fb 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/modules/photoreccarver/Bundle.properties-MERGED @@ -8,6 +8,9 @@ OpenIDE-Module-Long-Description=PhotoRec Carver ingest module. \n\n Carves unall OpenIDE-Module-Short-Description=Carves unallocated space and feeds carved files back into the system for processing. moduleDisplayName.text=PhotoRec Carver moduleDescription.text=Runs PhotoRec carver against unallocated space in the data source. +# {0} - extensions +PhotoRecCarverFileIngestModule_startUp_invalidExtensions_description=The following extensions are invalid: {0} +PhotoRecCarverFileIngestModule_startUp_noExtensionsProvided_description=No extensions provided for PhotoRec to carve. PhotoRecIngestModule.nonHostnameUNCPathUsed=PhotoRec cannot operate with a UNC path containing IP addresses. PhotoRecIngestModule.PermissionsNotSufficient=Insufficient permissions accessing PhotoRecIngestModule.PermissionsNotSufficientSeeReference=See 'Shared Drive Authentication' in Autopsy help. @@ -26,5 +29,12 @@ PhotoRecIngestModule.error.msg=Error processing {0} with PhotoRec carver. PhotoRecIngestModule.complete.numberOfErrors=Number of Errors while Carving: PhotoRecCarverIngestJobSettingsPanel.detectionSettingsLabel.text=PhotoRec Settings PhotoRecCarverIngestJobSettingsPanel.keepCorruptedFilesCheckbox.text=Keep corrupted files +PhotoRecCarverIngestJobSettingsPanel.includeExcludeCheckbox.text=Focus on certain file types +PhotoRecCarverIngestJobSettingsPanel.fullListOfTypesLabel.text=Full List of Types: +PhotoRecCarverIngestJobSettingsPanel.exampleLabel.text=Example: jpg,png,zip +PhotoRecCarverIngestJobSettingsPanel.extensionListTextfield.text= +PhotoRecCarverIngestJobSettingsPanel.extensionListLabel.text=Types (comma separated list of extensions) +PhotoRecCarverIngestJobSettingsPanel.excludeRadioButton.text=Ignore the specified types +PhotoRecCarverIngestJobSettingsPanel.includeRadioButton.text=Carve only the specified types unallocatedSpaceProcessingSettingsError.message=The selected file ingest filter ignores unallocated space. This module carves unallocated space. Please choose a filter which does not ignore unallocated space or disable this module. unsupportedOS.message=PhotoRec module is supported on Windows platforms only. diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED index 79a4135ce4..7dfb0acb54 100755 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties-MERGED @@ -36,7 +36,7 @@ KeywordSearchResultFactory.createNodeForKey.noResultsFound.text=No results found KeywordSearchResultFactory.query.exception.msg=Could not perform the query OpenIDE-Module-Display-Category=Ingest Module -OpenIDE-Module-Long-Description=Keyword Search ingest module.\n\nThe module indexes files found in the disk image at ingest time.\nIt then periodically runs the search on the indexed files using one or more keyword lists (containing pure words and/or regular expressions) and posts results.\n\n\The module also contains additional tools integrated in the main GUI, such as keyword list configuration, keyword search bar in the top-right corner, extracted text viewer and search results viewer showing highlighted keywords found. +OpenIDE-Module-Long-Description=Keyword Search ingest module.\n\nThe module indexes files found in the disk image at ingest time.\nIt then periodically runs the search on the indexed files using one or more keyword lists (containing pure words and/or regular expressions) and posts results.\n\nThe module also contains additional tools integrated in the main GUI, such as keyword list configuration, keyword search bar in the top-right corner, extracted text viewer and search results viewer showing highlighted keywords found. OpenIDE-Module-Name=KeywordSearch OptionsCategory_Name_KeywordSearchOptions=Keyword Search OptionsCategory_Keywords_KeywordSearchOptions=Keyword Search