Class Vulnerability
- java.lang.Object
-
- org.owasp.dependencycheck.dependency.Vulnerability
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<Vulnerability>
@NotThreadSafe public class Vulnerability extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Vulnerability>
Contains the information about a vulnerability.- Author:
- Jeremy Long
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVulnerability.SourceAn enumeration for the source of vulnerability.
-
Constructor Summary
Constructors Constructor Description Vulnerability()Default constructor.Vulnerability(java.lang.String name)Constructs a new Vulnerability by its name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCwe(java.lang.String cwe)Adds a CWE to the set.voidaddReference(java.lang.String referenceSource, java.lang.String referenceName, java.lang.String referenceUrl)Adds a reference.voidaddReference(Reference ref)Adds a reference to the references collection.voidaddReferences(java.util.Set<Reference> references)Adds the references to the collection.voidaddVulnerableSoftware(java.util.Set<VulnerableSoftware> vulnerableSoftware)Adds the vulnerableSoftware to the collection.voidaddVulnerableSoftware(VulnerableSoftware software)Adds an entry for vulnerable software.intcompareTo(@NotNull Vulnerability o)Compares two vulnerabilities.
Natural order of vulnerabilities is defined as decreasing in severity and alphabetically by name for equal severity.booleanequals(java.lang.Object obj)io.github.jeremylong.openvulnerability.client.nvd.CvssV2getCvssV2()Get the CVSS V2 scoring information.io.github.jeremylong.openvulnerability.client.nvd.CvssV3getCvssV3()Get the CVSS V3 scoring information.io.github.jeremylong.openvulnerability.client.nvd.CvssV4getCvssV4()Get the CVSS V3 scoring information.CweSetgetCwes()Get the set of CWEs.java.lang.StringgetDescription()Get the value of description.java.lang.StringgetHighestSeverityText()The report text to use for highest severity when this issue is ranked highest.VulnerabilitygetKnownExploitedVulnerability()Get the value of knownExploitedVulnerability.VulnerableSoftwaregetMatchedVulnerableSoftware()Get the value of matchedVulnerableSoftware.java.lang.StringgetName()Get the value of name.java.lang.StringgetNotes()Get the value of notes from suppression notes.java.util.Set<Reference>getReferences()Get the value of references.java.util.List<Reference>getReferences(boolean sorted)Returns the list of references.Vulnerability.SourcegetSource()Returns the source that identified the vulnerability.java.lang.StringgetUnscoredSeverity()Retrieves the severity aVulnerability.Sourcehas assigned for which a CVSS score is not available.java.util.Set<VulnerableSoftware>getVulnerableSoftware()Get the value of vulnerableSoftware.java.util.List<VulnerableSoftware>getVulnerableSoftware(boolean sorted)Returns a sorted list of vulnerable software.inthashCode()voidremoveVulnerableSoftware(java.util.Set<VulnerableSoftware> vulnerableSoftware)Removes the specified vulnerableSoftware from the collection.voidsetCvssV2(io.github.jeremylong.openvulnerability.client.nvd.CvssV2 cvssV2)Sets the CVSS V2 scoring information.voidsetCvssV3(io.github.jeremylong.openvulnerability.client.nvd.CvssV3 cvssV3)Sets the CVSS V3 scoring information.voidsetCvssV4(io.github.jeremylong.openvulnerability.client.nvd.CvssV4 cvssV4)Sets the CVSS V4 scoring information.voidsetDescription(java.lang.String description)Set the value of description.voidsetKnownExploitedVulnerability(Vulnerability kev)Adds information about known exploited vulnerabilities.voidsetMatchedVulnerableSoftware(VulnerableSoftware software)Sets the CPE that caused this vulnerability to be flagged.voidsetName(java.lang.String name)Set the value of name.voidsetNotes(java.lang.String notes)Set the value of notes.voidsetSource(Vulnerability.Source source)Sets the source that identified the vulnerability.voidsetUnscoredSeverity(java.lang.String unscoredSeverity)Sets the severity aVulnerability.Sourcehas assigned for which a CVSS score is not available.java.lang.StringtoString()
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the value of name.- Returns:
- the value of name
-
setName
public void setName(java.lang.String name)
Set the value of name.- Parameters:
name- new value of name
-
getDescription
public java.lang.String getDescription()
Get the value of description.- Returns:
- the value of description
-
setDescription
public void setDescription(java.lang.String description)
Set the value of description.- Parameters:
description- new value of description
-
getReferences
public java.util.Set<Reference> getReferences()
Get the value of references.- Returns:
- the value of references
-
getReferences
public java.util.List<Reference> getReferences(boolean sorted)
Returns the list of references. This is primarily used within the generated reports.- Parameters:
sorted- whether the returned list should be sorted- Returns:
- the list of references
-
addReferences
public void addReferences(java.util.Set<Reference> references)
Adds the references to the collection.- Parameters:
references- a collection of references to add
-
addReference
public void addReference(Reference ref)
Adds a reference to the references collection.- Parameters:
ref- a reference for the vulnerability
-
addReference
public void addReference(java.lang.String referenceSource, java.lang.String referenceName, java.lang.String referenceUrl)Adds a reference.- Parameters:
referenceSource- the source of the referencereferenceName- the referenceName of the referencereferenceUrl- the url of the reference
-
setKnownExploitedVulnerability
public void setKnownExploitedVulnerability(Vulnerability kev)
Adds information about known exploited vulnerabilities.- Parameters:
kev- the known exploited vulnerability information
-
getKnownExploitedVulnerability
public Vulnerability getKnownExploitedVulnerability()
Get the value of knownExploitedVulnerability.- Returns:
- the value of knownExploitedVulnerability
-
getVulnerableSoftware
public java.util.Set<VulnerableSoftware> getVulnerableSoftware()
Get the value of vulnerableSoftware.- Returns:
- the value of vulnerableSoftware
-
getVulnerableSoftware
public java.util.List<VulnerableSoftware> getVulnerableSoftware(boolean sorted)
Returns a sorted list of vulnerable software. This is primarily used for display within reports.- Parameters:
sorted- whether or not the list should be sorted- Returns:
- the list of vulnerable software
-
removeVulnerableSoftware
public void removeVulnerableSoftware(java.util.Set<VulnerableSoftware> vulnerableSoftware)
Removes the specified vulnerableSoftware from the collection.- Parameters:
vulnerableSoftware- a collection of vulnerable software to be removed
-
addVulnerableSoftware
public void addVulnerableSoftware(java.util.Set<VulnerableSoftware> vulnerableSoftware)
Adds the vulnerableSoftware to the collection.- Parameters:
vulnerableSoftware- a collection of vulnerable software
-
addVulnerableSoftware
public void addVulnerableSoftware(VulnerableSoftware software)
Adds an entry for vulnerable software.- Parameters:
software- the vulnerable software reference to add
-
getCvssV2
public io.github.jeremylong.openvulnerability.client.nvd.CvssV2 getCvssV2()
Get the CVSS V2 scoring information.- Returns:
- the CVSS V2 scoring information
-
setCvssV2
public void setCvssV2(io.github.jeremylong.openvulnerability.client.nvd.CvssV2 cvssV2)
Sets the CVSS V2 scoring information.- Parameters:
cvssV2- the CVSS V2 scoring information
-
getCvssV3
public io.github.jeremylong.openvulnerability.client.nvd.CvssV3 getCvssV3()
Get the CVSS V3 scoring information.- Returns:
- the CVSS V3 scoring information
-
setCvssV3
public void setCvssV3(io.github.jeremylong.openvulnerability.client.nvd.CvssV3 cvssV3)
Sets the CVSS V3 scoring information.- Parameters:
cvssV3- the CVSS V3 scoring information
-
getCvssV4
public io.github.jeremylong.openvulnerability.client.nvd.CvssV4 getCvssV4()
Get the CVSS V3 scoring information.- Returns:
- the CVSS V3 scoring information
-
setCvssV4
public void setCvssV4(io.github.jeremylong.openvulnerability.client.nvd.CvssV4 cvssV4)
Sets the CVSS V4 scoring information.- Parameters:
cvssV4- the CVSS V4 scoring information
-
getCwes
public CweSet getCwes()
Get the set of CWEs.- Returns:
- the set of CWEs
-
addCwe
public void addCwe(java.lang.String cwe)
Adds a CWE to the set.- Parameters:
cwe- new CWE to add
-
getUnscoredSeverity
public java.lang.String getUnscoredSeverity()
Retrieves the severity aVulnerability.Sourcehas assigned for which a CVSS score is not available. Severity could be anything ranging from 'critical', 'high', 'medium', and 'low', to non-traditional labels like 'major', 'minor', and 'important'.- Returns:
- the un-scored severity
-
setUnscoredSeverity
public void setUnscoredSeverity(java.lang.String unscoredSeverity)
Sets the severity aVulnerability.Sourcehas assigned for which a CVSS score is not available. Severity could be anything ranging from 'critical', 'high', 'medium', and 'low', to non-traditional labels like 'major', 'minor', and 'important'.- Parameters:
unscoredSeverity- the un-scored severity
-
getNotes
public java.lang.String getNotes()
Get the value of notes from suppression notes.- Returns:
- the value of notes
-
setNotes
public void setNotes(java.lang.String notes)
Set the value of notes.- Parameters:
notes- new value of notes
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(@NotNull @NotNull Vulnerability o)Compares two vulnerabilities.
Natural order of vulnerabilities is defined as decreasing in severity and alphabetically by name for equal severity. This way the most severe issues are listed first in a sorted list.
This uses abest-effort orderingfor severity as the variety of sources do not guarantee a consistent availability of standardized severity scores. The bestEffort severity level estimation will use CVSSv3 baseScore for comparison when available on both sides. If any of the vulnerabilities does not have a CVSSv3 score the sort order may be off, but it will be consistent.
The ranking (high to low) of severity can be informally represented as<CVSSv3 critical> >> <Unscored recognized critical> >> <Unscored unrecognized (assumed Critical)> >> <Score-based comparison for high-or-lower scoring severities with recognized unscored severities taking the lower bound of the comparable CVSSv3 range>- Specified by:
compareToin interfacejava.lang.Comparable<Vulnerability>- Parameters:
o- a vulnerability to be compared- Returns:
- a negative integer, zero, or a positive integer as this object is less than , equal to, or greater than the specified vulnerability
- See Also:
bestEffortSeverityLevelForSorting()
-
getHighestSeverityText
public java.lang.String getHighestSeverityText()
The report text to use for highest severity when this issue is ranked highest.- Returns:
- The string to display in the report, clarifying for unrecognized unscored severities that critical is assumed.
-
setMatchedVulnerableSoftware
public void setMatchedVulnerableSoftware(VulnerableSoftware software)
Sets the CPE that caused this vulnerability to be flagged.- Parameters:
software- a Vulnerable Software identifier
-
getMatchedVulnerableSoftware
public VulnerableSoftware getMatchedVulnerableSoftware()
Get the value of matchedVulnerableSoftware.- Returns:
- the value of matchedVulnerableSoftware
-
getSource
public Vulnerability.Source getSource()
Returns the source that identified the vulnerability.- Returns:
- the source
-
setSource
public void setSource(Vulnerability.Source source)
Sets the source that identified the vulnerability.- Parameters:
source- the source
-
-