From e937f86a7b7437cb463bf79d528dfc277b554a0f Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Tue, 12 Dec 2023 06:33:11 -0500 Subject: [PATCH] fix: synch last modified timestamp for NVD API Allow an initial data load via the data feed to later be updated by just the API --- .../dependencycheck/data/update/NvdApiDataSource.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/owasp/dependencycheck/data/update/NvdApiDataSource.java b/core/src/main/java/org/owasp/dependencycheck/data/update/NvdApiDataSource.java index bf3ad2ffbbb..da67807bc24 100644 --- a/core/src/main/java/org/owasp/dependencycheck/data/update/NvdApiDataSource.java +++ b/core/src/main/java/org/owasp/dependencycheck/data/update/NvdApiDataSource.java @@ -214,9 +214,15 @@ private boolean processDatafeed(String nvdDataFeedUrl) throws UpdateException { private void storeLastModifiedDates(final ZonedDateTime now, final Properties cacheProperties, final Map updateable) throws UpdateException { + + ZonedDateTime lastModifiedRequest = DatabaseProperties.getTimestamp(cacheProperties, + NVD_API_CACHE_MODIFIED_DATE + ".modified"); dbProperties.save(DatabaseProperties.NVD_CACHE_LAST_CHECKED, now); - dbProperties.save(DatabaseProperties.NVD_CACHE_LAST_MODIFIED, DatabaseProperties.getTimestamp(cacheProperties, - NVD_API_CACHE_MODIFIED_DATE + ".modified")); + dbProperties.save(DatabaseProperties.NVD_CACHE_LAST_MODIFIED, lastModifiedRequest); + //allow users to initially load from a cache but then use the API - this may happen with the GH Action + dbProperties.save(DatabaseProperties.NVD_API_LAST_CHECKED, now); + dbProperties.save(DatabaseProperties.NVD_API_LAST_MODIFIED, lastModifiedRequest); + for (String entry : updateable.keySet()) { final ZonedDateTime date = DatabaseProperties.getTimestamp(cacheProperties, NVD_API_CACHE_MODIFIED_DATE + "." + entry); dbProperties.save(DatabaseProperties.NVD_CACHE_LAST_MODIFIED + "." + entry, date);