Class DatabaseProperties

java.lang.Object
org.owasp.dependencycheck.data.nvdcve.DatabaseProperties

@ThreadSafe public class DatabaseProperties extends Object
This 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 Details

    • NVD_API_LAST_MODIFIED

      public static final String NVD_API_LAST_MODIFIED
      The last modified request data for the NVD API.
      See Also:
    • NVD_API_LAST_CHECKED

      public static final String NVD_API_LAST_CHECKED
      The date the NVD API was last checked for an update.
      See Also:
    • NVD_CACHE_LAST_CHECKED

      public static final String NVD_CACHE_LAST_CHECKED
      The date the NVD cache was last checked for an update.
      See Also:
    • NVD_CACHE_LAST_MODIFIED

      public static final String NVD_CACHE_LAST_MODIFIED
      The date the NVD cache data was last modified/updated.
      See Also:
    • LAST_CPE_UPDATE

      public static final String LAST_CPE_UPDATE
      The key for the last time the CPE data was updated.
      See Also:
    • VERSION

      public static final String VERSION
      The key for the database schema version.
      See Also:
    • KEV_LAST_CHECKED

      public static final String KEV_LAST_CHECKED
      The key for the last check time for the Known Exploited Vulnerabilities.
      See Also:
    • KEV_VERSION

      public static final String KEV_VERSION
      The key for the version the Known Exploited Vulnerabilities.
      See Also:
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns whether or not any properties are set.
      Returns:
      whether or not any properties are set
    • save

      public void save(String key, String value)
      Saves the key value pair to the properties store.
      Parameters:
      key - the property key
      value - the property value
    • getProperty

      public String getProperty(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 String getProperty(String key, 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 key
      defaultValue - the default value
      Returns:
      the value of the property
    • getProperties

      public Properties getProperties()
      Returns the collection of Database Properties as a properties collection.
      Returns:
      the collection of Database Properties
    • getMetaData

      public Map<String,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 ZonedDateTime getTimestamp(String key)
      Retrieves a zoned date time.
      Parameters:
      key - the property key
      Returns:
      the zoned date time
    • save

      public void save(String key, ZonedDateTime timestamp)
      Stores a timestamp.
      Parameters:
      key - the property key
      timestamp - the zoned date time
    • setTimestamp

      public static void setTimestamp(Properties properties, String key, ZonedDateTime timestamp)
      Stores a timestamp in the properties file.
      Parameters:
      properties - the properties to store the timestamp
      key - the property key
      timestamp - the zoned date time
    • getTimestamp

      public static ZonedDateTime getTimestamp(Properties properties, String key)
      Retrieves a zoned date time.
      Parameters:
      properties - the properties file containing the date time
      key - the property key
      Returns:
      the zoned date time
    • getIsoTimestamp

      public static ZonedDateTime getIsoTimestamp(Properties properties, String key)
      Retrieves a zoned date time.
      Parameters:
      properties - the properties file containing the date time
      key - the property key
      Returns:
      the zoned date time
    • getPropertyInSeconds

      public long getPropertyInSeconds(String key)
      Returns the database property value in seconds.
      Parameters:
      key - the key to the property
      Returns:
      the property value in seconds