Skip to content

Commit b3d9f1a

Browse files
committedJan 18, 2013
more impovements, issue #311
1 parent 738ccb6 commit b3d9f1a

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed
 

‎extra/shutils/regressiontest.py

+25-17
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,55 @@
1919
SMTP_PORT = 25
2020
SMTP_TIMEOUT = 30
2121
FROM = "regressiontest@sqlmap.org"
22-
TO = "dev@sqlmap.org"
23-
SUBJECT = "Regression test results on on %s" % TIME
22+
#TO = "dev@sqlmap.org"
23+
TO = "bernardo.damele@gmail.com"
24+
SUBJECT = "Regression test results on %s" % TIME
2425
CONTENT = ""
2526
TEST_COUNTS = []
27+
ATTACHMENTS = {}
2628

2729
command_line = "cd ../../ ; rm -f $REGRESSION_FILE ; python sqlmap.py --live-test --run-case 'Invalid logic'"
2830
proc = subprocess.Popen(command_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2931
proc.wait()
3032
stdout, stderr = proc.communicate()
31-
failed_tests = re.findall("running live test case: (.+?) \((\d+)\/\d+\)[\r]*\n(.+?)test failed (.*?)at parsing item: (.+) \- scan folder is (\/.+)[\r]*\n", stdout, re.I | re.M)
33+
failed_tests = re.findall("running live test case: (.+?) \((\d+)\/\d+\)[\r]*\n.+test failed (at parsing item \"(.+)\" )?\- scan folder: (\/.+) \- traceback: (.*?)( - SQL injection not detected)?[\r]*\n", stdout, re.M)
3234

3335
for failed_test in failed_tests:
3436
title = failed_test[0]
35-
test_count = failed_test[1]
36-
error = True if "the test did not identify the SQL injection" in failed_test[2] else False
37-
traceback = failed_test[2] or None
38-
parse = failed_test[3]
37+
test_count = int(failed_test[1])
38+
parse = failed_test[3] if failed_test[3] else None
3939
output_folder = failed_test[4]
40+
traceback = failed_test[5]
41+
detection = True if failed_test[6] else False
4042

4143
TEST_COUNTS.append(test_count)
4244

4345
console_output_fd = codecs.open(os.path.join(output_folder, "console_output"), "rb", "utf8")
4446
console_output = console_output_fd.read()
4547
console_output_fd.close()
4648

47-
if error is False:
48-
log_fd = codecs.open(os.path.join(output_folder, "debiandev", "log"), "rb", "utf8")
49-
log = log_fd.read()
50-
log_fd.close()
49+
ATTACHMENTS[test_count] = str(console_output)
50+
51+
log_fd = codecs.open(os.path.join(output_folder, "debiandev", "log"), "rb", "utf8")
52+
log = log_fd.read()
53+
log_fd.close()
5154

5255
if traceback:
5356
traceback_fd = codecs.open(os.path.join(output_folder, "traceback"), "rb", "utf8")
5457
traceback = traceback_fd.read()
5558
traceback_fd.close()
5659

57-
CONTENT += "Failed test case '%s' at parsing: %s:\n\n" % (title, parse)
60+
CONTENT += "Failed test case '%s'" % title
5861

59-
if error is False:
62+
if parse:
63+
CONTENT += " at parsing: %s:\n\n" % parse
6064
CONTENT += "### LOG FILE:\n\n"
6165
CONTENT += "%s\n" % log
62-
else:
63-
CONTENT += "### CONSOLE OUTPUT\n\n"
64-
CONTENT += "%s\n" % str(console_output)
66+
elif not detection:
67+
CONTENT += " - SQL injection not detected\n\n"
6568

6669
if traceback:
67-
CONTENT += "### TRACEBACK:\n"
70+
CONTENT += "### TRACEBACK:\n\n"
6871
CONTENT += "%s\n" % str(traceback)
6972

7073
CONTENT += "\n#######################################\n\n"
@@ -76,6 +79,11 @@
7679
msg["From"] = FROM
7780
msg["To"] = TO
7881

82+
for test_count, attachment in ATTACHMENTS:
83+
attachment = MIMEText(attachment)
84+
attachment.add_header('Content-Disposition', 'attachment', filename="%d.console_output.txt" % test_count)
85+
msg.attach(attachment)
86+
7987
s = smtplib.SMTP(host=SMTP_SERVER, port=SMTP_PORT, timeout=SMTP_TIMEOUT)
8088
#s.set_debuglevel(1)
8189
s.sendmail(FROM, TO, msg.as_string())

0 commit comments

Comments
 (0)
Please sign in to comment.