@ThreadSafe public final class CveDB extends Object implements AutoCloseable
| Constructor and Description |
|---|
CveDB(Settings settings)
Creates a new CveDB object and opens the database connection.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCpe(String cpe,
String vendor,
String product)
This method is only referenced in unused code and will likely break on
MySQL if ever used due to the MERGE statement.
|
void |
cleanupDatabase()
It is possible that orphaned rows may be generated during database
updates.
|
void |
close()
Closes the database connection.
|
void |
commit()
Commits all completed transactions.
|
boolean |
dataExists()
Checks to see if data exists so that analysis can be performed.
|
void |
defrag()
If the database is using an H2 file based database calling
defrag() will de-fragment the database. |
void |
deleteUnusedCpe()
This method is only referenced in unused code.
|
protected void |
finalize()
Cleans up the object and ensures that "close" has been called.
|
Set<CpePlus> |
getCPEs(String vendor,
String product)
Searches the CPE entries in the database and retrieves all entries for a
given vendor and product combination.
|
DatabaseProperties |
getDatabaseProperties()
Get the value of databaseProperties.
|
protected VulnerableSoftware |
getMatchingSoftware(us.springett.parsers.cpe.Cpe cpe,
Set<VulnerableSoftware> vulnerableSoftware)
Determines if the given identifiedVersion is affected by the given cpeId
and previous version flag.
|
Properties |
getProperties()
Returns a set of properties.
|
Set<Pair<String,String>> |
getVendorProductList()
Returns the entire list of vendor/product combinations.
|
Set<Pair<String,String>> |
getVendorProductListForNode()
Returns the entire list of vendor/product combinations filtered for just
Node JS related products.
|
List<Vulnerability> |
getVulnerabilities(us.springett.parsers.cpe.Cpe cpe)
Retrieves the vulnerabilities associated with the specified CPE.
|
Vulnerability |
getVulnerability(String cve)
Gets a vulnerability for the provided CVE.
|
protected boolean |
isOpen()
Returns whether the database connection is open or closed.
|
protected DatabaseProperties |
reloadProperties()
Used within the unit tests to reload the database properties.
|
void |
saveProperty(String key,
String value)
Saves a property to the database.
|
void |
updateVulnerability(DefCveItem cve)
Updates the vulnerability within the database.
|
public CveDB(Settings settings) throws DatabaseException
settings - the configured settingsDatabaseException - thrown if there is an exception opening the
database.public void close()
close in interface AutoCloseableprotected boolean isOpen()
public void commit()
throws SQLException
SQLException - thrown if a SQL Exception occursprotected void finalize()
throws Throwable
public DatabaseProperties getDatabaseProperties()
protected DatabaseProperties reloadProperties()
public Set<CpePlus> getCPEs(String vendor, String product)
vendor - the identified vendor name of the dependency being analyzedproduct - the identified name of the product of the dependency being
analyzedpublic Set<Pair<String,String>> getVendorProductList() throws DatabaseException
DatabaseException - thrown when there is an error retrieving the
data from the DBpublic Set<Pair<String,String>> getVendorProductListForNode() throws DatabaseException
DatabaseException - thrown when there is an error retrieving the
data from the DBpublic Properties getProperties()
public void saveProperty(String key, String value)
key - the property keyvalue - the property valuepublic List<Vulnerability> getVulnerabilities(us.springett.parsers.cpe.Cpe cpe) throws DatabaseException
cpe - the CPE to retrieve vulnerabilities forDatabaseException - thrown if there is an exception retrieving datapublic Vulnerability getVulnerability(String cve) throws DatabaseException
cve - the CVE to lookupDatabaseException - if an exception occurspublic void updateVulnerability(DefCveItem cve)
cve - the vulnerability from the NVD CVE Data Feed to add to the
databaseDatabaseException - is thrown if the databasepublic boolean dataExists()
true if data exists; otherwise falsepublic void cleanupDatabase()
public void defrag()
defrag() will de-fragment the database.protected VulnerableSoftware getMatchingSoftware(us.springett.parsers.cpe.Cpe cpe, Set<VulnerableSoftware> vulnerableSoftware)
cpe - the CPE for the given dependencyvulnerableSoftware - a set of the vulnerable softwarepublic void deleteUnusedCpe()
Deletes unused dictionary entries from the database.
public void addCpe(String cpe, String vendor, String product)
Merges CPE entries into the database.
cpe - the CPE identifiervendor - the CPE vendorproduct - the CPE productCopyright © 2012–2020 OWASP. All rights reserved.