Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Willi Ballenthin <[email protected]>
  • Loading branch information
mr-tz and williballenthin authored Aug 26, 2024
1 parent 6f4726c commit 6e000c6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions capa/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions capa/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion capa/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6e000c6

Please sign in to comment.