Class EngineVersionCheck
- java.lang.Object
-
- org.owasp.dependencycheck.data.update.EngineVersionCheck
-
- All Implemented Interfaces:
CachedWebDataSource
@ThreadSafe public class EngineVersionCheck extends java.lang.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 Summary
Fields Modifier and Type Field Description static java.lang.StringCURRENT_ENGINE_RELEASEThe property key indicating when the last version check occurred.static java.lang.StringENGINE_VERSION_CHECKED_ONThe property key indicating when the last version check occurred.
-
Constructor Summary
Constructors Modifier Constructor Description EngineVersionCheck()Constructs a new engine version check utility.protectedEngineVersionCheck(Settings settings)Constructs a new engine version check utility for testing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringgetCurrentReleaseVersion()Retrieves the current released version number from the github documentation site.protected java.lang.StringgetUpdateToVersion()Getter for updateToVersion - only used for testing.booleanpurge(Engine engine)Deletes any locally cached data.protected voidsetUpdateToVersion(java.lang.String version)Setter for updateToVersion - only used for testing.protected booleanshouldUpdate(long lastChecked, long now, DatabaseProperties properties, java.lang.String currentVersion)Determines if a new version of the dependency-check engine has been released.booleanupdate(Engine engine)Downloads the current released version number and compares it to the running engine's version number.
-
-
-
Field Detail
-
ENGINE_VERSION_CHECKED_ON
public static final java.lang.String ENGINE_VERSION_CHECKED_ON
The property key indicating when the last version check occurred.- See Also:
- Constant Field Values
-
CURRENT_ENGINE_RELEASE
public static final java.lang.String CURRENT_ENGINE_RELEASE
The property key indicating when the last version check occurred.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
getUpdateToVersion
protected java.lang.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(java.lang.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:
updatein interfaceCachedWebDataSource- 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, java.lang.String currentVersion) throws UpdateExceptionDetermines if a new version of the dependency-check engine has been released.- Parameters:
lastChecked- the epoch time of the last version checknow- the current epoch timeproperties- the database properties objectcurrentVersion- the current version of dependency-check- Returns:
trueif a newer version of the database has been released; otherwisefalse- Throws:
UpdateException- thrown if there is an error connecting to the github documentation site or accessing the local database.
-
getCurrentReleaseVersion
protected java.lang.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:CachedWebDataSourceDeletes any locally cached data.- Specified by:
purgein interfaceCachedWebDataSource- Parameters:
engine- a reference to the dependency-check engine- Returns:
trueif the purge was successful; otherwisefalse
-
-