Skip to content

Commit 3fc41ca

Browse files
committed
Salvaging (verified) what's useful from #6103
1 parent 3b8a8d3 commit 3fc41ca

3 files changed

Lines changed: 112 additions & 1 deletion

File tree

data/xml/errors.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
<root>
44
<dbms value="MySQL">
5+
<error regexp="org\.apache\.doris\." fork="Doris"/>
6+
<error regexp="com\.starrocks\." fork="StarRocks"/>
7+
<error regexp="Getting syntax error (at|from) line \d+, column \d+" fork="StarRocks"/>
58
<error regexp="SQL syntax.*?MySQL"/>
69
<error regexp="Warning.*?\Wmysqli?_"/>
710
<error regexp="MySQLSyntaxErrorException"/>
@@ -24,6 +27,15 @@
2427
</dbms>
2528

2629
<dbms value="PostgreSQL">
30+
<error regexp="crdb_internal\." fork="CockroachDB"/>
31+
<error regexp="github\.com/cockroachdb/cockroach/pkg/sql" fork="CockroachDB"/>
32+
<error regexp="com\.yugabyte\.(util\.PSQLException|core\.v3)" fork="YugabyteDB"/>
33+
<error regexp="\(yb/\w+/\w+\.cc:\d+\)" fork="YugabyteDB"/>
34+
<error regexp="org\.opengauss\.(util\.PSQLException|core\.v3)" fork="OpenGauss"/>
35+
<error regexp="(duckdb\.duckdb|_duckdb)\.(Parser|Binder|Catalog|Conversion)Exception" fork="DuckDB"/>
36+
<error regexp="org\.duckdb\.DuckDB" fork="DuckDB"/>
37+
<error regexp="Parser Error: [^\n]{0,40}at or near" fork="DuckDB"/>
38+
<error regexp="(Catalog Error: Table with name|Binder Error: Referenced column)" fork="DuckDB"/>
2739
<error regexp="PostgreSQL.*?ERROR"/>
2840
<error regexp="Warning.*?\Wpg_"/>
2941
<error regexp="valid PostgreSQL result"/>
@@ -203,6 +215,7 @@
203215
</dbms>
204216

205217
<dbms value="Presto">
218+
<error regexp="io\.trino\.(jdbc|spi)\." fork="Trino"/>
206219
<error regexp="com\.facebook\.presto\.jdbc"/>
207220
<error regexp="io\.prestosql\.jdbc"/>
208221
<error regexp="com\.simba\.presto\.jdbc"/>

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.8.57"
23+
VERSION = "1.10.9.1"
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_html_parser_forks.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
5+
See the file 'LICENSE' for copying permission
6+
"""
7+
8+
import os
9+
import sys
10+
import unittest
11+
12+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
13+
from _testutils import bootstrap
14+
bootstrap()
15+
16+
from lib.core.data import kb
17+
from lib.core.enums import DBMS
18+
from lib.core.enums import FORK
19+
from lib.parse.html import htmlParser
20+
21+
22+
class TestHtmlParserForks(unittest.TestCase):
23+
def setUp(self):
24+
kb.forkNote = None
25+
kb.cache.parsedDbms.clear()
26+
27+
# NOTE: these forks all speak the PostgreSQL wire protocol and inherit its error wording, so
28+
# the brand name itself never appears next to 'ERROR:' - only a leaked driver package or an
29+
# engine-internal source reference tells them apart from stock PostgreSQL
30+
def test_cockroachdb_error_fingerprint(self):
31+
for page in (
32+
"ERROR: relation \"crdb_internal.tables\" does not exist",
33+
"DETAIL: stack trace: github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:733",
34+
):
35+
kb.forkNote = None
36+
kb.cache.parsedDbms.clear()
37+
self.assertEqual(htmlParser(page), DBMS.PGSQL)
38+
self.assertEqual(kb.forkNote, FORK.COCKROACHDB)
39+
40+
def test_yugabytedb_error_fingerprint(self):
41+
for page in (
42+
"com.yugabyte.util.PSQLException: ERROR: syntax error at or near \"'\"",
43+
"ERROR: Query error: [Query error (yb/tserver/read_query.cc:265): MISMATCHED_SCHEMA]",
44+
):
45+
kb.forkNote = None
46+
kb.cache.parsedDbms.clear()
47+
self.assertEqual(htmlParser(page), DBMS.PGSQL)
48+
self.assertEqual(kb.forkNote, FORK.YUGABYTEDB)
49+
50+
def test_opengauss_error_fingerprint(self):
51+
page = "org.opengauss.util.PSQLException: ERROR: syntax error at or near \"'\""
52+
dbms = htmlParser(page)
53+
self.assertEqual(dbms, DBMS.PGSQL)
54+
self.assertEqual(kb.forkNote, FORK.OPENGAUSS)
55+
56+
def test_duckdb_error_fingerprint(self):
57+
# Messages below are verbatim from DuckDB 1.1.3/1.5.5 (the module was renamed
58+
#'duckdb.duckdb' -> '_duckdb')
59+
for page in (
60+
"_duckdb.ParserException: Parser Error: unterminated quoted string at or near \"'''\"",
61+
"duckdb.duckdb.CatalogException: Catalog Error: Table with name t does not exist!",
62+
"_duckdb.BinderException: Binder Error: Referenced column \"x\" not found in FROM clause!",
63+
"at org.duckdb.DuckDBPreparedStatement.execute(DuckDBPreparedStatement.java:180)",
64+
):
65+
kb.forkNote = None
66+
kb.cache.parsedDbms.clear()
67+
self.assertEqual(htmlParser(page), DBMS.PGSQL)
68+
self.assertEqual(kb.forkNote, FORK.DUCKDB)
69+
70+
def test_trino_error_fingerprint(self):
71+
# the generic Presto 'mismatched input' entry also matches, so this pins the ordering
72+
# that keeps the Trino fork note from being swallowed by it
73+
page = "io.trino.jdbc.TrinoSQLException: line 1:15: mismatched input 'FROM'. Expecting: <expression>"
74+
dbms = htmlParser(page)
75+
self.assertEqual(dbms, DBMS.PRESTO)
76+
self.assertEqual(kb.forkNote, FORK.TRINO)
77+
78+
def test_doris_error_fingerprint(self):
79+
# Doris speaks the MySQL wire protocol, so the client-side exception is MySQL's own -
80+
# only the leaked FE package name tells the fork apart
81+
page = "com.mysql.jdbc.exceptions.MySQLSyntaxErrorException at org.apache.doris.qe.ConnectProcessor"
82+
dbms = htmlParser(page)
83+
self.assertEqual(dbms, DBMS.MYSQL)
84+
self.assertEqual(kb.forkNote, FORK.DORIS)
85+
86+
def test_starrocks_error_fingerprint(self):
87+
for page in (
88+
"com.mysql.jdbc.exceptions.MySQLSyntaxErrorException at com.starrocks.qe.ConnectProcessor",
89+
"(1064, 'Getting syntax error from line 1, column 7 to line 1, column 62. Detail message: x.')",
90+
):
91+
kb.forkNote = None
92+
kb.cache.parsedDbms.clear()
93+
self.assertEqual(htmlParser(page), DBMS.MYSQL)
94+
self.assertEqual(kb.forkNote, FORK.STARROCKS)
95+
96+
97+
if __name__ == "__main__":
98+
unittest.main()

0 commit comments

Comments
 (0)