From cb3376d9e23fcd94c16525fb5f92f3e4c66219e0 Mon Sep 17 00:00:00 2001 From: Willi Ballenthin Date: Wed, 22 Apr 2026 17:33:06 +0300 Subject: [PATCH] fix: correct off-by-one in call_count debug log for dynamic analysis `enumerate` is 0-based, so after the loop `call_count` held `n - 1` for `n` calls processed. The debug log at the end of `find_thread_capabilities` therefore reported one fewer event than was actually analyzed. Replace `enumerate` with an explicit `call_count += 1` counter so the log is accurate. Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 1 + capa/capabilities/dynamic.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef74e6bc..2b77a44f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - ### Bug Fixes +- fix: correct off-by-one in dynamic analysis call_count debug log (enumerate -> explicit counter) @williballenthin - fix: correct capa/subscope-rule key in RuleMetadata so is_subscope_rule is no longer always False @williballenthin - fix: remove unreachable backports.functools_lru_cache fallback and dead dependency @williballenthin - fix: add missing ELF branch in get_format_from_extension for .elf_ files @williballenthin #3031 diff --git a/capa/capabilities/dynamic.py b/capa/capabilities/dynamic.py index e7e6594a..2605f578 100644 --- a/capa/capabilities/dynamic.py +++ b/capa/capabilities/dynamic.py @@ -177,7 +177,8 @@ def find_thread_capabilities( span_matcher = SpanOfCallsMatcher(ruleset) call_count = 0 - for call_count, ch in enumerate(extractor.get_calls(ph, th)): # noqa: B007 + for ch in extractor.get_calls(ph, th): + call_count += 1 call_capabilities = find_call_capabilities(ruleset, extractor, ph, th, ch) for feature, vas in call_capabilities.features.items(): features[feature].update(vas)