Skip to content

Commit

Permalink
Merge pull request #2302 from aberenguel/#2299_invalid_local_path_ufdr
Browse files Browse the repository at this point in the history
Fix content of files from UFDR generated by PA 10.3
  • Loading branch information
lfcnassif authored Sep 4, 2024
2 parents 69089c1 + 3fe29c2 commit 3abd400
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public class UfedXmlReader extends DataSourceReader {
private HashSet<String> addedImUfedIds = new HashSet<>();
private HashSet<String> addedTrackIds = new HashSet<>();

HashMap<String, String> md5ToLocalPath = new HashMap<>();

public UfedXmlReader(ICaseData caseData, File output, boolean listOnly) {
super(caseData, output, listOnly);
}
Expand Down Expand Up @@ -804,9 +806,24 @@ else if (item != null && !value.isEmpty()) {
} else if (qName.equals("targetid") && parentNode.element.equals("jumptargets")) { //$NON-NLS-1$ //$NON-NLS-2$
item.getMetadata().add(ExtraProperties.UFED_META_PREFIX + parentNode.element, chars.toString().trim());

} else if (qName.equals("taggedFiles")) { //$NON-NLS-1$
md5ToLocalPath.clear();

} else if (qName.equals("file")) { //$NON-NLS-1$
itemSeq.remove(itemSeq.size() - 1);

// See https://github.com/sepinf-inc/IPED/issues/2299
String md5 = item.getMetadata().get(ExtraProperties.UFED_META_PREFIX + "MD5");
String localPath = item.getMetadata().get(LOCAL_PATH_META);
if (StringUtils.isNotBlank(md5) && md5.length() == 32) {
if (item.getInputStreamFactory() != null && !md5ToLocalPath.containsKey(md5) && StringUtils.isNotBlank(localPath)) {
md5ToLocalPath.put(md5, localPath);
} else if (item.getInputStreamFactory() == null && md5ToLocalPath.containsKey(md5)) {
String seenPath = md5ToLocalPath.get(md5);
setContent(item, seenPath);
}
}

// See https://github.com/sepinf-inc/IPED/issues/1685
boolean merged = false;
if (!itemSeq.isEmpty()) {
Expand Down Expand Up @@ -1288,10 +1305,12 @@ private void setContent(Item item, String path) {
if (fisf == null) {
fisf = new FileInputStreamFactory(rootFolder.toPath());
}
item.setInputStreamFactory(fisf);
item.setIdInDataSource(path);
File file = new File(rootFolder, path);
item.setLength(file.length());
if (file.exists()) {
item.setInputStreamFactory(fisf);
item.setIdInDataSource(path);
item.setLength(file.length());
}
} else {
if (getUISF().entryExists(path)) {
item.setLength(getUISF().getEntrySize(path));
Expand Down

0 comments on commit 3abd400

Please sign in to comment.