From 2c3ef39e24025f596b12f59fbc09c69c483a82e5 Mon Sep 17 00:00:00 2001 From: JohnE Date: Fri, 29 Jan 2016 13:24:44 -0800 Subject: [PATCH] MOD: code cleanup to be more consistant with print statements and exception handing when calling the API --- dbfp.py | 18 +++++++++--------- docs/devnotes | 34 ++++++++++++++++++++++++++++++++++ libs/fingerprint.py | 3 ++- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/dbfp.py b/dbfp.py index 478748f..337595e 100644 --- a/dbfp.py +++ b/dbfp.py @@ -27,11 +27,10 @@ def compareFingerprint(file_in, file_json): # def createFingerprint(file_in, verbose, app_name, app_ver, notes): + print "Reading database file: {}".format(file_in) db = FingerprintDB() retVal = db.scanDBFile(file_in) - print "GOT HERE BITCHES: file_in=={}, retVal=={}".format(file_in, str(retVal)) - if (retVal > 0): if verbose: db.debugFingerprint() @@ -41,7 +40,8 @@ def createFingerprint(file_in, verbose, app_name, app_ver, notes): db.setAppVer(app_ver) if notes: db.setNotes(notes) - db.writeFingerprint() + filename = db.writeFingerprint() + print "Fingerprint generated: {}".format(filename) else: print db.getErrorString(retVal) @@ -81,16 +81,16 @@ def androidPull(): return if (not mkdir(BASE_DIR)): - logging.error("ERROR creating directory: {}".format(BASE_DIR)) + print "ERROR creating directory: {}".format(BASE_DIR) return if (not mkdir(FP_BASE_DIR)): - logging.error("ERROR creating directory: {}".format(FP_BASE_DIR)) + print "ERROR creating directory: {}".format(FP_BASE_DIR) return dir_names = ap.getAppsDir() for dir_name in dir_names: - fq_dir = BASE_DIR + os.path.sep + dir_name ap.pullApp(BASE_DIR, dir_name) + fq_dir = BASE_DIR + os.path.sep + dir_name __createFingerprint(fq_dir, FP_BASE_DIR, dir_name) # @@ -99,12 +99,12 @@ def androidData(data_dir): try: dirs = os.listdir(data_dir) except Exception, ex: - print "ERROR opening Android data directory [{}]\n{}".format(data_dir, ex) + print "ERROR opening Android Data Directory (-dd): {}\n{}".format(data_dir, ex) return out_dir = FP_BASE_DIR + "_" + ToolBox.getTimestampStr() if (not mkdir(out_dir)): - logging.error("ERROR creating directory: {}".format(FP_BASE_DIR)) + print "ERROR creating directory: {}".format(FP_BASE_DIR) return for ddir in dirs: @@ -143,7 +143,7 @@ def mkdir(fdir): check_call(["mkdir", fdir]) retval = True except: - logging.error('ERROR: problem creating directory "{}"'.format(fdir)) + print 'ERROR: problem creating directory "{}"'.format(fdir) return retval # diff --git a/docs/devnotes b/docs/devnotes index 6362a39..f8c4e7b 100644 --- a/docs/devnotes +++ b/docs/devnotes @@ -1,6 +1,17 @@ [[ TODO ]] +[ Regression Testing ] +android pull, data dir, comparison + +[ Pull Apps from Internet ] +http://www.aptoide.com/webservices/docs/2/getApkInfo + +[ Static Code Analysis ] +AFL (python port) +http://lcamtuf.coredump.cx/afl/ +https://bitbucket.org/jwilk/python-afl/src/af96425344b992ba6b8ea2c446e8eeea5dc43ccd/doc/?at=default + [ Android Pull ] -test android pull (regression testing) -try VM android pull? @@ -61,3 +72,26 @@ [[ Errors ]] +file is encrypted or is not a database +WARN: field definition not recognized: "[version] INTEGER" +WARN: field definition not recognized: "[corpus_name] STRING PRIMARY KEY" +WARN: field definition not recognized: "[incarnation] STRING" +WARN: field definition not recognized: "[seqno_table_complete] INTEGER" +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database +file is encrypted or is not a database + diff --git a/libs/fingerprint.py b/libs/fingerprint.py index f6f6808..e7a6f1a 100644 --- a/libs/fingerprint.py +++ b/libs/fingerprint.py @@ -89,7 +89,6 @@ class FingerprintDB: return try: - print "FILE=={}".format(self.filein) filename = ToolBox.getTimestampFilename(self.filein) fh = open(filename, "w") try: @@ -100,6 +99,8 @@ class FingerprintDB: logging.error(ex) raise FingerprintWrite("Problem writing the fingerprint to a file, file=={}".format(filename)) + return filename + # def writeFingerprintFile(self, filename): if (not self.init):