Skip to content

Commit

Permalink
#784: store parentGlobalID for all items from SleuthkitReader and also:
Browse files Browse the repository at this point in the history
- fix embedded disks subitems references to parentGlobalID
  • Loading branch information
lfcnassif committed Jan 26, 2022
1 parent daf13ab commit 53d443b
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TimeZone;
import java.util.TreeSet;
Expand Down Expand Up @@ -137,6 +138,8 @@ public class SleuthkitReader extends DataSourceReader {
private int itemCount = 0;
private volatile boolean decodingError = false;

private HashMap<Integer, String> idToGlobalIdMap = new HashMap<>();

// Referência estática para a JVM não finalizar o objeto que será usado
// futuramente
// via referência interna ao JNI para acessar os itens do caso
Expand Down Expand Up @@ -1065,11 +1068,20 @@ private IItem addEvidenceFile(Content content) throws Exception {
private void setSubitemProperties(Item item) {
item.setSubItem(true);
item.setSubitemId(itemCount);
Util.generateGlobalId((String) parent.getExtraAttribute(IndexItem.GLOBAL_ID), item);
item.setExtraAttribute(IndexItem.CONTAINER_GLOBAL_ID, Util.getGlobalId(parent));
}

private void addToProcessingQueue(ICaseData caseData, Item item) throws InterruptedException {
// retrieve and store parentGlobalID explicitly before adding to queue
if (!item.isRoot()) {
String parentGlobalID = idToGlobalIdMap.get(item.getParentId());
if (parentGlobalID != null) {
item.setExtraAttribute(IndexItem.PARENT_GLOBAL_ID, parentGlobalID);
} else {
throw new RuntimeException("parentGlobalID must not be null: " + item.getPath() + " " + item.getName());
}
}

if (embeddedDisk) {
// always add to queue to avoid deadlock if expanding many virtual disks simultaneously
caseData.addItemFirstNonBlocking(item);
Expand All @@ -1084,6 +1096,11 @@ private void addToProcessingQueue(ICaseData caseData, Item item) throws Interrup
}

}
// store parents globalID after adding to queue (where it is computed and ID could be reassigned)
if (item.hasChildren() || item.isDir() || item.isRoot()) {
String globalID = (String) item.getExtraAttribute(IndexItem.GLOBAL_ID);
idToGlobalIdMap.put(item.getId(), globalID);
}
}

private boolean isFATFile(Content content) {
Expand Down

0 comments on commit 53d443b

Please sign in to comment.