Skip to content

Commit 96de437

Browse files
authored
Fix binskim warnings for mac, linux, and pyd files (#1856)
* Add controlflow guard to linux, mac, and pyd files * Fix manylinux too * Fix pydevd bits too
1 parent ed9f294 commit 96de437

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

src/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/compile_linux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ case $ARCH in
88
esac
99

1010
SRC="$(dirname "$0")/.."
11-
g++ -std=c++11 -shared -fPIC -nostartfiles $SRC/linux_and_mac/attach.cpp -o $SRC/attach_linux_$SUFFIX.so
11+
g++ -std=c++11 -shared -fPIC -D_FORTIFY_SOURCE=2 -nostartfiles $SRC/linux_and_mac/attach.cpp -o $SRC/attach_linux_$SUFFIX.so
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
set -e
22
SRC="$(dirname "$0")/.."
3-
g++ -fPIC -D_REENTRANT -std=c++11 -arch x86_64 -c $SRC/linux_and_mac/attach.cpp -o $SRC/attach_x86_64.o
3+
g++ -fPIC -D_REENTRANT -std=c++11 -D_FORTIFY_SOURCE=2 -arch x86_64 -c $SRC/linux_and_mac/attach.cpp -o $SRC/attach_x86_64.o
44
g++ -dynamiclib -nostartfiles -arch x86_64 -lc $SRC/attach_x86_64.o -o $SRC/attach_x86_64.dylib

src/debugpy/_vendored/pydevd/pydevd_attach_to_process/linux_and_mac/compile_manylinux.cmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
:: [wsl2]
66
:: kernelCommandLine = vsyscall=emulate
77

8-
docker run --rm -v %~dp0/..:/src quay.io/pypa/manylinux1_x86_64 g++ -std=c++11 -shared -o /src/attach_linux_amd64.so -fPIC -nostartfiles /src/linux_and_mac/attach.cpp
8+
docker run --rm -v %~dp0/..:/src quay.io/pypa/manylinux1_x86_64 g++ -std=c++11 -D_FORTIFY_SOURCE=2 -shared -o /src/attach_linux_amd64.so -fPIC -nostartfiles /src/linux_and_mac/attach.cpp
99

10-
docker run --rm -v %~dp0/..:/src quay.io/pypa/manylinux1_i686 g++ -std=c++11 -shared -o /src/attach_linux_x86.so -fPIC -nostartfiles /src/linux_and_mac/attach.cpp
10+
docker run --rm -v %~dp0/..:/src quay.io/pypa/manylinux1_i686 g++ -std=c++11 -D_FORTIFY_SOURCE=2 -shared -o /src/attach_linux_x86.so -fPIC -nostartfiles /src/linux_and_mac/attach.cpp

src/debugpy/_vendored/pydevd/setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def make_rel(p):
170170
# uncomment to generate pdbs for visual studio.
171171
# extra_compile_args=["-Zi", "/Od"]
172172
# extra_link_args=["-debug"]
173+
extra_compile_args = ["/guard:cf"]
174+
extra_link_args = ["/guard:cf", "/DYNAMICBASE"]
173175

174176
kwargs = {}
175177
if extra_link_args:

src/debugpy/_vendored/pydevd/setup_pydevd_cython.py

+2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ def build_extension(dir_name, extension_name, target_pydevd_name, force_cython,
207207
# uncomment to generate pdbs for visual studio.
208208
# extra_compile_args=["-Zi", "/Od"]
209209
# extra_link_args=["-debug"]
210+
extra_compile_args = ["/guard:cf"]
211+
extra_link_args = ["/guard:cf", "/DYNAMICBASE"]
210212
if IS_PY311_ONWARDS:
211213
# On py311 we need to add the CPython include folder to the include path.
212214
extra_compile_args.append("-I%s\\include\\CPython" % sys.exec_prefix)

0 commit comments

Comments
 (0)