This is for forbidden function check
|
# @todo Check difference between Darwin and Linux `nm' |
|
result = subprocess.run(['nm', project_path + '/' + binary], |
|
stdout=subprocess.PIPE, |
|
stderr=subprocess.STDOUT).stdout.decode('utf-8') |
|
for line in result.splitlines(): |
|
if "U " in line: |
|
functions_called.append(re.sub(' +', ' ', line)) |
|
sys_calls = {func.replace(' U ', '') for func in functions_called} |
|
sys_calls = [item for item in sys_calls if not item.startswith("ft_")] |
|
extra_function_call = [item for item in sys_calls if item not in authorized_func] |
|
with open(root_path + "/.myforbiddenfunctions", 'w+') as file: |
|
for item in extra_function_call: |
|
# This is to ignore functions like `__stack_chk_fail' |
|
if not item.startswith("__"): |
|
file.write("You should justify the use of this function: `{}'\n".format(item)) |
This is for forbidden function check
42PyChecker/PyChecker/utils/forbidden_functions.py
Lines 20 to 34 in 985e824