From c9b1f01adddd8455f385250bf469278caea5599f Mon Sep 17 00:00:00 2001 From: Henri Rosten Date: Mon, 8 Apr 2024 13:53:45 +0300 Subject: [PATCH] Increase local http cache timeout Increase CachedLimiterSession expiration timeout from two to six hours Signed-off-by: Henri Rosten --- src/repology/repology_cli.py | 4 ++-- src/repology/repology_cve.py | 3 ++- src/vulnxscan/vulnxscan_cli.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/repology/repology_cli.py b/src/repology/repology_cli.py index 1e5b938..8ae1235 100755 --- a/src/repology/repology_cli.py +++ b/src/repology/repology_cli.py @@ -124,8 +124,8 @@ def __init__(self): # - Limit non-cached requests to 1 request per second # - Identify this client with custom user-agent # In addition: - # - Cache all responses locally for 7200 seconds - self.session = CachedLimiterSession(per_second=1, expire_after=7200) + # - Cache all responses locally for 6 hours + self.session = CachedLimiterSession(per_second=1, expire_after=6 * 60 * 60) ua_product = "repology_cli/0" ua_comment = "(https://github.com/tiiuae/sbomnix/)" self.headers = {"User-Agent": f"{ua_product} {ua_comment}"} diff --git a/src/repology/repology_cve.py b/src/repology/repology_cve.py index 03f663a..86e308c 100755 --- a/src/repology/repology_cve.py +++ b/src/repology/repology_cve.py @@ -180,7 +180,8 @@ def query_cve(pkg_name, pkg_version): Return vulnerabilities known to repology that impact the given package name and version. Results are returned in pandas dataframe. """ - session = CachedLimiterSession(per_second=1, expire_after=7200) + # Cache all responses locally for 6 hours + session = CachedLimiterSession(per_second=1, expire_after=6 * 60 * 60) ua_product = "repology_cli/0" ua_comment = "(https://github.com/tiiuae/sbomnix/)" headers = {"User-Agent": f"{ua_product} {ua_comment}"} diff --git a/src/vulnxscan/vulnxscan_cli.py b/src/vulnxscan/vulnxscan_cli.py index 9ead4e2..83b3a7c 100755 --- a/src/vulnxscan/vulnxscan_cli.py +++ b/src/vulnxscan/vulnxscan_cli.py @@ -396,7 +396,8 @@ def report(self, args, sbom_csv): _repology_cli_dfs = {} # Rate-limited and cached session. For github api rate limits, see: # https://docs.github.com/en/rest/search?apiVersion=latest#rate-limit -_session = CachedLimiterSession(per_minute=9, per_second=1, expire_after=7200) +# (caching all responses locally for 6 hours) +_session = CachedLimiterSession(per_minute=9, per_second=1, expire_after=6 * 60 * 60) def _select_newest(df):