From 341962fd8b51bca45f40a161da5a2c89dcb824ab Mon Sep 17 00:00:00 2001 From: Brian Carrier Date: Tue, 28 Oct 2014 18:15:45 -0400 Subject: [PATCH] reports: force new generator logo, do not dislpay raw tool output in report, change alignment to left instead of center for HTML --- .../autopsy/coreutils/PlatformUtil.java | 3 ++ .../report/ArtifactSelectionDialog.java | 2 +- .../autopsy/report/ReportBranding.java | 38 +++++++------------ .../sleuthkit/autopsy/report/ReportHTML.java | 2 +- .../autopsy/report/ReportVisualPanel2.java | 1 + 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java b/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java index 418e52bcc0..a5c01c9d42 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/PlatformUtil.java @@ -212,6 +212,7 @@ public class PlatformUtil { * @param resourceClass class in the same package as the resourceFile to * extract * @param resourceFile resource file name to extract + * @param overWrite true to overwrite an existing resource * @return true if extracted, false otherwise (if file already exists) * @throws IOException exception thrown if extract the file failed for IO * reasons @@ -223,6 +224,8 @@ public class PlatformUtil { if (resourceFileF.exists() && !overWrite) { return false; } + + resourceFileF.getParentFile().mkdirs(); InputStream inputStream = resourceClass.getResourceAsStream(resourceFile); diff --git a/Core/src/org/sleuthkit/autopsy/report/ArtifactSelectionDialog.java b/Core/src/org/sleuthkit/autopsy/report/ArtifactSelectionDialog.java index 6b07aa0dcc..11ca18705d 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ArtifactSelectionDialog.java +++ b/Core/src/org/sleuthkit/autopsy/report/ArtifactSelectionDialog.java @@ -67,7 +67,7 @@ public class ArtifactSelectionDialog extends javax.swing.JDialog { try { ArrayList doNotReport = new ArrayList<>(); doNotReport.add(BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO); - + doNotReport.add(BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT); // output is too unstructured for table review. artifacts = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifactTypesInUse(); artifacts.removeAll(doNotReport); diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportBranding.java b/Core/src/org/sleuthkit/autopsy/report/ReportBranding.java index 40e8ae3e6c..276004478a 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportBranding.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportBranding.java @@ -19,15 +19,10 @@ package org.sleuthkit.autopsy.report; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.util.logging.Level; import org.sleuthkit.autopsy.coreutils.Logger; -import org.openide.filesystems.FileUtil; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.coreutils.ModuleSettings; import org.sleuthkit.autopsy.coreutils.PlatformUtil; @@ -41,7 +36,6 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil; public final class ReportBranding implements ReportBrandingProviderI { //property names - private static final String GENERATOR_LOGO_PATH_PROP = "GeneratorLogoPath"; //NON-NLS private static final String AGENCY_LOGO_PATH_PROP = "AgencyLogoPath"; //NON-NLS private static final String REPORT_TITLE_PROP = "ReportTitle"; //NON-NLS private static final String REPORT_FOOTER_PROP = "ReportFooter"; //NON-NLS @@ -54,6 +48,7 @@ public final class ReportBranding implements ReportBrandingProviderI { private String reportsBrandingDir; //dir with extracted reports branding resources private static final String MODULE_NAME = ReportBranding.class.getSimpleName(); private static final Logger logger = Logger.getLogger(ReportBranding.class.getName()); + private static String generatorLogoPath; public ReportBranding() { @@ -69,7 +64,7 @@ public final class ReportBranding implements ReportBrandingProviderI { //TODO use defaults } } - getGeneratorLogoPath(); + extractGeneratorLogo(); getAgencyLogoPath(); getReportTitle(); } @@ -78,31 +73,24 @@ public final class ReportBranding implements ReportBrandingProviderI { public String getReportsBrandingDir() { return reportsBrandingDir; } + + private void extractGeneratorLogo() { + try { + PlatformUtil.extractResourceToUserConfigDir(getClass(), DEFAULT_GENERATOR_LOGO, true); + } catch (IOException ex) { + logger.log(Level.SEVERE, "Error extracting report branding resource for generator logo ", ex); //NON-NLS + } + generatorLogoPath = PlatformUtil.getUserConfigDirectory() + File.separator + DEFAULT_GENERATOR_LOGO; + } @Override public String getGeneratorLogoPath() { - String curPath = null; - try { - curPath = ModuleSettings.getConfigSetting(MODULE_NAME, GENERATOR_LOGO_PATH_PROP); - if (curPath == null || (!curPath.isEmpty() && !new File(curPath).canRead() ) ) { - //use default - logger.log(Level.INFO, "Using default report branding for generator logo"); //NON-NLS - curPath = reportsBrandingDir + File.separator + "logo.png"; //NON-NLS - InputStream in = getClass().getResourceAsStream(DEFAULT_GENERATOR_LOGO); - OutputStream output = new FileOutputStream(new File(curPath)); - FileUtil.copy(in, output); - ModuleSettings.setConfigSetting(MODULE_NAME, GENERATOR_LOGO_PATH_PROP, curPath); - } - } catch (IOException e) { - logger.log(Level.SEVERE, "Error extracting report branding resources for generator logo", e); //NON-NLS - } - - return curPath; + return generatorLogoPath; } @Override public void setGeneratorLogoPath(String path) { - ModuleSettings.setConfigSetting(MODULE_NAME, GENERATOR_LOGO_PATH_PROP, path); + } @Override diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java b/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java index 7fa34d292b..b44c9755d0 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportHTML.java @@ -792,7 +792,7 @@ import org.sleuthkit.datamodel.TskData.TSK_DB_FILES_TYPE_ENUM; "table th {white-space:nowrap; display: table-cell; text-align: center; padding: 2px 4px; background: #e5e5e5; color: #777; font-size: 11px; text-shadow: #e9f9fd 0 1px 0; border-top: 1px solid #dedede; border-bottom: 2px solid #e5e5e5;}\n" + //NON-NLS "table .left_align_cell{display: table-cell; padding: 2px 4px; font: 13px/20px Arial, Helvetica, sans-serif; min-width: 125px; overflow: auto; text-align: left; }\n" + //NON-NLS "table .right_align_cell{display: table-cell; padding: 2px 4px; font: 13px/20px Arial, Helvetica, sans-serif; min-width: 125px; overflow: auto; text-align: right; }\n" + //NON-NLS - "table td {white-space:nowrap; display: table-cell; padding: 2px 3px; font: 13px/20px Arial, Helvetica, sans-serif; min-width: 125px; overflow: auto; text-align:center; }\n" + //NON-NLS + "table td {white-space:nowrap; display: table-cell; padding: 2px 3px; font: 13px/20px Arial, Helvetica, sans-serif; min-width: 125px; overflow: auto; text-align:left; }\n" + //NON-NLS "table tr:nth-child(even) td {background: #f3f3f3;}"; //NON-NLS cssOut.write(css); } catch (FileNotFoundException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java index a2615d1445..b5cd0499f8 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java @@ -110,6 +110,7 @@ final class ReportVisualPanel2 extends JPanel { try { ArrayList doNotReport = new ArrayList<>(); doNotReport.add(BlackboardArtifact.ARTIFACT_TYPE.TSK_GEN_INFO); + doNotReport.add(BlackboardArtifact.ARTIFACT_TYPE.TSK_TOOL_OUTPUT); // output is too unstructured for table review artifacts = Case.getCurrentCase().getSleuthkitCase().getBlackboardArtifactTypesInUse();