@@ -95,20 +95,16 @@ def test_PE(self):
95
95
cxx = determine_wellknown_cmd ('CXX' , 'x86_64-w64-mingw32-g++' )
96
96
write_testcode (source )
97
97
98
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,--disable-nxcompat' ,'-Wl,--disable-reloc-section' ,'-Wl,--disable-dynamicbase' ,'-Wl,--disable-high-entropy-va' ,'-no-pie' ,'-fno-PIE' ,'-fno-stack-protector' ]),
99
- (1 , executable + ': failed PIE DYNAMIC_BASE HIGH_ENTROPY_VA NX RELOC_SECTION CONTROL_FLOW Canary' ))
100
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,--nxcompat' ,'-Wl,--disable-reloc-section' ,'-Wl,--disable-dynamicbase' ,'-Wl,--disable-high-entropy-va' ,'-no-pie' ,'-fno-PIE' ,'-fstack-protector-all' , '-lssp' ]),
101
- (1 , executable + ': failed PIE DYNAMIC_BASE HIGH_ENTROPY_VA RELOC_SECTION CONTROL_FLOW' ))
102
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,--nxcompat' ,'-Wl,--enable-reloc-section' ,'-Wl,--disable-dynamicbase' ,'-Wl,--disable-high-entropy-va' ,'-no-pie' ,'-fno-PIE' ,'-fstack-protector-all' , '-lssp' ]),
103
- (1 , executable + ': failed PIE DYNAMIC_BASE HIGH_ENTROPY_VA CONTROL_FLOW' ))
104
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,--nxcompat' ,'-Wl,--enable-reloc-section' ,'-Wl,--disable-dynamicbase' ,'-Wl,--disable-high-entropy-va' ,'-pie' ,'-fPIE' ,'-fstack-protector-all' , '-lssp' ]),
105
- (1 , executable + ': failed PIE DYNAMIC_BASE HIGH_ENTROPY_VA CONTROL_FLOW' )) # -pie -fPIE does nothing unless --dynamicbase is also supplied
106
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,--nxcompat' ,'-Wl,--enable-reloc-section' ,'-Wl,--dynamicbase' ,'-Wl,--disable-high-entropy-va' ,'-pie' ,'-fPIE' ,'-fstack-protector-all' , '-lssp' ]),
107
- (1 , executable + ': failed HIGH_ENTROPY_VA CONTROL_FLOW' ))
108
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,--nxcompat' ,'-Wl,--enable-reloc-section' ,'-Wl,--dynamicbase' ,'-Wl,--high-entropy-va' ,'-pie' ,'-fPIE' ,'-fstack-protector-all' , '-lssp' ]),
109
- (1 , executable + ': failed CONTROL_FLOW' ))
110
- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,--nxcompat' ,'-Wl,--enable-reloc-section' ,'-Wl,--dynamicbase' ,'-Wl,--high-entropy-va' ,'-pie' ,'-fPIE' , '-fcf-protection=full' ,'-fstack-protector-all' , '-lssp' ]),
111
- (0 , '' ))
98
+ pass_flags = ['-Wl,--nxcompat' , '-Wl,--enable-reloc-section' , '-Wl,--dynamicbase' , '-Wl,--high-entropy-va' , '-pie' , '-fPIE' , '-fcf-protection=full' , '-fstack-protector-all' , '-lssp' ]
99
+
100
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-fno-stack-protector' ]), (1 , executable + ': failed CANARY' ))
101
+ # https://github.com/lief-project/LIEF/issues/1076 - in future, we could test this individually.
102
+ # self.assertEqual(call_security_check(cxx, source, executable, pass_flags + ['-Wl,--disable-reloc-section']), (1, executable + ': failed RELOC_SECTION'))
103
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,--disable-nxcompat' ]), (1 , executable + ': failed NX' ))
104
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,--disable-dynamicbase' ]), (1 , executable + ': failed PIE DYNAMIC_BASE HIGH_ENTROPY_VA' )) # -pie -fPIE does nothing without --dynamicbase
105
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,--disable-high-entropy-va' ]), (1 , executable + ': failed HIGH_ENTROPY_VA' ))
106
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-fcf-protection=none' ]), (1 , executable + ': failed CONTROL_FLOW' ))
107
+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags ), (0 , '' ))
112
108
113
109
clean_files (source , executable )
114
110
0 commit comments