Salvaging (verified) what's useful from #6103

This commit is contained in:
Miroslav Štampar
2026-09-02 07:53:32 +02:00
parent 3b8a8d3d09
commit 3fc41ca370
3 changed files with 112 additions and 1 deletions
+13
View File
@@ -2,6 +2,9 @@
<root> <root>
<dbms value="MySQL"> <dbms value="MySQL">
<error regexp="org\.apache\.doris\." fork="Doris"/>
<error regexp="com\.starrocks\." fork="StarRocks"/>
<error regexp="Getting syntax error (at|from) line \d+, column \d+" fork="StarRocks"/>
<error regexp="SQL syntax.*?MySQL"/> <error regexp="SQL syntax.*?MySQL"/>
<error regexp="Warning.*?\Wmysqli?_"/> <error regexp="Warning.*?\Wmysqli?_"/>
<error regexp="MySQLSyntaxErrorException"/> <error regexp="MySQLSyntaxErrorException"/>
@@ -24,6 +27,15 @@
</dbms> </dbms>
<dbms value="PostgreSQL"> <dbms value="PostgreSQL">
<error regexp="crdb_internal\." fork="CockroachDB"/>
<error regexp="github\.com/cockroachdb/cockroach/pkg/sql" fork="CockroachDB"/>
<error regexp="com\.yugabyte\.(util\.PSQLException|core\.v3)" fork="YugabyteDB"/>
<error regexp="\(yb/\w+/\w+\.cc:\d+\)" fork="YugabyteDB"/>
<error regexp="org\.opengauss\.(util\.PSQLException|core\.v3)" fork="OpenGauss"/>
<error regexp="(duckdb\.duckdb|_duckdb)\.(Parser|Binder|Catalog|Conversion)Exception" fork="DuckDB"/>
<error regexp="org\.duckdb\.DuckDB" fork="DuckDB"/>
<error regexp="Parser Error: [^\n]{0,40}at or near" fork="DuckDB"/>
<error regexp="(Catalog Error: Table with name|Binder Error: Referenced column)" fork="DuckDB"/>
<error regexp="PostgreSQL.*?ERROR"/> <error regexp="PostgreSQL.*?ERROR"/>
<error regexp="Warning.*?\Wpg_"/> <error regexp="Warning.*?\Wpg_"/>
<error regexp="valid PostgreSQL result"/> <error regexp="valid PostgreSQL result"/>
@@ -203,6 +215,7 @@
</dbms> </dbms>
<dbms value="Presto"> <dbms value="Presto">
<error regexp="io\.trino\.(jdbc|spi)\." fork="Trino"/>
<error regexp="com\.facebook\.presto\.jdbc"/> <error regexp="com\.facebook\.presto\.jdbc"/>
<error regexp="io\.prestosql\.jdbc"/> <error regexp="io\.prestosql\.jdbc"/>
<error regexp="com\.simba\.presto\.jdbc"/> <error regexp="com\.simba\.presto\.jdbc"/>
+1 -1
View File
@@ -20,7 +20,7 @@ from lib.core.enums import OS
from thirdparty import six from thirdparty import six
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.10.8.57" VERSION = "1.10.9.1"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} 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) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
+98
View File
@@ -0,0 +1,98 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _testutils import bootstrap
bootstrap()
from lib.core.data import kb
from lib.core.enums import DBMS
from lib.core.enums import FORK
from lib.parse.html import htmlParser
class TestHtmlParserForks(unittest.TestCase):
def setUp(self):
kb.forkNote = None
kb.cache.parsedDbms.clear()
# NOTE: these forks all speak the PostgreSQL wire protocol and inherit its error wording, so
# the brand name itself never appears next to 'ERROR:' - only a leaked driver package or an
# engine-internal source reference tells them apart from stock PostgreSQL
def test_cockroachdb_error_fingerprint(self):
for page in (
"ERROR: relation \"crdb_internal.tables\" does not exist",
"DETAIL: stack trace: github.com/cockroachdb/cockroach/pkg/sql/conn_executor.go:733",
):
kb.forkNote = None
kb.cache.parsedDbms.clear()
self.assertEqual(htmlParser(page), DBMS.PGSQL)
self.assertEqual(kb.forkNote, FORK.COCKROACHDB)
def test_yugabytedb_error_fingerprint(self):
for page in (
"com.yugabyte.util.PSQLException: ERROR: syntax error at or near \"'\"",
"ERROR: Query error: [Query error (yb/tserver/read_query.cc:265): MISMATCHED_SCHEMA]",
):
kb.forkNote = None
kb.cache.parsedDbms.clear()
self.assertEqual(htmlParser(page), DBMS.PGSQL)
self.assertEqual(kb.forkNote, FORK.YUGABYTEDB)
def test_opengauss_error_fingerprint(self):
page = "org.opengauss.util.PSQLException: ERROR: syntax error at or near \"'\""
dbms = htmlParser(page)
self.assertEqual(dbms, DBMS.PGSQL)
self.assertEqual(kb.forkNote, FORK.OPENGAUSS)
def test_duckdb_error_fingerprint(self):
# Messages below are verbatim from DuckDB 1.1.3/1.5.5 (the module was renamed
#'duckdb.duckdb' -> '_duckdb')
for page in (
"_duckdb.ParserException: Parser Error: unterminated quoted string at or near \"'''\"",
"duckdb.duckdb.CatalogException: Catalog Error: Table with name t does not exist!",
"_duckdb.BinderException: Binder Error: Referenced column \"x\" not found in FROM clause!",
"at org.duckdb.DuckDBPreparedStatement.execute(DuckDBPreparedStatement.java:180)",
):
kb.forkNote = None
kb.cache.parsedDbms.clear()
self.assertEqual(htmlParser(page), DBMS.PGSQL)
self.assertEqual(kb.forkNote, FORK.DUCKDB)
def test_trino_error_fingerprint(self):
# the generic Presto 'mismatched input' entry also matches, so this pins the ordering
# that keeps the Trino fork note from being swallowed by it
page = "io.trino.jdbc.TrinoSQLException: line 1:15: mismatched input 'FROM'. Expecting: <expression>"
dbms = htmlParser(page)
self.assertEqual(dbms, DBMS.PRESTO)
self.assertEqual(kb.forkNote, FORK.TRINO)
def test_doris_error_fingerprint(self):
# Doris speaks the MySQL wire protocol, so the client-side exception is MySQL's own -
# only the leaked FE package name tells the fork apart
page = "com.mysql.jdbc.exceptions.MySQLSyntaxErrorException at org.apache.doris.qe.ConnectProcessor"
dbms = htmlParser(page)
self.assertEqual(dbms, DBMS.MYSQL)
self.assertEqual(kb.forkNote, FORK.DORIS)
def test_starrocks_error_fingerprint(self):
for page in (
"com.mysql.jdbc.exceptions.MySQLSyntaxErrorException at com.starrocks.qe.ConnectProcessor",
"(1064, 'Getting syntax error from line 1, column 7 to line 1, column 62. Detail message: x.')",
):
kb.forkNote = None
kb.cache.parsedDbms.clear()
self.assertEqual(htmlParser(page), DBMS.MYSQL)
self.assertEqual(kb.forkNote, FORK.STARROCKS)
if __name__ == "__main__":
unittest.main()