diff --git a/mobsf/StaticAnalyzer/views/android/code_analysis.py b/mobsf/StaticAnalyzer/views/android/code_analysis.py index e94dbf02a6..2b1cd702c0 100755 --- a/mobsf/StaticAnalyzer/views/android/code_analysis.py +++ b/mobsf/StaticAnalyzer/views/android/code_analysis.py @@ -1,6 +1,7 @@ # -*- coding: utf_8 -*- """Module holding the functions for code analysis.""" +import os import logging import tempfile from pathlib import Path @@ -37,9 +38,10 @@ def get_perm_rules(perm_rules, android_permissions): dynamic_rules.append(p) rules = yaml.dump(dynamic_rules) if rules: - tmp = tempfile.NamedTemporaryFile(mode='w', delete=False) + tmp = tempfile.NamedTemporaryFile( + mode='w', + delete=False) tmp.write(rules) - tmp.flush() tmp.close() return tmp except Exception: @@ -99,10 +101,7 @@ def code_analysis(app_dir, typ, manifest_file, android_permissions): [src], {})) logger.info('Android Permission Mapping Completed') - try: - os.remove(rule_file.name) - except: - pass + os.unlink(rule_file.name) # NIAP Scan niap_findings = niap_scan( niap_rules.as_posix(),