diff --git a/capa/helpers.py b/capa/helpers.py index 1fc072431..497a99e41 100644 --- a/capa/helpers.py +++ b/capa/helpers.py @@ -343,13 +343,12 @@ def ts_to_str(ts): return datetime.fromtimestamp(ts).strftime("%Y-%m-%d %H:%M:%S") logger.warning( - "not using cache: latest rule code file %s (%s) is newer than the latest rule cache file %s (%s)", + "latest rule code file %s (%s) is newer than the latest rule cache file %s (%s)", latest_rule_code_file, ts_to_str(rule_code_timestamp), latest_cache_file, ts_to_str(cache_timestamp), ) - logger.debug("delete the cache file manually to use rule caching again") return False logger.debug("no potentially outdated cache files found, cache can be used") diff --git a/capa/main.py b/capa/main.py index 390a0cc26..f42ae8e1a 100644 --- a/capa/main.py +++ b/capa/main.py @@ -622,6 +622,8 @@ def get_rules_from_cli(args) -> RuleSet: if capa.helpers.is_dev_environment(): # using the rules cache during development may result in unexpected errors, see #1898 enable_cache = capa.helpers.is_cache_newer_than_rule_code(cache_dir) + if not enable_cache: + logger.debug("not using cache. delete the cache file manually to use rule caching again") rules = capa.rules.get_rules(args.rules, cache_dir=cache_dir, enable_cache=enable_cache) except (IOError, capa.rules.InvalidRule, capa.rules.InvalidRuleSet) as e: diff --git a/capa/rules/__init__.py b/capa/rules/__init__.py index d5dfcf886..1d7f13ed1 100644 --- a/capa/rules/__init__.py +++ b/capa/rules/__init__.py @@ -2137,7 +2137,7 @@ def get_rules( rule_paths: list of paths to rules files or directories containing rules files cache_dir: directory to use for caching rules, or will use the default detected cache directory if None on_load_rule: callback to invoke before a rule is loaded, use for progress or cancellation - enable_cache: enable loading of a cached ruleset + enable_cache: enable loading of a cached ruleset (default: True) """ if cache_dir is None: cache_dir = capa.rules.cache.get_default_cache_directory()