From 51d2ea147b656ba7af9c93e979c00bb22846813a Mon Sep 17 00:00:00 2001 From: Willi Ballenthin Date: Wed, 11 Sep 2024 11:28:04 +0000 Subject: [PATCH] cache: use path to code, not hardcoded relative path closes #2350 --- CHANGELOG.md | 1 + capa/helpers.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22a599a52..2255ffe85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Unlock powerful malware analysis with capa's new [VMRay sandbox](https://www.vmr ### Bug Fixes - fix duplicate features shown in vverbose mode @williballenthin #2323 +- fix code path reference in linter @williballenthin #2350 ### capa explorer IDA Pro plugin diff --git a/capa/helpers.py b/capa/helpers.py index 86f4db694..ec0a99716 100644 --- a/capa/helpers.py +++ b/capa/helpers.py @@ -352,7 +352,11 @@ def is_cache_newer_than_rule_code(cache_dir: Path) -> bool: cache_timestamp = os.path.getmtime(latest_cache_file) # these are the relevant rules code files that could conflict with using an outdated cache - latest_rule_code_file = max([Path("capa/rules/__init__.py"), Path("capa/rules/cache.py")], key=os.path.getmtime) + # delayed import due to circular dependencies + import capa.rules + import capa.rules.cache + + latest_rule_code_file = max([Path(capa.rules.__file__), Path(capa.rules.cache.__file__)], key=os.path.getmtime) rule_code_timestamp = os.path.getmtime(latest_rule_code_file) if rule_code_timestamp > cache_timestamp: