mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 00:16:16 +00:00
reporting uses new extension code, displays full path and tag names, can be moved around (relative paths)
This commit is contained in:
parent
f19f4c7211
commit
cfa50f4345
@ -93,16 +93,12 @@ public class ImageUtils {
|
||||
logger.log(Level.WARNING, "Error while getting file signature from blackboard.", ex);
|
||||
}
|
||||
|
||||
final String fName = f.getName();
|
||||
final int dotIdx = fName.lastIndexOf('.');
|
||||
final String extension = f.getNameExtension();
|
||||
|
||||
// if we have an extension, check it
|
||||
if ((dotIdx != -1) && (dotIdx != (fName.length() - 1))) {
|
||||
|
||||
final String ext = fName.substring(dotIdx + 1).toLowerCase();
|
||||
|
||||
if (extension.equals("") == false) {
|
||||
// Note: thumbnail generator only supports JPG, GIF, and PNG for now
|
||||
if (SUPP_EXTENSIONS.contains(ext)) {
|
||||
if (SUPP_EXTENSIONS.contains(extension)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingWorker;
|
||||
import org.openide.filesystems.FileUtil;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.coreutils.EscapeUtil;
|
||||
import org.sleuthkit.autopsy.coreutils.ImageUtils;
|
||||
@ -87,7 +88,7 @@ public class ReportGenerator {
|
||||
static final String REPORTS_DIR = "Reports";
|
||||
|
||||
ReportGenerator(Map<TableReportModule, Boolean> tableModuleStates, Map<GeneralReportModule, Boolean> generalModuleStates, Map<FileReportModule, Boolean> fileListModuleStates) {
|
||||
// Create the root reports directory path of the form: <CASE DIRECTORY>/Reports/<Case name> <Timestamp>/
|
||||
// Create the root reports directory path of the form: <CASE DIRECTORY>/Reports/<Case fileName> <Timestamp>/
|
||||
DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss");
|
||||
Date date = new Date();
|
||||
String dateNoTime = dateFormat.format(date);
|
||||
@ -542,7 +543,14 @@ public class ReportGenerator {
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList<String> rowData = new ArrayList<>(Arrays.asList(tag.getContent().getName(), tag.getName().getDisplayName(), tag.getComment()));
|
||||
String fileName;
|
||||
try {
|
||||
fileName = tag.getContent().getUniquePath();
|
||||
} catch (TskCoreException ex) {
|
||||
fileName = tag.getContent().getName();
|
||||
}
|
||||
|
||||
ArrayList<String> rowData = new ArrayList<>(Arrays.asList(fileName, tag.getName().getDisplayName(), tag.getComment()));
|
||||
for (TableReportModule module : tableModules) {
|
||||
// @@@ This casting is a tricky little workaround to allow the HTML report module to slip in a content hyperlink.
|
||||
if (module instanceof ReportHTML) {
|
||||
|
@ -44,6 +44,8 @@ import org.openide.filesystems.FileObject;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.openide.filesystems.FileUtil;
|
||||
import org.sleuthkit.autopsy.casemodule.services.Services;
|
||||
import org.sleuthkit.autopsy.casemodule.services.TagsManager;
|
||||
import org.sleuthkit.autopsy.coreutils.ImageUtils;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.ContentUtils.ExtractFscContentVisitor;
|
||||
@ -538,7 +540,7 @@ public class ReportHTML implements TableReportModule {
|
||||
|
||||
// Add the hyperlink to the row. A column header for it was created in startTable().
|
||||
StringBuilder localFileLink = new StringBuilder();
|
||||
localFileLink.append("<a href=\"file:///");
|
||||
localFileLink.append("<a href=\"");
|
||||
localFileLink.append(localFilePath);
|
||||
localFileLink.append("\">View File</a>");
|
||||
row.add(localFileLink.toString());
|
||||
@ -605,15 +607,39 @@ public class ReportHTML implements TableReportModule {
|
||||
continue;
|
||||
}
|
||||
String contentPath = saveContent(file, "thumbs_fullsize");
|
||||
String nameInImage;
|
||||
try {
|
||||
nameInImage = file.getUniquePath();
|
||||
} catch (TskCoreException ex) {
|
||||
nameInImage = file.getName();
|
||||
}
|
||||
|
||||
StringBuilder linkToThumbnail = new StringBuilder();
|
||||
linkToThumbnail.append("<a href=\"file:///");
|
||||
linkToThumbnail.append("<a href=\"");
|
||||
linkToThumbnail.append(contentPath);
|
||||
linkToThumbnail.append("\">");
|
||||
linkToThumbnail.append("<img src=\"").append(thumbnailPath).append("\" />");
|
||||
linkToThumbnail.append("<img src=\"").append(thumbnailPath).append("\" title=\"").append(nameInImage).append("\"/>");
|
||||
linkToThumbnail.append("</a><br>");
|
||||
linkToThumbnail.append(file.getName()).append("<br>");
|
||||
// @@@ Add tags here
|
||||
|
||||
Services services = currentCase.getServices();
|
||||
TagsManager tagsManager = services.getTagsManager();
|
||||
try {
|
||||
List<ContentTag> tags = tagsManager.getContentTagsByContent(content);
|
||||
if (tags.size() > 0) {
|
||||
linkToThumbnail.append("Tags: " );
|
||||
}
|
||||
for (int i = 0; i < tags.size(); i++) {
|
||||
ContentTag tag = tags.get(i);
|
||||
linkToThumbnail.append(tag.getName().getDisplayName());
|
||||
if (i != tags.size() - 1) {
|
||||
linkToThumbnail.append(", ");
|
||||
}
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.WARNING, "Could not find get tags for file.", ex);
|
||||
}
|
||||
|
||||
currentRow.add(linkToThumbnail.toString());
|
||||
|
||||
totalCount++;
|
||||
@ -649,7 +675,7 @@ public class ReportHTML implements TableReportModule {
|
||||
* Save a local copy of the given file in the reports folder.
|
||||
* @param file File to save
|
||||
* @param dirName Custom top-level folder to use to store the files in (tag name, etc.)
|
||||
* @return Path to where file was stored
|
||||
* @return Path to where file was stored (relative to root of HTML folder)
|
||||
*/
|
||||
public String saveContent(AbstractFile file, String dirName) {
|
||||
// clean up the dir name passed in
|
||||
@ -657,8 +683,9 @@ public class ReportHTML implements TableReportModule {
|
||||
dirName2 = dirName2.replace("\\", "_");
|
||||
|
||||
// Make a folder for the local file with the same tagName as the tag.
|
||||
StringBuilder localFilePath = new StringBuilder();
|
||||
localFilePath.append(path);
|
||||
StringBuilder localFilePath = new StringBuilder(); // full path
|
||||
|
||||
localFilePath.append(path);
|
||||
localFilePath.append(dirName2);
|
||||
File localFileFolder = new File(localFilePath.toString());
|
||||
if (!localFileFolder.exists()) {
|
||||
@ -687,7 +714,9 @@ public class ReportHTML implements TableReportModule {
|
||||
if (!localFile.exists()) {
|
||||
ExtractFscContentVisitor.extract(file, localFile, null, null);
|
||||
}
|
||||
return localFilePath.toString();
|
||||
|
||||
// get the relative path
|
||||
return localFilePath.toString().substring(path.length());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user