From 86a769ca0b6820ab9151f2165205c72e4497ac57 Mon Sep 17 00:00:00 2001 From: Ajin Abraham Date: Tue, 28 Apr 2020 15:01:45 -0400 Subject: [PATCH] Hotfix psutil fix + QA --- .dockerignore | 1 + MobSF/utils.py | 23 ++++++++++------------- requirements.txt | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.dockerignore b/.dockerignore index 84dc451a..2c9d7ab1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ .git .github +.gitmodules .tox .dockerignore .sonarcloud.properties diff --git a/MobSF/utils.py b/MobSF/utils.py index 2361777e..4207bcc7 100755 --- a/MobSF/utils.py +++ b/MobSF/utils.py @@ -414,15 +414,9 @@ def get_random(): def find_process_by(name): """Return a set of process path matching name.""" proc = set() - try: - for p in psutil.process_iter(attrs=['name', 'exe', 'cmdline']): - if (name == p.info['name'] or p.info['exe'] - and os.path.basename(p.info['exe']) == name - or p.info['cmdline'] and p.info['cmdline'][0] == name): - proc.add(p.info['exe']) - except FileNotFoundError: - # Bug in OSX 10.6 ? - pass + for p in psutil.process_iter(attrs=['name']): + if (name == p.info['name']): + proc.add(p.exe()) return proc @@ -446,6 +440,10 @@ def get_device(): def get_adb(): """Get ADB binary path.""" try: + adb_loc = None + adb_msg = ('Set adb path, ADB_BINARY in MobSF/settings.py' + ' with same adb binary used' + ' by Genymotion VM/Emulator AVD.') global ADB_PATH if (len(settings.ADB_BINARY) > 0 and is_file_exists(settings.ADB_BINARY)): @@ -458,15 +456,14 @@ def get_adb(): else: adb_loc = find_process_by('adb') if len(adb_loc) > 1: - logger.warning('Multiple ADB locations found. ' - 'Set adb path, ADB_BINARY in MobSF/settings.py' - ' with same adb binary used' - ' by Genymotion VM/Emulator AVD.') + logger.warning('Multiple ADB locations found. %s', adb_msg) logger.warning(adb_loc) if adb_loc: ADB_PATH = adb_loc.pop() return ADB_PATH except Exception: + if not adb_loc: + logger.warning('Cannot find adb! %s', adb_msg) logger.exception('Getting ADB Location') finally: if ADB_PATH: diff --git a/requirements.txt b/requirements.txt index d0f057ec..b28b58a5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,6 +21,6 @@ distro==1.5.0 IP2Location==8.4.1 # Do not update the following apkid==2.1.0 -cryptography<2.5,>=2.1.4 # pyup: ignore -pyOpenSSL==19.0.0 # pyup: ignore +cryptography<3.0,>=2.9 # pyup: ignore +pyOpenSSL<19.2,>=19.1.0 # pyup: ignore http-tools==1.1.1