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,6 +410,8 @@ 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();
//sometimes etime will be an empty string and therefore can not be parsed into a date
if (etime != null && !etime.isEmpty()) {
try { try {
mtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(etime).getTime(); mtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(etime).getTime();
String Tempdate = mtime.toString(); String Tempdate = mtime.toString();
@ -418,6 +420,7 @@ class ExtractRegistry extends Extract {
logger.log(Level.WARNING, "Failed to parse epoch time when parsing the registry.", ex); //NON-NLS logger.log(Level.WARNING, "Failed to parse epoch time when parsing the registry.", ex); //NON-NLS
} }
} }
}
NodeList artroots = tempnode.getElementsByTagName("artifacts"); //NON-NLS NodeList artroots = tempnode.getElementsByTagName("artifacts"); //NON-NLS
if (artroots.getLength() == 0) { if (artroots.getLength() == 0) {
@ -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,14 +476,15 @@ class ExtractRegistry extends Extract {
regOrg = value; regOrg = value;
break; break;
case "InstallDate": //NON-NLS case "InstallDate": //NON-NLS
if (value != null && !value.isEmpty()) {
try { try {
Long epochtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(value).getTime(); installtime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(value).getTime();
installtime = epochtime;
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:
break; break;
@ -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 = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy").parse(mTimeAttr).getTime(); //NON-NLS
itemMtime /= MS_IN_SEC; 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
} }