mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-05-02 05:04:29 +02:00
fixed compareTo in order to resolve issue #503
This commit is contained in:
@@ -254,17 +254,16 @@ public class NvdCve20Handler extends DefaultHandler {
|
||||
* @throws IOException thrown if there is an IOException with the CPE Index
|
||||
*/
|
||||
private void saveEntry(Vulnerability vuln) throws DatabaseException, CorruptIndexException, IOException {
|
||||
if (cveDB == null) {
|
||||
return;
|
||||
}
|
||||
final String cveName = vuln.getName();
|
||||
if (prevVersionVulnMap.containsKey(cveName)) {
|
||||
if (prevVersionVulnMap != null && prevVersionVulnMap.containsKey(cveName)) {
|
||||
final List<VulnerableSoftware> vulnSoftware = prevVersionVulnMap.get(cveName);
|
||||
for (VulnerableSoftware vs : vulnSoftware) {
|
||||
vuln.updateVulnerableSoftware(vs);
|
||||
}
|
||||
}
|
||||
cveDB.updateVulnerability(vuln);
|
||||
if (cveDB != null) {
|
||||
cveDB.updateVulnerability(vuln);
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="The Element Class that maintains state information about the current node">
|
||||
|
||||
@@ -180,23 +180,14 @@ public class VulnerableSoftware extends IndexEntry implements Serializable, Comp
|
||||
final int max = (left.length <= right.length) ? left.length : right.length;
|
||||
if (max > 0) {
|
||||
for (int i = 0; result == 0 && i < max; i++) {
|
||||
final String[] subLeft = left[i].split("\\.");
|
||||
final String[] subRight = right[i].split("\\.");
|
||||
final String[] subLeft = left[i].split("(\\.|-)");
|
||||
final String[] subRight = right[i].split("(\\.|-)");
|
||||
final int subMax = (subLeft.length <= subRight.length) ? subLeft.length : subRight.length;
|
||||
if (subMax > 0) {
|
||||
for (int x = 0; result == 0 && x < subMax; x++) {
|
||||
if (isPositiveInteger(subLeft[x]) && isPositiveInteger(subRight[x])) {
|
||||
try {
|
||||
result = Long.valueOf(subLeft[x]).compareTo(Long.valueOf(subRight[x]));
|
||||
// final long iLeft = Long.parseLong(subLeft[x]);
|
||||
// final long iRight = Long.parseLong(subRight[x]);
|
||||
// if (iLeft != iRight) {
|
||||
// if (iLeft > iRight) {
|
||||
// result = 2;
|
||||
// } else {
|
||||
// result = -2;
|
||||
// }
|
||||
// }
|
||||
} catch (NumberFormatException ex) {
|
||||
//ignore the exception - they obviously aren't numbers
|
||||
if (!subLeft[x].equalsIgnoreCase(subRight[x])) {
|
||||
|
||||
Reference in New Issue
Block a user