From 588a9c5b2b5fcadaffefe101357b38c8beb7e209 Mon Sep 17 00:00:00 2001 From: Raman Arora Date: Thu, 26 Mar 2020 07:28:48 -0400 Subject: [PATCH] Call TSK util methods to validate phone/email. --- InternalPythonModules/android/general.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/InternalPythonModules/android/general.py b/InternalPythonModules/android/general.py index f0dfb05dfd..daa789a57c 100644 --- a/InternalPythonModules/android/general.py +++ b/InternalPythonModules/android/general.py @@ -18,7 +18,8 @@ limitations under the License. """ -import re +from org.sleuthkit.datamodel import TskCoreException +from org.sleuthkit.datamodel import CommunicationsUtils MODULE_NAME = "Android Analyzer" @@ -45,10 +46,18 @@ def appendAttachmentList(msgBody, attachmentsList): Checks if the given string might be a phone number. """ def isValidPhoneNumer(data): - return bool(re.match(r"^\+?[0-9()\-\s]+$", data)) + try: + return CommunicationsUtils.normalizePhoneNum(data) is not None + except TskCoreException as ex: + return False + """ Checks if the given string is a valid email address. """ def isValidEmailAddress(data): - return bool(re.match(r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)", data)) + try: + return CommunicationsUtils.normalizeEmailAddress(data) is not None + except TskCoreException as ex: + return False +