mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
scripts: add MACHO NX check to security-check.py
This commit is contained in:
parent
1a4e9f32ef
commit
edaca2dd12
2 changed files with 12 additions and 0 deletions
|
|
@ -197,6 +197,15 @@ def check_MACHO_NOUNDEFS(executable) -> bool:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def check_MACHO_NX(executable) -> bool:
|
||||||
|
'''
|
||||||
|
Check for no stack execution
|
||||||
|
'''
|
||||||
|
flags = get_MACHO_executable_flags(executable)
|
||||||
|
if 'ALLOW_STACK_EXECUTION' in flags:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
CHECKS = {
|
CHECKS = {
|
||||||
'ELF': [
|
'ELF': [
|
||||||
('PIE', check_ELF_PIE),
|
('PIE', check_ELF_PIE),
|
||||||
|
|
@ -212,6 +221,7 @@ CHECKS = {
|
||||||
'MACHO': [
|
'MACHO': [
|
||||||
('PIE', check_MACHO_PIE),
|
('PIE', check_MACHO_PIE),
|
||||||
('NOUNDEFS', check_MACHO_NOUNDEFS),
|
('NOUNDEFS', check_MACHO_NOUNDEFS),
|
||||||
|
('NX', check_MACHO_NX)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@ class TestSecurityChecks(unittest.TestCase):
|
||||||
cc = 'clang'
|
cc = 'clang'
|
||||||
write_testcode(source)
|
write_testcode(source)
|
||||||
|
|
||||||
|
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace', '-Wl,-allow_stack_execute']),
|
||||||
|
(1, executable+': failed PIE NOUNDEFS NX'))
|
||||||
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace']),
|
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie','-Wl,-flat_namespace']),
|
||||||
(1, executable+': failed PIE NOUNDEFS'))
|
(1, executable+': failed PIE NOUNDEFS'))
|
||||||
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie']),
|
self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-no_pie']),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue