Merge pull request #4808 from wschaeferB/5046-RecentActivityNPE

5046 recent activity npe
This commit is contained in:
Richard Cordovano 2019-05-29 09:17:22 -04:00 committed by GitHub
commit b16b27f23b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -410,12 +410,15 @@ class ExtractRegistry extends Extract {
if (timenodes.getLength() > 0) { if (timenodes.getLength() > 0) {
Element timenode = (Element) timenodes.item(0); Element timenode = (Element) timenodes.item(0);
String etime = timenode.getTextContent(); String etime = timenode.getTextContent();
try { //sometimes etime will be an empty string and therefore can not be parsed into a date
mtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(etime).getTime(); if (etime != null && !etime.isEmpty()) {
String Tempdate = mtime.toString(); try {
mtime = Long.valueOf(Tempdate) / MS_IN_SEC; mtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(etime).getTime();
} catch (ParseException ex) { String Tempdate = mtime.toString();
logger.log(Level.WARNING, "Failed to parse epoch time when parsing the registry.", ex); //NON-NLS mtime = Long.valueOf(Tempdate) / MS_IN_SEC;
} catch (ParseException ex) {
logger.log(Level.WARNING, "Failed to parse epoch time when parsing the registry.", ex); //NON-NLS
}
} }
} }
@ -444,8 +447,14 @@ class ExtractRegistry extends Extract {
if (artchild.hasAttributes()) { if (artchild.hasAttributes()) {
Element artnode = (Element) artchild; Element artnode = (Element) artchild;
String value = artnode.getTextContent().trim(); String value = artnode.getTextContent();
if (value != null) {
value = value.trim();
}
String name = artnode.getAttribute("name"); //NON-NLS String name = artnode.getAttribute("name"); //NON-NLS
if (name == null) {
continue;
}
switch (name) { switch (name) {
case "ProductName": // NON-NLS case "ProductName": // NON-NLS
version = value; version = value;
@ -467,13 +476,14 @@ class ExtractRegistry extends Extract {
regOrg = value; regOrg = value;
break; break;
case "InstallDate": //NON-NLS case "InstallDate": //NON-NLS
try { if (value != null && !value.isEmpty()) {
Long epochtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(value).getTime(); try {
installtime = epochtime; installtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(value).getTime();
String Tempdate = installtime.toString(); String Tempdate = installtime.toString();
installtime = Long.valueOf(Tempdate) / MS_IN_SEC; installtime = Long.valueOf(Tempdate) / MS_IN_SEC;
} catch (ParseException e) { } catch (ParseException e) {
logger.log(Level.SEVERE, "RegRipper::Conversion on DateTime -> ", e); //NON-NLS logger.log(Level.SEVERE, "RegRipper::Conversion on DateTime -> ", e); //NON-NLS
}
} }
break; break;
default: default:
@ -651,9 +661,11 @@ class ExtractRegistry extends Extract {
case "uninstall": //NON-NLS case "uninstall": //NON-NLS
Long itemMtime = null; Long itemMtime = null;
try { try {
Long epochtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(artnode.getAttribute("mtime")).getTime(); //NON-NLS String mTimeAttr = artnode.getAttribute("mtime");
itemMtime = epochtime; if (mTimeAttr != null && !mTimeAttr.isEmpty()) {
itemMtime /= MS_IN_SEC; itemMtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(mTimeAttr).getTime(); //NON-NLS
itemMtime /= MS_IN_SEC;
}
} catch (ParseException e) { } catch (ParseException e) {
logger.log(Level.WARNING, "Failed to parse epoch time for installed program artifact."); //NON-NLS logger.log(Level.WARNING, "Failed to parse epoch time for installed program artifact."); //NON-NLS
} }