important bug fix and minor code restyling

This commit is contained in:
Bernardo Damele 2013-02-07 14:05:57 +00:00
parent b477c56b52
commit 13b424a63c

View File

@ -20,7 +20,7 @@ sys.path.append(os.path.normpath("%s/../../" % os.path.dirname(inspect.getfile(i
from lib.core.revision import getRevisionNumber from lib.core.revision import getRevisionNumber
TIME = time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime()) START_TIME = time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime())
SQLMAP_HOME = "/opt/sqlmap" SQLMAP_HOME = "/opt/sqlmap"
REVISION = getRevisionNumber() REVISION = getRevisionNumber()
@ -30,7 +30,7 @@ SMTP_TIMEOUT = 30
FROM = "regressiontest@sqlmap.org" FROM = "regressiontest@sqlmap.org"
#TO = "dev@sqlmap.org" #TO = "dev@sqlmap.org"
TO = ["bernardo.damele@gmail.com", "miroslav.stampar@gmail.com"] TO = ["bernardo.damele@gmail.com", "miroslav.stampar@gmail.com"]
SUBJECT = "Regression test on %s using revision %s" % (TIME, REVISION) SUBJECT = "Regression test on %s using revision %s" % (START_TIME, REVISION)
def prepare_email(content): def prepare_email(content):
global FROM global FROM
@ -71,16 +71,14 @@ def main():
test_counts = [] test_counts = []
attachments = {} attachments = {}
proc = subprocess.Popen("cd /opt/sqlmap/ ; python /opt/sqlmap/sqlmap.py --update", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) updateproc = subprocess.Popen("cd /opt/sqlmap/ ; python /opt/sqlmap/sqlmap.py --update", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc.wait() stdout, stderr = updateproc.communicate()
stdout, stderr = proc.communicate()
if stderr: if stderr:
failure_email("Update of sqlmap failed with error:\n\n%s" % stderr) failure_email("Update of sqlmap failed with error:\n\n%s" % stderr)
proc = subprocess.Popen("python /opt/sqlmap/sqlmap.py --live-test", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) regressionproc = subprocess.Popen("python /opt/sqlmap/sqlmap.py --live-test", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc.wait() stdout, stderr = regressionproc.communicate()
stdout, stderr = proc.communicate()
if stderr: if stderr:
failure_email("Execution of regression test failed with error:\n\n%s" % stderr) failure_email("Execution of regression test failed with error:\n\n%s" % stderr)
@ -149,12 +147,12 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
log_fd = open("/tmp/sqlmapregressiontest.log", "wb") log_fd = open("/tmp/sqlmapregressiontest.log", "wb")
log_fd.write("Regression test started at %s\n" % TIME) log_fd.write("Regression test started at %s\n" % START_TIME)
try: try:
main() main()
except Exception, e: except Exception, e:
log_fd.write("An exception has occurred:\n%s" % str(traceback.format_exc())) log_fd.write("An exception has occurred:\n%s" % str(traceback.format_exc()))
log_fd.write("Regression test finished at %s\n\n" % TIME) log_fd.write("Regression test finished at %s\n\n" % time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime())
log_fd.close() log_fd.close()