From e02af459a3ee6993857fbc90d97e57389bb9f1d3 Mon Sep 17 00:00:00 2001 From: Henri Rosten Date: Fri, 22 Dec 2023 08:38:38 +0200 Subject: [PATCH] Continue despite failure in downloading cpedict Signed-off-by: Henri Rosten --- src/sbomnix/cpe.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sbomnix/cpe.py b/src/sbomnix/cpe.py index 12d47f0..7c26516 100644 --- a/src/sbomnix/cpe.py +++ b/src/sbomnix/cpe.py @@ -37,8 +37,13 @@ def __init__(self): LOG.debug("read CPE dictionary from cache") else: LOG.debug("CPE cache miss, downloading: %s", _CPE_CSV_URL) - self.df_cpedict = df_from_csv_file(_CPE_CSV_URL) - self.cache.set(_CPE_CSV_URL, self.df_cpedict, ttl=_CPE_CSV_CACHE_TTL) + self.df_cpedict = df_from_csv_file(_CPE_CSV_URL, exit_on_error=False) + if self.df_cpedict is None or self.df_cpedict.empty: + LOG.warning( + "Failed downloading cpedict: CPE information might not be accurate" + ) + else: + self.cache.set(_CPE_CSV_URL, self.df_cpedict, ttl=_CPE_CSV_CACHE_TTL) if self.df_cpedict is not None: # Verify the loaded cpedict contains at least the following columns required_cols = {"vendor", "product"}