Class DatabaseProperties
- java.lang.Object
-
- org.owasp.dependencycheck.data.nvdcve.DatabaseProperties
-
@ThreadSafe public class DatabaseProperties extends java.lang.ObjectThis is a wrapper around a set of properties that are stored in the database. This class is safe to be accessed from multiple threads in parallel.- Author:
- Jeremy Long
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringKEV_LAST_CHECKEDThe key for the last check time for the Known Exploited Vulnerabilities.static java.lang.StringKEV_VERSIONThe key for the version the Known Exploited Vulnerabilities.static java.lang.StringLAST_CPE_UPDATEThe key for the last time the CPE data was updated.static java.lang.StringNVD_API_LAST_CHECKEDThe date the NVD API was last checked for an update.static java.lang.StringNVD_API_LAST_MODIFIEDThe last modified request data for the NVD API.static java.lang.StringNVD_CACHE_LAST_CHECKEDThe date the NVD cache was last checked for an update.static java.lang.StringNVD_CACHE_LAST_MODIFIEDThe date the NVD cache data was last modified/updated.static java.lang.StringVERSIONThe key for the database schema version.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.time.ZonedDateTimegetIsoTimestamp(java.util.Properties properties, java.lang.String key)Retrieves a zoned date time.java.util.Map<java.lang.String,java.lang.String>getMetaData()Returns a map of the meta data from the database properties.java.util.PropertiesgetProperties()Returns the collection of Database Properties as a properties collection.java.lang.StringgetProperty(java.lang.String key)Returns the property value for the given key.java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)Returns the property value for the given key.longgetPropertyInSeconds(java.lang.String key)Returns the database property value in seconds.java.time.ZonedDateTimegetTimestamp(java.lang.String key)Retrieves a zoned date time.static java.time.ZonedDateTimegetTimestamp(java.util.Properties properties, java.lang.String key)Retrieves a zoned date time.booleanisEmpty()Returns whether or not any properties are set.voidsave(java.lang.String key, java.lang.String value)Saves the key value pair to the properties store.voidsave(java.lang.String key, java.time.ZonedDateTime timestamp)Stores a timestamp.static voidsetTimestamp(java.util.Properties properties, java.lang.String key, java.time.ZonedDateTime timestamp)Stores a timestamp in the properties file.
-
-
-
Field Detail
-
NVD_API_LAST_MODIFIED
public static final java.lang.String NVD_API_LAST_MODIFIED
The last modified request data for the NVD API.- See Also:
- Constant Field Values
-
NVD_API_LAST_CHECKED
public static final java.lang.String NVD_API_LAST_CHECKED
The date the NVD API was last checked for an update.- See Also:
- Constant Field Values
-
NVD_CACHE_LAST_CHECKED
public static final java.lang.String NVD_CACHE_LAST_CHECKED
The date the NVD cache was last checked for an update.- See Also:
- Constant Field Values
-
NVD_CACHE_LAST_MODIFIED
public static final java.lang.String NVD_CACHE_LAST_MODIFIED
The date the NVD cache data was last modified/updated.- See Also:
- Constant Field Values
-
LAST_CPE_UPDATE
public static final java.lang.String LAST_CPE_UPDATE
The key for the last time the CPE data was updated.- See Also:
- Constant Field Values
-
VERSION
public static final java.lang.String VERSION
The key for the database schema version.- See Also:
- Constant Field Values
-
KEV_LAST_CHECKED
public static final java.lang.String KEV_LAST_CHECKED
The key for the last check time for the Known Exploited Vulnerabilities.- See Also:
- Constant Field Values
-
KEV_VERSION
public static final java.lang.String KEV_VERSION
The key for the version the Known Exploited Vulnerabilities.- See Also:
- Constant Field Values
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Returns whether or not any properties are set.- Returns:
- whether or not any properties are set
-
save
public void save(java.lang.String key, java.lang.String value)Saves the key value pair to the properties store.- Parameters:
key- the property keyvalue- the property value
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Returns the property value for the given key. If the key is not contained in the underlying properties null is returned.- Parameters:
key- the property key- Returns:
- the value of the property
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)Returns the property value for the given key. If the key is not contained in the underlying properties the default value is returned.- Parameters:
key- the property keydefaultValue- the default value- Returns:
- the value of the property
-
getProperties
public java.util.Properties getProperties()
Returns the collection of Database Properties as a properties collection.- Returns:
- the collection of Database Properties
-
getMetaData
public java.util.Map<java.lang.String,java.lang.String> getMetaData()
Returns a map of the meta data from the database properties. This primarily contains timestamps of when the NVD CVE information was last updated.- Returns:
- a map of the database meta data
-
getTimestamp
public java.time.ZonedDateTime getTimestamp(java.lang.String key)
Retrieves a zoned date time.- Parameters:
key- the property key- Returns:
- the zoned date time
-
save
public void save(java.lang.String key, java.time.ZonedDateTime timestamp)Stores a timestamp.- Parameters:
key- the property keytimestamp- the zoned date time
-
setTimestamp
public static void setTimestamp(java.util.Properties properties, java.lang.String key, java.time.ZonedDateTime timestamp)Stores a timestamp in the properties file.- Parameters:
properties- the properties to store the timestampkey- the property keytimestamp- the zoned date time
-
getTimestamp
public static java.time.ZonedDateTime getTimestamp(java.util.Properties properties, java.lang.String key)Retrieves a zoned date time.- Parameters:
properties- the properties file containing the date timekey- the property key- Returns:
- the zoned date time
-
getIsoTimestamp
public static java.time.ZonedDateTime getIsoTimestamp(java.util.Properties properties, java.lang.String key)Retrieves a zoned date time.- Parameters:
properties- the properties file containing the date timekey- the property key- Returns:
- the zoned date time
-
getPropertyInSeconds
public long getPropertyInSeconds(java.lang.String key)
Returns the database property value in seconds.- Parameters:
key- the key to the property- Returns:
- the property value in seconds
-
-