mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-08-04 06:50:14 +00:00
Minor patch
This commit is contained in:
parent
2e28b70975
commit
6234b62c6f
3 changed files with 17 additions and 2 deletions
|
|
@ -2955,7 +2955,12 @@ def extractErrorMessage(page):
|
|||
|
||||
if match:
|
||||
candidate = htmlUnescape(match.group("result")).replace("<br>", "\n").strip()
|
||||
if candidate and (1.0 * len(re.findall(r"[^A-Za-z,. ]", candidate)) / len(candidate) > MIN_ERROR_PARSING_NON_WRITING_RATIO):
|
||||
# Note: only the generic '(fatal|error|warning|exception): ...' regexes can capture
|
||||
# arbitrary prose, so guard those with the non-writing-char ratio; the specific
|
||||
# DBMS-signature regexes (e.g. MSSQL 'Unclosed quotation mark ...') are definitive and
|
||||
# must not be discarded just because the message happens to read like plain text
|
||||
generic = "(fatal|error|warning|exception)" in regex
|
||||
if candidate and (not generic or 1.0 * len(re.findall(r"[^A-Za-z,. ]", candidate)) / len(candidate) > MIN_ERROR_PARSING_NON_WRITING_RATIO):
|
||||
retVal = candidate
|
||||
break
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ from lib.core.enums import OS
|
|||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.10.7.141"
|
||||
VERSION = "1.10.7.142"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
|
|
|||
|
|
@ -1623,6 +1623,16 @@ class TestCommonRegexAndPage(unittest.TestCase):
|
|||
def test_extract_error_message_none_for_plain(self):
|
||||
self.assertIsNone(extractErrorMessage("Warning: This is only a dummy foobar test"))
|
||||
|
||||
def test_extract_error_message_prose_like_dbms_signature(self):
|
||||
# a specific DBMS signature must be extracted even when it reads like plain text (few
|
||||
# non-writing chars) - the non-writing-char ratio guards only the generic keyword regexes
|
||||
page = "Microsoft OLE DB Provider for SQL Server error '80040e14' Unclosed quotation mark after the character string ''."
|
||||
self.assertEqual(extractErrorMessage(page), "Unclosed quotation mark after the character string ''.")
|
||||
|
||||
def test_extract_error_message_generic_prose_still_rejected(self):
|
||||
# the generic '(fatal|error|warning): ...' path must still drop natural-language prose
|
||||
self.assertIsNone(extractErrorMessage("Error: everything is working fine and nothing is wrong here"))
|
||||
|
||||
def test_extract_error_message_non_string(self):
|
||||
self.assertIsNone(extractErrorMessage(None))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue