Skip to content

Commit ab92638

Browse files
Merge pull request #2031 from StellaHuang95/stellahuang/tsa-2816219-flawfinder-cython-read-loop
Fix TSA #2816219: suppress Flawfinder false positive on Cython read-loop iterator (_pydevd_sys_monitoring_cython.c)
1 parent 12bd4fe commit ab92638

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/debugpy/_vendored/pydevd/_pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/debugpy/_vendored/pydevd/setup_pydevd_cython.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ def build_extension(dir_name, extension_name, target_pydevd_name, force_cython,
177177
c_file_contents = c_file_contents.replace(r"_pydevd_bundle\\pydevd_cython.pxd", "_pydevd_bundle/pydevd_cython.pxd")
178178
c_file_contents = c_file_contents.replace(r"_pydevd_bundle\\pydevd_cython.pyx", "_pydevd_bundle/pydevd_cython.pyx")
179179

180+
# Suppress Flawfinder false positive (CWE-120/CWE-20) in the
181+
# Cython 3.x ModuleStateLookup boilerplate (`__Pyx_State_ConvertFromInterpIdAsIndex`):
182+
# `read` is a bounded pointer iterator (not POSIX read()), and the loop is
183+
# guarded by `read < end` where `end = read + data->count`.
184+
c_file_contents = c_file_contents.replace(
185+
" for (; read<end; ++read) {\n",
186+
" for (; read<end; ++read) { /* Flawfinder: ignore */\n",
187+
)
188+
180189
with open(c_file, "w") as stream:
181190
stream.write(c_file_contents)
182191

0 commit comments

Comments
 (0)