Update ExtractRegistry.java

Check for empty string and if it is empty do not add the attribute.

Format the block of code.
This commit is contained in:
Mark McKinnon 2021-10-21 10:23:04 -04:00
parent 685c7a3768
commit 3c8f91dfa2

View File

@ -783,29 +783,34 @@ class ExtractRegistry extends Extract {
break; break;
case "usb": //NON-NLS case "usb": //NON-NLS
try { try {
Long usbMtime = Long.parseLong(artnode.getAttribute("mtime")); //NON-NLS Long usbMtime = Long.valueOf("0");
usbMtime = Long.valueOf(usbMtime.toString()); if (!artnode.getAttribute("mtime").isEmpty()) {
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, usbMtime)); usbMtime = Long.parseLong(artnode.getAttribute("mtime")); //NON-NLS
String dev = artnode.getAttribute("dev"); //NON-NLS
String make = "";
String model = dev;
if (dev.toLowerCase().contains("vid")) { //NON-NLS
USBInfo info = USB_MAPPER.parseAndLookup(dev);
if (info.getVendor() != null) {
make = info.getVendor();
} }
if (info.getProduct() != null) { usbMtime = Long.valueOf(usbMtime.toString());
model = info.getProduct(); if (usbMtime > 0) {
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DATETIME, parentModuleName, usbMtime));
} }
String dev = artnode.getAttribute("dev"); //NON-NLS
String make = "";
String model = dev;
if (dev.toLowerCase().contains("vid")) { //NON-NLS
USBInfo info = USB_MAPPER.parseAndLookup(dev);
if (info.getVendor() != null) {
make = info.getVendor();
}
if (info.getProduct() != null) {
model = info.getProduct();
}
}
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MAKE, parentModuleName, make));
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MODEL, parentModuleName, model));
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_ID, parentModuleName, value));
newArtifacts.add(createArtifactWithAttributes(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED, regFile, bbattributes));
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, String.format("Error adding device_attached artifact to blackboard for file %d.", regFile.getId()), ex); //NON-NLS
} }
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MAKE, parentModuleName, make)); break;
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_MODEL, parentModuleName, model));
bbattributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_DEVICE_ID, parentModuleName, value));
newArtifacts.add(createArtifactWithAttributes(ARTIFACT_TYPE.TSK_DEVICE_ATTACHED, regFile, bbattributes));
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, String.format("Error adding device_attached artifact to blackboard for file %d.", regFile.getId()), ex); //NON-NLS
}
break;
case "uninstall": //NON-NLS case "uninstall": //NON-NLS
Long itemMtime = null; Long itemMtime = null;
try { try {