Return copies of Purl collections upon get.
@@ -194,11 +194,11 @@ public class Vulnerability implements Serializable, Comparable<Vulnerability> {
}
public LinkedHashSet<Purl> getPurls() {
- return purls;
+ return new LinkedHashSet<>(purls);
}
public LinkedHashSet<Purl> getFirstPatchedPurls() {
- return firstPatchedPurls;
+ return new LinkedHashSet<>(firstPatchedPurls);
}
public void addFirstPatchedPurl(Purl purl) {
@@ -221,8 +221,6 @@ public class Vulnerability implements Serializable, Comparable<Vulnerability> {
this.baseCpe = baseCpe;
}
- // Extra Setters and Getters for Serializability
-
public void setPatchLinks(HashSet<String> patchLinks) {
this.patchLinks = patchLinks;
}
@@ -288,13 +286,12 @@ public class Vulnerability implements Serializable, Comparable<Vulnerability> {
public void merge(Vulnerability v2) {
assert this.getId().equals(v2.getId());
- this.getPurls().addAll(v2.getPurls());
- this.getFirstPatchedPurls().addAll(v2.getFirstPatchedPurls());
- this.getReferences().addAll(v2.getReferences());
- this.getPatches().addAll(v2.getPatches());
- this.getExploits().addAll(v2.getExploits());
- this.getPatchLinks().addAll(v2.getPatchLinks());
- this.getPatches().addAll(v2.getPatches());
+ this.purls.addAll(v2.getPurls());
+ this.firstPatchedPurls.addAll(v2.getFirstPatchedPurls());
+ this.references.addAll(v2.getReferences());
+ this.patches.addAll(v2.getPatches());
+ this.exploits.addAll(v2.getExploits());
+ this.patchLinks.addAll(v2.getPatchLinks());
if (v2.description != null && this.description != null) {
if (v2.getDescription().length() > this.getDescription().length()) {
this.setDescription(v2.getDescription());
@@ -358,11 +355,11 @@ public class Vulnerability implements Serializable, Comparable<Vulnerability> {
@Override
public int compareTo(Vulnerability other) {
- if (this.getPurls().size() > 0 && this.getPatchLinks().size() > 0 && this.getFirstPatchedPurls().size() > 0) return -1;
+ if (purls.size() > 0 && patchLinks.size() > 0 && firstPatchedPurls.size() > 0) return -1;
if (other.getPurls().size() > 0 && other.getPatchLinks().size() > 0 && other.getFirstPatchedPurls().size() > 0) return -1;
- if (this.getPurls().size() > 0 && this.getPatchLinks().size() > 0) return -1;
+ if (purls.size() > 0 && patchLinks.size() > 0) return -1;
if (other.getPurls().size() > 0 && other.getPatchLinks().size() > 0) return 1;
- return -1 * Integer.compare(this.getPurls().size(), other.getPurls().size());
+ return -1 * Integer.compare(purls.size(), other.getPurls().size());
}
}
