Skip to content

fix(filter): don't drop memory-safety findings in .hpp/.cxx/.hh C++ files#110

Closed
vidigoat wants to merge 1 commit into
anthropics:mainfrom
vidigoat:fix/memory-safety-cpp-extensions
Closed

fix(filter): don't drop memory-safety findings in .hpp/.cxx/.hh C++ files#110
vidigoat wants to merge 1 commit into
anthropics:mainfrom
vidigoat:fix/memory-safety-cpp-extensions

Conversation

@vidigoat

@vidigoat vidigoat commented Jun 3, 2026

Copy link
Copy Markdown

Problem

HardExclusionRules.get_exclusion_reason (claudecode/findings_filter.py) excludes memory-safety findings as "not applicable" for any file whose extension is not in this set:

c_cpp_extensions = {'.c', '.cc', '.cpp', '.h'}

That set omits the common C++ extensions .hpp, .hh, .cxx, .hxx, .c++, .h++ and template-implementation extensions (.ipp, .tpp, .inl). .hpp is the dominant C++ header extension, and because headers hold inline functions and templates, they are exactly where memory-safety bugs (buffer overflow, use-after-free, OOB) tend to live. So genuine memory-safety findings in real C++ files were being silently dropped before they could be reported.

This contradicts the documented intent of the existing test test_memory_safety_not_excluded_cpp_files ("memory safety issues are NOT excluded in C/C++ files").

Reproduction

get_exclusion_reason on a buffer-overflow finding in object.hpp or a use-after-free in engine.cxx returns "Memory safety finding in non-C/C++ code (not applicable)" instead of None (keep). On main the new test fails for exactly these cases.

Fix

Extend c_cpp_extensions to include the standard C++ header/source and template-impl extensions.

Tests

Added test_memory_safety_not_excluded_cpp_header_and_alt_extensions covering .hpp, .cxx, .hh, .hxx, .ipp. It fails on main and passes with the fix; the full claudecode suite (174 tests) stays green, including the existing case-insensitive and non-C/C++ exclusion tests (a .py memory-safety finding is still correctly excluded).


Authored with AI assistance (Claude); bug reproduced, fix written, and the full test suite verified locally before submitting.

…iles

HardExclusionRules.get_exclusion_reason excluded memory-safety findings for
any file whose extension was not in {.c, .cc, .cpp, .h}. That set omits the
common C++ extensions .hpp, .hh, .cxx, .hxx, .c++, .h++ (and template-impl
.ipp/.tpp/.inl). .hpp is the dominant C++ header extension and, holding inline
and template code, is exactly where memory-safety bugs live, so real findings
there were silently dropped. This contradicts the documented intent of
test_memory_safety_not_excluded_cpp_files. Extend the extension set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vidigoat vidigoat closed this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant