Class NvdApiDataSource
- java.lang.Object
-
- org.owasp.dependencycheck.data.update.NvdApiDataSource
-
- All Implemented Interfaces:
CachedWebDataSource
public class NvdApiDataSource extends java.lang.Object implements CachedWebDataSource
- Author:
- Jeremy Long
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
NvdApiDataSource.UrlData
-
Constructor Summary
Constructors Constructor Description NvdApiDataSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NvdApiDataSource.UrlData
extractUrlData(java.lang.String nvdDataFeedUrl)
protected java.util.Properties
getRemoteCacheProperties(java.lang.String url, java.lang.String pattern)
Downloads the metadata properties of the NVD API cache.protected java.util.Map<java.lang.String,java.lang.String>
getUpdatesNeeded(java.lang.String url, java.lang.String filePattern, java.util.Properties cacheProperties, java.time.ZonedDateTime now)
Determines if the index needs to be updated.boolean
purge(Engine engine)
Deletes any locally cached data.boolean
update(Engine engine)
Determines if an update to the current data store is needed, if it is the new data is downloaded from the Internet and imported into the current cached data store.
-
-
-
Method Detail
-
update
public boolean update(Engine engine) throws UpdateException
Description copied from interface:CachedWebDataSource
Determines if an update to the current data store is needed, if it is the new data is downloaded from the Internet and imported into the current cached data store.- Specified by:
update
in interfaceCachedWebDataSource
- Parameters:
engine
- a reference to the dependency-check engine- Returns:
- whether or not an update was made to the CveDB
- Throws:
UpdateException
- is thrown if there is an exception downloading the data or updating the data store.
-
extractUrlData
protected NvdApiDataSource.UrlData extractUrlData(java.lang.String nvdDataFeedUrl)
-
purge
public boolean purge(Engine engine)
Description copied from interface:CachedWebDataSource
Deletes any locally cached data.- Specified by:
purge
in interfaceCachedWebDataSource
- Parameters:
engine
- a reference to the dependency-check engine- Returns:
true
if the purge was successful; otherwisefalse
-
getUpdatesNeeded
protected final java.util.Map<java.lang.String,java.lang.String> getUpdatesNeeded(java.lang.String url, java.lang.String filePattern, java.util.Properties cacheProperties, java.time.ZonedDateTime now) throws UpdateException
Determines if the index needs to be updated. This is done by fetching the NVD CVE meta data and checking the last update date. If the data needs to be refreshed this method will return the NvdCveUrl for the files that need to be updated.- Parameters:
url
- the URL of the NVD API cachefilePattern
- the string format pattern for the cached files (e.g. "nvdcve-{0}.json.gz")cacheProperties
- the properties from the remote NVD API cachenow
- the start time of the update process- Returns:
- the map of key to URLs - where the key is the year or `modified`
- Throws:
UpdateException
- Is thrown if there is an issue with the last updated properties file
-
getRemoteCacheProperties
protected final java.util.Properties getRemoteCacheProperties(java.lang.String url, java.lang.String pattern) throws UpdateException
Downloads the metadata properties of the NVD API cache.- Parameters:
url
- the base URL to the NVD API cachepattern
- the pattern of the datafile name for the NVD API cache- Returns:
- the cache properties
- Throws:
UpdateException
- thrown if the properties file could not be downloaded
-
-