@@ -59,33 +59,20 @@ def test_ELF(self):
5959 arch = get_arch (cxx , source , executable )
6060
6161 if arch == lief .ARCHITECTURES .X86 :
62- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-zexecstack' ,'-Wl,-znorelro' ,'-no-pie' ,'-fno-PIE' , '-Wl,-z,separate-code' ]),
63- (1 , executable + ': failed PIE NX RELRO CONTROL_FLOW' ))
64- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-znorelro' ,'-no-pie' ,'-fno-PIE' , '-Wl,-z,separate-code' ]),
65- (1 , executable + ': failed PIE RELRO CONTROL_FLOW' ))
66- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-znorelro' ,'-no-pie' ,'-fno-PIE' , '-Wl,-z,separate-code' ]),
67- (1 , executable + ': failed PIE RELRO CONTROL_FLOW' ))
68- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-znorelro' ,'-pie' ,'-fPIE' , '-Wl,-z,separate-code' ]),
69- (1 , executable + ': failed RELRO CONTROL_FLOW' ))
70- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-zrelro' ,'-Wl,-z,now' ,'-pie' ,'-fPIE' , '-Wl,-z,noseparate-code' ]),
71- (1 , executable + ': failed separate_code CONTROL_FLOW' ))
72- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-zrelro' ,'-Wl,-z,now' ,'-pie' ,'-fPIE' , '-Wl,-z,separate-code' ]),
73- (1 , executable + ': failed CONTROL_FLOW' ))
74- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-zrelro' ,'-Wl,-z,now' ,'-pie' ,'-fPIE' , '-Wl,-z,separate-code' , '-fcf-protection=full' ]),
75- (0 , '' ))
62+ pass_flags = ['-Wl,-znoexecstack' , '-Wl,-zrelro' , '-Wl,-z,now' , '-pie' , '-fPIE' , '-Wl,-z,separate-code' , '-fcf-protection=full' ]
63+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-zexecstack' ]), (1 , executable + ': failed NX' ))
64+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-no-pie' ,'-fno-PIE' ]), (1 , executable + ': failed PIE' ))
65+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-znorelro' ]), (1 , executable + ': failed RELRO' ))
66+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-z,noseparate-code' ]), (1 , executable + ': failed SEPARATE_CODE' ))
67+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-fcf-protection=none' ]), (1 , executable + ': failed CONTROL_FLOW' ))
68+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags ), (0 , '' ))
7669 else :
77- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-zexecstack' ,'-Wl,-znorelro' ,'-no-pie' ,'-fno-PIE' , '-Wl,-z,separate-code' ]),
78- (1 , executable + ': failed PIE NX RELRO' ))
79- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-znorelro' ,'-no-pie' ,'-fno-PIE' , '-Wl,-z,separate-code' ]),
80- (1 , executable + ': failed PIE RELRO' ))
81- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-znorelro' ,'-no-pie' ,'-fno-PIE' , '-Wl,-z,separate-code' ]),
82- (1 , executable + ': failed PIE RELRO' ))
83- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-znorelro' ,'-pie' ,'-fPIE' , '-Wl,-z,separate-code' ]),
84- (1 , executable + ': failed RELRO' ))
85- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-zrelro' ,'-Wl,-z,now' ,'-pie' ,'-fPIE' , '-Wl,-z,noseparate-code' ]),
86- (1 , executable + ': failed separate_code' ))
87- self .assertEqual (call_security_check (cxx , source , executable , ['-Wl,-znoexecstack' ,'-Wl,-zrelro' ,'-Wl,-z,now' ,'-pie' ,'-fPIE' , '-Wl,-z,separate-code' ]),
88- (0 , '' ))
70+ pass_flags = ['-Wl,-znoexecstack' , '-Wl,-zrelro' , '-Wl,-z,now' , '-pie' , '-fPIE' , '-Wl,-z,separate-code' ]
71+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-zexecstack' ]), (1 , executable + ': failed NX' ))
72+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-no-pie' ,'-fno-PIE' ]), (1 , executable + ': failed PIE' ))
73+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-znorelro' ]), (1 , executable + ': failed RELRO' ))
74+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags + ['-Wl,-z,noseparate-code' ]), (1 , executable + ': failed SEPARATE_CODE' ))
75+ self .assertEqual (call_security_check (cxx , source , executable , pass_flags ), (0 , '' ))
8976
9077 clean_files (source , executable )
9178
0 commit comments