From 543f5fc4c715f3f4073e9212053df4fb22e024b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20K=C3=B6ritz?= Date: Fri, 17 Apr 2020 14:07:08 +0200 Subject: [PATCH] Added the possibility to include a comment when adding hashes to a hash set --- .../AddHashValuesToDatabaseProgressDialog.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/AddHashValuesToDatabaseProgressDialog.java b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/AddHashValuesToDatabaseProgressDialog.java index 3715816801..de6b84bdce 100644 --- a/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/AddHashValuesToDatabaseProgressDialog.java +++ b/Core/src/org/sleuthkit/autopsy/modules/hashdatabase/AddHashValuesToDatabaseProgressDialog.java @@ -64,7 +64,7 @@ public class AddHashValuesToDatabaseProgressDialog extends javax.swing.JDialog { display(parent); this.hashes = new ArrayList<>(); this.invalidHashes = new ArrayList<>(); - this.md5Pattern = Pattern.compile("^[a-fA-F0-9]{32}$"); // NON-NLS + this.md5Pattern = Pattern.compile("^([a-fA-F0-9]{32})"); // NON-NLS this.parentRef = parent; this.hashDb = hashDb; this.text = text; @@ -162,9 +162,15 @@ public class AddHashValuesToDatabaseProgressDialog extends javax.swing.JDialog { for (String hashEntry : linesInTextArea) { hashEntry = hashEntry.trim(); Matcher m = md5Pattern.matcher(hashEntry); - if (m.find()) { - // more information can be added to the HashEntry - sha-1, sha-512, comment - hashes.add(new HashEntry(null, m.group(0), null, null, null)); + if (m.find()) { + // Is there any text left on this line? If so, treat it as a comment. + final String comment = hashEntry.substring(m.end()).trim(); + if (comment.length() > 0) { + hashes.add(new HashEntry(null, m.group(0), null, null, comment)); + } else { + // more information can be added to the HashEntry - sha-1, sha-512, comment + hashes.add(new HashEntry(null, m.group(0), null, null, null)); + } } else { if (!hashEntry.isEmpty()) { invalidHashes.add(hashEntry);