Skip to content

Commit 6234b62

Browse files
committed
Minor patch
1 parent 2e28b70 commit 6234b62

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

lib/core/common.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,12 @@ def extractErrorMessage(page):
29552955

29562956
if match:
29572957
candidate = htmlUnescape(match.group("result")).replace("<br>", "\n").strip()
2958-
if candidate and (1.0 * len(re.findall(r"[^A-Za-z,. ]", candidate)) / len(candidate) > MIN_ERROR_PARSING_NON_WRITING_RATIO):
2958+
# Note: only the generic '(fatal|error|warning|exception): ...' regexes can capture
2959+
# arbitrary prose, so guard those with the non-writing-char ratio; the specific
2960+
# DBMS-signature regexes (e.g. MSSQL 'Unclosed quotation mark ...') are definitive and
2961+
# must not be discarded just because the message happens to read like plain text
2962+
generic = "(fatal|error|warning|exception)" in regex
2963+
if candidate and (not generic or 1.0 * len(re.findall(r"[^A-Za-z,. ]", candidate)) / len(candidate) > MIN_ERROR_PARSING_NON_WRITING_RATIO):
29592964
retVal = candidate
29602965
break
29612966

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from thirdparty import six
2121

2222
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
23-
VERSION = "1.10.7.141"
23+
VERSION = "1.10.7.142"
2424
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2525
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2626
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

tests/test_common.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,16 @@ def test_extract_error_message_oracle(self):
16231623
def test_extract_error_message_none_for_plain(self):
16241624
self.assertIsNone(extractErrorMessage("Warning: This is only a dummy foobar test"))
16251625

1626+
def test_extract_error_message_prose_like_dbms_signature(self):
1627+
# a specific DBMS signature must be extracted even when it reads like plain text (few
1628+
# non-writing chars) - the non-writing-char ratio guards only the generic keyword regexes
1629+
page = "Microsoft OLE DB Provider for SQL Server error '80040e14' Unclosed quotation mark after the character string ''."
1630+
self.assertEqual(extractErrorMessage(page), "Unclosed quotation mark after the character string ''.")
1631+
1632+
def test_extract_error_message_generic_prose_still_rejected(self):
1633+
# the generic '(fatal|error|warning): ...' path must still drop natural-language prose
1634+
self.assertIsNone(extractErrorMessage("Error: everything is working fine and nothing is wrong here"))
1635+
16261636
def test_extract_error_message_non_string(self):
16271637
self.assertIsNone(extractErrorMessage(None))
16281638

0 commit comments

Comments
 (0)