Skip to content

Commit

Permalink
Fix crashing when -u never parameter is given
Browse files Browse the repository at this point in the history
The time_of_last_update attribute is now defined when -u never parameter is given
  • Loading branch information
BreadGenie committed Jun 16, 2021
1 parent 94bc09b commit b37b668
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions cve_bin_tool/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def main(argv=None):
cvedb_orig.get_cvelist_if_stale()
else:
LOGGER.warning("Not verifying CVE DB cache")
cvedb_orig.get_db_update_date()
if not cvedb_orig.nvd_years():
with ErrorHandler(mode=error_mode, logger=LOGGER):
raise EmptyCache(cvedb_orig.cachedir)
Expand Down
7 changes: 4 additions & 3 deletions cve_bin_tool/cvedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ def get_cve_count(self):
return self.cve_count

def get_db_update_date(self):
return os.path.getmtime(self.dbpath)

# last time when CVE data was updated
self.time_of_last_update = datetime.datetime.now()
self.time_of_last_update = datetime.datetime.fromtimestamp(
os.path.getmtime(self.dbpath)
)
return os.path.getmtime(self.dbpath)

async def getmeta(self, session, meta_url):
async with session.get(meta_url) as response:
Expand Down

0 comments on commit b37b668

Please sign in to comment.