Class EngineVersionCheck

java.lang.Object
org.owasp.dependencycheck.data.update.EngineVersionCheck
All Implemented Interfaces:
CachedWebDataSource

@ThreadSafe public class EngineVersionCheck extends Object implements CachedWebDataSource
Checks the gh-pages dependency-check site to determine the current released version number. If the released version number is greater than the running version number a warning is printed recommending that an upgrade be performed.
Author:
Jeremy Long
  • Field Details

    • ENGINE_VERSION_CHECKED_ON

      public static final String ENGINE_VERSION_CHECKED_ON
      The property key indicating when the last version check occurred.
      See Also:
    • CURRENT_ENGINE_RELEASE

      public static final String CURRENT_ENGINE_RELEASE
      The property key indicating when the last version check occurred.
      See Also:
  • Constructor Details

    • EngineVersionCheck

      protected EngineVersionCheck(Settings settings)
      Constructs a new engine version check utility for testing.
      Parameters:
      settings - the configured settings
    • EngineVersionCheck

      public EngineVersionCheck()
      Constructs a new engine version check utility.
  • Method Details

    • getUpdateToVersion

      protected String getUpdateToVersion()
      Getter for updateToVersion - only used for testing. Represents the version retrieved from the database.
      Returns:
      the version to test
    • setUpdateToVersion

      protected void setUpdateToVersion(String version)
      Setter for updateToVersion - only used for testing. Represents the version retrieved from the database.
      Parameters:
      version - the version to test
    • update

      public boolean update(Engine engine) throws UpdateException
      Downloads the current released version number and compares it to the running engine's version number. If the released version number is newer a warning is printed recommending an upgrade.
      Specified by:
      update in interface CachedWebDataSource
      Parameters:
      engine - a reference to the dependency-check engine
      Returns:
      returns false as no updates are made to the database that would require compaction
      Throws:
      UpdateException - thrown if the local database properties could not be updated
    • shouldUpdate

      protected boolean shouldUpdate(long lastChecked, long now, DatabaseProperties properties, String currentVersion) throws UpdateException
      Determines if a new version of the dependency-check engine has been released.
      Parameters:
      lastChecked - the epoch time of the last version check
      now - the current epoch time
      properties - the database properties object
      currentVersion - the current version of dependency-check
      Returns:
      true if a newer version of the database has been released; otherwise false
      Throws:
      UpdateException - thrown if there is an error connecting to the github documentation site or accessing the local database.
    • getCurrentReleaseVersion

      protected String getCurrentReleaseVersion()
      Retrieves the current released version number from the github documentation site.
      Returns:
      the current released version number
    • purge

      public boolean purge(Engine engine)
      Description copied from interface: CachedWebDataSource
      Deletes any locally cached data.
      Specified by:
      purge in interface CachedWebDataSource
      Parameters:
      engine - a reference to the dependency-check engine
      Returns:
      true if the purge was successful; otherwise false