23 package org.sleuthkit.autopsy.report.modules.bodyfile;
26 import java.io.BufferedWriter;
27 import java.io.FileWriter;
28 import java.io.IOException;
29 import java.util.List;
30 import java.util.logging.Level;
31 import java.util.stream.Collectors;
32 import javax.swing.JPanel;
34 import org.openide.util.NbBundle;
52 private static BodyFileReport instance = null;
54 private Case currentCase;
55 private SleuthkitCase skCase;
57 private String reportPath;
60 private BodyFileReport() {
64 public static synchronized BodyFileReport getDefault() {
65 if (instance == null) {
66 instance =
new BodyFileReport();
72 public boolean supportsDataSourceSelection() {
88 logger.log(Level.SEVERE,
"Exception while getting open case.", ex);
92 progressPanel.
start();
93 progressPanel.
updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.querying"));
101 final String query =
"type = " + TskData.TSK_DB_FILES_TYPE_ENUM.FS.getFileType()
102 +
" AND name != '.' AND name != '..'";
104 progressPanel.
updateStatusLabel(NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.loading"));
107 List<AbstractFile> fs = skCase.findAllFilesWhere(query).stream()
115 .collect(Collectors.toList());
118 String ingestwarning =
"";
120 ingestwarning = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.ingestWarning.text");
123 int size = fs.size();
126 BufferedWriter out = null;
129 out =
new BufferedWriter(
new FileWriter(reportPath,
true));
130 out.write(ingestwarning);
133 for (AbstractFile file : fs) {
137 if (count++ == 100) {
140 NbBundle.getMessage(
this.getClass(),
"ReportBodyFile.progress.processing",
145 if (file.getMd5Hash() != null) {
146 out.write(file.getMd5Hash());
149 if (file.getUniquePath() != null) {
150 out.write(file.getUniquePath());
153 out.write(Long.toString(file.getMetaAddr()));
155 String modeString = file.getModesAsString();
156 if (modeString != null) {
157 out.write(modeString);
160 out.write(Long.toString(file.getUid()));
162 out.write(Long.toString(file.getGid()));
164 out.write(Long.toString(file.getSize()));
166 out.write(Long.toString(file.getAtime()));
168 out.write(Long.toString(file.getMtime()));
170 out.write(Long.toString(file.getCtime()));
172 out.write(Long.toString(file.getCrtime()));
175 }
catch (IOException ex) {
176 logger.log(Level.WARNING,
"Could not write the temp body file report.", ex);
183 NbBundle.getMessage(
this.getClass(),
184 "ReportBodyFile.generateReport.srcModuleName.text"),
"");
187 }
catch (IOException ex) {
188 logger.log(Level.WARNING,
"Could not flush and close the BufferedWriter.", ex);
190 String errorMessage = String.format(
"Error adding %s to case as a report", reportPath);
191 logger.log(Level.SEVERE, errorMessage, ex);
195 }
catch (TskCoreException ex) {
196 logger.log(Level.WARNING,
"Failed to get the unique path.", ex);
201 public String getName() {
202 String name = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getName.text");
207 public String getRelativeFilePath() {
208 return NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getFilePath.text");
212 public String getDescription() {
213 String desc = NbBundle.getMessage(this.getClass(),
"ReportBodyFile.getDesc.text");
218 public JPanel getConfigurationPanel() {
static synchronized IngestManager getInstance()
void complete(ReportStatus reportStatus)
boolean isIngestRunning()
void addReport(String localPath, String srcModuleName, String reportName)
void setIndeterminate(boolean indeterminate)
void setMaximumProgress(int max)
SleuthkitCase getSleuthkitCase()
List< Long > getSelectedDataSources()
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
void updateStatusLabel(String statusMessage)
String getReportDirectoryPath()