From 222db62abb52b734b1d4e2611423b5e9e99e5a34 Mon Sep 17 00:00:00 2001 From: Ann Priestman Date: Wed, 9 Jan 2019 09:52:15 -0500 Subject: [PATCH 1/2] Show acquisition details in content viewer --- .../autopsy/contentviewers/Metadata.java | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/Metadata.java b/Core/src/org/sleuthkit/autopsy/contentviewers/Metadata.java index 740bf6511d..d163f6dc71 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/Metadata.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/Metadata.java @@ -19,13 +19,16 @@ package org.sleuthkit.autopsy.contentviewers; import java.awt.Component; +import java.util.logging.Level; import org.openide.nodes.Node; import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.openide.util.lookup.ServiceProvider; import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer; import org.sleuthkit.autopsy.datamodel.ContentUtils; +import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.datamodel.DataSource; import org.sleuthkit.datamodel.Image; import org.sleuthkit.datamodel.FsContent; import org.sleuthkit.datamodel.TskCoreException; @@ -40,6 +43,8 @@ import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM; @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives public class Metadata extends javax.swing.JPanel implements DataContentViewer { + private static final Logger LOGGER = Logger.getLogger(Metadata.class.getName()); + /** * Creates new form Metadata */ @@ -130,11 +135,13 @@ public class Metadata extends javax.swing.JPanel implements DataContentViewer { "Metadata.tableRowTitle.imageType=Type", "Metadata.tableRowTitle.sectorSize=Sector Size", "Metadata.tableRowTitle.timezone=Time Zone", - "Metadata.tableRowTitle.deviceId=Device ID"}) + "Metadata.tableRowTitle.deviceId=Device ID", + "Metadata.tableRowTitle.acquisitionDetails=Acquisition Details"}) @Override public void setNode(Node node) { AbstractFile file = node.getLookup().lookup(AbstractFile.class); - Image image = node.getLookup().lookup((Image.class)); + Image image = node.getLookup().lookup(Image.class); + DataSource dataSource = node.getLookup().lookup(DataSource.class); if (file == null && image == null) { setText(NbBundle.getMessage(this.getClass(), "Metadata.nodeText.nonFilePassedIn")); return; @@ -167,12 +174,13 @@ public class Metadata extends javax.swing.JPanel implements DataContentViewer { } addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.md5"), md5); addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.hashLookupResults"), file.getKnown().toString()); - + addAcquisitionDetails(sb, dataSource); + addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.internalid"), Long.toString(file.getId())); if (file.getType().compareTo(TSK_DB_FILES_TYPE_ENUM.LOCAL) == 0) { addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.localPath"), file.getLocalAbsPath()); } - + endTable(sb); /* @@ -235,6 +243,7 @@ public class Metadata extends javax.swing.JPanel implements DataContentViewer { } addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.sectorSize"), Long.toString(image.getSsize())); addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.timezone"), image.getTimeZone()); + addAcquisitionDetails(sb, dataSource); addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.deviceId"), image.getDeviceId()); addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.internalid"), Long.toString(image.getId())); @@ -250,11 +259,32 @@ public class Metadata extends javax.swing.JPanel implements DataContentViewer { } addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.localPath"), pathValues.toString()); } - + setText(sb.toString()); jTextPane1.setCaretPosition(0); this.setCursor(null); } + + /** + * Add the acquisition details to the results (if applicable) + * + * @param sb The output StringBuilder object + * @param dataSource The data source (may be null) + */ + private void addAcquisitionDetails(StringBuilder sb, DataSource dataSource) { + if (dataSource != null) { + try { + String details = dataSource.getAcquisitionDetails(); + if (details == null) { + details = ""; + } + details = details.replaceAll("\n", "
"); + addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.acquisitionDetails"), details); + } catch (TskCoreException ex) { + LOGGER.log(Level.SEVERE, "Error reading acquisition details from case database", ex); //NON-NLS + } + } + } @Override public String getTitle() { From a4f570caf5094125b0641fefb7ca8fdfd466b7ba Mon Sep 17 00:00:00 2001 From: Ann Priestman Date: Wed, 9 Jan 2019 11:10:28 -0500 Subject: [PATCH 2/2] Add default string for empty details --- .../org/sleuthkit/autopsy/contentviewers/Metadata.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/contentviewers/Metadata.java b/Core/src/org/sleuthkit/autopsy/contentviewers/Metadata.java index d163f6dc71..6bd42367e2 100644 --- a/Core/src/org/sleuthkit/autopsy/contentviewers/Metadata.java +++ b/Core/src/org/sleuthkit/autopsy/contentviewers/Metadata.java @@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.contentviewers; import java.awt.Component; import java.util.logging.Level; +import org.apache.commons.lang3.StringUtils; import org.openide.nodes.Node; import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; @@ -136,7 +137,8 @@ public class Metadata extends javax.swing.JPanel implements DataContentViewer { "Metadata.tableRowTitle.sectorSize=Sector Size", "Metadata.tableRowTitle.timezone=Time Zone", "Metadata.tableRowTitle.deviceId=Device ID", - "Metadata.tableRowTitle.acquisitionDetails=Acquisition Details"}) + "Metadata.tableRowTitle.acquisitionDetails=Acquisition Details", + "Metadata.nodeText.unknown=Unknown"}) @Override public void setNode(Node node) { AbstractFile file = node.getLookup().lookup(AbstractFile.class); @@ -275,8 +277,8 @@ public class Metadata extends javax.swing.JPanel implements DataContentViewer { if (dataSource != null) { try { String details = dataSource.getAcquisitionDetails(); - if (details == null) { - details = ""; + if (StringUtils.isEmpty(details)) { + details = Bundle.Metadata_nodeText_unknown(); } details = details.replaceAll("\n", "
"); addRow(sb, NbBundle.getMessage(this.getClass(), "Metadata.tableRowTitle.acquisitionDetails"), details);