mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
Properly close resource streams in html report generation to ensure report has images before applications closes and streams are flushed
This commit is contained in:
parent
8cfd800077
commit
f87135afca
@ -460,76 +460,107 @@ public class ReportHTML implements TableReportModule {
|
|||||||
//pull generator and agency logo from branding, and the remaining resources from the core jar
|
//pull generator and agency logo from branding, and the remaining resources from the core jar
|
||||||
String generatorLogoPath = reportBranding.getGeneratorLogoPath();
|
String generatorLogoPath = reportBranding.getGeneratorLogoPath();
|
||||||
if (generatorLogoPath != null) {
|
if (generatorLogoPath != null) {
|
||||||
in = new FileInputStream(generatorLogoPath);
|
File from = new File(generatorLogoPath);
|
||||||
output = new FileOutputStream(new File(path + File.separator + "generator_logo.png"));
|
File to = new File(path);
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copyFile(FileUtil.toFileObject(from), FileUtil.toFileObject(to), "generator_logo");
|
||||||
}
|
}
|
||||||
|
|
||||||
String agencyLogoPath = reportBranding.getAgencyLogoPath();
|
String agencyLogoPath = reportBranding.getAgencyLogoPath();
|
||||||
if (agencyLogoPath != null) {
|
if (agencyLogoPath != null) {
|
||||||
in = new FileInputStream(agencyLogoPath);
|
File from = new File(agencyLogoPath);
|
||||||
output = new FileOutputStream(new File(path + File.separator + "agency_logo.png"));
|
File to = new File(path);
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copyFile(FileUtil.toFileObject(from), FileUtil.toFileObject(to), "agency_logo");
|
||||||
}
|
}
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/favicon.ico");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/favicon.ico");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "favicon.ico"));
|
output = new FileOutputStream(new File(path + File.separator + "favicon.ico"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/summary.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/summary.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "summary.png"));
|
output = new FileOutputStream(new File(path + File.separator + "summary.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/bookmarks.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/bookmarks.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Bookmarks.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Bookmarks.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/cookies.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/cookies.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Cookies.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Cookies.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/history.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/history.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Web History.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Web History.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/downloads.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/downloads.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Downloads.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Downloads.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/search.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/search.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Web Search Engine Queries.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Web Search Engine Queries.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/recent.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/recent.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Recent Documents.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Recent Documents.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/installed.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/installed.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Installed Programs.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Installed Programs.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/keywords.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/keywords.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Keyword Hits.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Keyword Hits.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/devices.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/devices.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Devices Attached.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Devices Attached.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/exif.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/exif.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "EXIF Metadata.png"));
|
output = new FileOutputStream(new File(path + File.separator + "EXIF Metadata.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/userbookmarks.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/userbookmarks.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "File Tags.png"));
|
output = new FileOutputStream(new File(path + File.separator + "File Tags.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/userbookmarks.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/userbookmarks.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Result Tags.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Result Tags.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
|
|
||||||
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/hash.png");
|
in = getClass().getResourceAsStream("/org/sleuthkit/autopsy/report/images/hash.png");
|
||||||
output = new FileOutputStream(new File(path + File.separator + "Hashset Hits.png"));
|
output = new FileOutputStream(new File(path + File.separator + "Hashset Hits.png"));
|
||||||
FileUtil.copy(in, output);
|
FileUtil.copy(in, output);
|
||||||
|
in.close();
|
||||||
|
output.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.log(Level.SEVERE, "Failed to extract images for HTML report.", ex);
|
logger.log(Level.SEVERE, "Failed to extract images for HTML report.", ex);
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user