From patchwork Fri Dec 4 12:29:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yogita Urade X-Patchwork-Id: 107303 Received: from aer-iport-8.cisco.com (aer-iport-8.cisco.com [173.38.203.70]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.6870.1796387381540419000 for ; Fri, 04 Dec 2026 04:29:42 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=LLdlZubS; spf=pass (domain: cisco.com, ip: 173.38.203.70, mailfrom: yurade@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=6291; q=dns/txt; s=iport01; t=1796387381; x=1797596981; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=wAU6dMGOMYAz+HPx8/GpmtKaOnhNLXklbBqnDs6PXks=; b=LLdlZubSJgTpxdystYovjYYvHSjhKirnjZvUEyoqs4umCyXqjXoVa6Qz 3aU8CrWyGtoxkazh7RwH757DGdd+klSHjvAh2JC5q2IgNytOagcvFxhiw DzfIcMYy9aoieRtLMe/q35UXXw/J5zsjt27Fw7q9C4rXZkzTir5BX6TdA jU6/iCRSORMTSsEiNPwewNb5q0GDGvyS3bB7ePRwt1AbsU3ZX3HjEvbmx kE0whunZLb8ll3jFUncMig8f/QecuYveWAOYirJQXtTCeEGtFOlaXbIEa b3Z/MeE5MJfXIecCrPioYKx8cv7W4ZHMVIOS8Dh4MFjQ7wLF9Og/4YmD3 Q==; X-CSE-ConnectionGUID: xUGglYhcQ0y8NZ1xCrD7Yw== X-CSE-MsgGUID: GG82sGQOQC29QgkeAn9l5g== X-IPAS-Result: A0DJAgBhsRJr/9NK/pBRCYJZgld1YENJlCyCIYEWilOSRBSBag8BAQEPRA0EAQGEP45sAiY1CA4BAgQDAgMBAQEBAQEBAQEBAQEKAQEFAQEBAgEHBYEOE4ZPDZASATgBG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eZnhlCWzGEfBBAaEFe2v/S9okq/QM5Eb UsM9ywjqKI/+ECmQp/6RRLQnZKflhcRQZ9UVuY98gzIk/KS6AeCDW9CRTlEADA7iPILqfUR/ gfht7vU6fZH6dV5lVr1Gm+okA6P IronPort-HdrOrdr: A9a23:ynNX+aHZIU/3lZx2pLqE2MeALOsnbusQ8zAXPidKOH5om6Oj+f xG8M536faWskdzZJhfo7G90cC7KBu2n6KdirN/AV7NZmXbUROTTL1K3M/F3yDqHTH4+6p20K dtdLU7NfjLZGIK6PoTJGKDYrEdKB7tytHNudvj X-Talos-CUID: 9a23:zj8hLWOvxSVQwu5DSBRI+0olGsscKmyN6kWJM2SiJTlYV+jA X-Talos-MUID: 9a23:HPeScAvu3Q2z+IC3zs2nqx4ybtxH2oOXIxpcqJoFtuCCZCgtNGLI X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.29,78,1794873600"; d="scan'208";a="62043334" Received: from aer-l-core-10.cisco.com ([144.254.74.211]) by aer-iport-8.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 04 Dec 2026 12:29:37 +0000 Received: from sjc-ads-7871.cisco.com (sjc-ads-7871.cisco.com [10.30.222.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-10.cisco.com (Postfix) with ESMTPS id 6EA6B18000B59 for ; Fri, 4 Dec 2026 12:29:37 +0000 (GMT) Received: by sjc-ads-7871.cisco.com (Postfix, from userid 1889728) id 2047DCC1611; Fri, 4 Dec 2026 04:29:36 -0800 (PST) From: Yogita Urade To: openembedded-devel@lists.openembedded.org Subject: [oe][meta-python][wrynose][PATCH 1/2] python3-sqlparse: Fix CVE-2026-84305 Date: Fri, 4 Dec 2026 04:29:34 -0800 Message-Id: <20261204122935.2451864-1-yurade@cisco.com> X-Mailer: git-send-email 2.35.6 MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-7871.cisco.com [10.30.222.158];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 10.30.222.158, sjc-ads-7871.cisco.com X-Outbound-Node: aer-l-core-10.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 04 Dec 2026 12:29:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/134031 Backport upstream's reindent fix, which measures offsets by walking backward through tokens [1] for CVE-2026-84305 [2]. [1] https://github.com/andialbrecht/sqlparse/commit/a51df6d9e2d31b44be9adb6bc8732517db6bf96b [2] https://nvd.nist.gov/vuln/detail/cve-2026-84305 Signed-off-by: Yogita Urade --- .../python3-sqlparse/CVE-2026-84305.patch | 119 ++++++++++++++++++ .../python/python3-sqlparse_0.5.5.bb | 1 + 2 files changed, 120 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-84305.patch diff --git a/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-84305.patch b/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-84305.patch new file mode 100644 index 0000000000..2955dcfd3d --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-84305.patch @@ -0,0 +1,119 @@ +From a51df6d9e2d31b44be9adb6bc8732517db6bf96b Mon Sep 17 00:00:00 2001 +From: Andi Albrecht +Date: Sat, 25 Jul 2026 08:52:26 +0200 +Subject: [PATCH] Measure reindent offsets backwards to avoid quadratic CPU use + +ReindentFilter._get_offset() reports the column a token starts on and is +called once per group. It rebuilt the statement prefix from the start of +the statement on every call, so reindenting a list of N parenthesized +tuples cost O(N^2). A ~12 KB payload sized just below MAX_GROUPING_TOKENS +occupied a worker for seconds (CWE-1333, GHSA-cfqr-cjx5-5jcm). + +Measure the current line by walking backwards from the token and counting +characters instead, which stops at the preceding line break rather than +touching the whole statement. Formatting output is unchanged, verified +byte for byte over the test corpus and 147 option combinations. + +Both vectors reaching the offset calculation are covered by the new +benchmark: IN (...) tuple lists via _process_parenthesis() and +_process_identifierlist(), VALUES lists via _process_values(). + +CVE: CVE-2026-84305 +Upstream-Status: Backport [https://github.com/andialbrecht/sqlparse/commit/a51df6d9e2d31b44be9adb6bc8732517db6bf96b] + +Backport Changes: +- Omitted CHANGELOG because its upstream master hunk conflicts with the + wrynose 0.5.5 changelog history; the entry is documentation-only and + is not needed for the security fix. +- Omitted the upstream benchmark script; it is development tooling and is + not required for the production fix. + +Co-Authored-By: Claude Opus 5 +Signed-off-by: Yogita Urade +--- + sqlparse/filters/reindent.py | 66 +++++++++++++++---- + 1 file changed, 53 insertions(+), 13 deletions(-) + +diff --git a/sqlparse/filters/reindent.py b/sqlparse/filters/reindent.py +index 9fb232f..96b603a 100644 +--- a/sqlparse/filters/reindent.py ++++ b/sqlparse/filters/reindent.py +@@ -25,25 +25,65 @@ class ReindentFilter: + self._last_stmt = None + self._last_func = None + +- def _flatten_up_to_token(self, token): +- """Yields all tokens up to token but excluding current.""" +- if token.is_group: +- token = next(token.flatten()) +- +- for t in self._curr_stmt.flatten(): +- if t == token: +- break +- yield t +- + @property + def leading_ws(self): + return self.offset + self.indent * self.width + ++ def _current_line_len(self, token): ++ """Returns the width of what's already emitted on *token*'s line. ++ ++ The tokens preceding *token* are visited last one first, so the walk ++ stops at the line break that starts the current line. Rebuilding the ++ statement prefix from its start instead made every caller ++ O(statement), and the callers running once per group (tuple lists, ++ identifier lists) quadratic in the number of groups -- a CPU ++ exhaustion vector (GHSA-cfqr-cjx5-5jcm). The walk is inlined and ++ counts characters rather than collecting them: both matter, since a ++ line without any break still has to be measured token by token. ++ """ ++ length = 0 ++ node = token ++ while node is not self._curr_stmt and node.parent is not None: ++ parent = node.parent ++ # ``Token`` doesn't implement ``__eq__``, so ``index()`` is an ++ # identity lookup and safe against tokens sharing a value. ++ stack = parent.tokens[:parent.tokens.index(node)] ++ while stack: ++ prev_ = stack.pop() ++ if prev_.is_group: ++ stack.extend(prev_.tokens) ++ continue ++ ++ value = prev_.value ++ size = len(value) ++ if not size: ++ continue ++ lines = value.splitlines() ++ if len(lines) == 1 and len(lines[0]) == size: ++ # No break in here. ``splitlines()`` hands back the value ++ # itself in that case, so this costs a scan but no copy -- ++ # which is what keeps a long break-free line affordable. ++ length += size ++ continue ++ ++ # ``value`` holds the break that starts the current line. The ++ # sentinel keeps a trailing break from collapsing, so ``lines`` ++ # always has one entry more than the number of breaks. ++ lines = (value + '.').splitlines() ++ tail = len(lines[-1]) - 1 + length ++ if tail: ++ return tail ++ # Nothing but a break to our right, and ``splitlines()`` drops ++ # that empty line -- so the line to measure is the one before. ++ if len(lines) > 2: ++ return len(lines[-2]) ++ length = len(lines[0]) ++ node = parent ++ return length ++ + def _get_offset(self, token): +- raw = ''.join(map(str, self._flatten_up_to_token(token))) +- line = (raw or '\n').splitlines()[-1] + # Now take current offset into account and return relative offset. +- return len(line) - len(self.char * self.leading_ws) ++ return self._current_line_len(token) - len(self.char * self.leading_ws) + + def nl(self, offset=0): + return sql.Token( diff --git a/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb b/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb index 61fe759ede..62d0318f84 100644 --- a/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb +++ b/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb @@ -11,6 +11,7 @@ SRC_URI += "file://CVE-2026-54284-1.patch \ file://CVE-2026-59893.patch \ file://CVE-2026-59894.patch \ file://CVE-2026-71491.patch \ + file://CVE-2026-84305.patch \ " CVE_PRODUCT = "sqlparse" From patchwork Fri Dec 4 12:29:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yogita Urade X-Patchwork-Id: 107304 Received: from aer-iport-4.cisco.com (aer-iport-4.cisco.com [173.38.203.54]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.6871.1796387386351056206 for ; Fri, 04 Dec 2026 04:29:46 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: message contains an insecure body length tag" header.i=@cisco.com header.s=iport01 header.b=jRV0AZxg; spf=pass (domain: cisco.com, ip: 173.38.203.54, mailfrom: yurade@cisco.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=5890; q=dns/txt; s=iport01; t=1796387386; x=1797596986; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=CwvxC4Q2L4MLTo3ZQMReSI4imUG4h4jI3YNSTGM005I=; b=jRV0AZxgmU6XsXSPt5Z893zkXeZbECYgeiS02Ec+LIUgJcj/9EXrOd7H pAibRCox/D+7hPQw0bGkfgxnFqj/RGrV/UICHAyQ7kTXX6v/u8J8z9Ol0 oyLttxKKVLr25dpxS18x9ysbg20p2TcGTQkZBSI2V1jcXtW2u9aYs3YXK pbDR/G+hnStQF91FPSX78m28fJ1mB7hFl7pgNa5OYaJmihLzf/drankpM lH7mqPkF1ADnNGy5WOPRl2Y/xC9BO71XkcYIplbAODHXJPe+yWmHQT4hb QSrtjQV8GH2AANQr/O9H9wM8azdeR5l6LjY4LoajDREfXKTgKEuyC788s A==; X-CSE-ConnectionGUID: 2ISAIJy+RZu2WubPOwyn2Q== X-CSE-MsgGUID: YHd0y0zYT9GDIDc+QiXRlg== X-IPAS-Result: A0BJAgDYsRJr/8pK/pBaglmCV3VgQ0mULIIhA4ETnReBfg8BAQEPRA0EAQGEP0YCjiQCJjQJDgECBAMCAwEBAQEBAQEBAQEBAQoBAQUBAQECAQcFgQ4Thk8NkBIBAgEDJwsBGAEeHxwDAQIvKyMIGYMCAYJ0AxG4WoF5M4EBgykBPwJDUNlLgWgBCxQBgTiFQognXRgBhH4nG4FJRIEVgnR2gQWBXAEBiCYEgy6BVB6GG4ZYAoFIiVVIgR4DWSwBVRMNCgsHBYFoAzUSKhVuMh2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QXvYji2hC6mlwRA09TyX+rb HLoB1173HJYVoqNU3I3OrwW5VoIkmskKKdn7NxAV7KZmCP0wGVxcNZnOnfKlbbdBEWmNQw6U 4ZSchDIey1K0RmhsDn5wT9OdMhzN6btJ2Mv47lvhBQpcUAUdAY0++/YTzrdHFLeA== X-Talos-CUID: 9a23:gJQCxmtaW4rlypLy9Tbw6o/w6It/U0b07VXBYHWKFDxWVbetbkCB/vldxp8= X-Talos-MUID: 9a23:FJm6jAQ24VWrRJVARXTdpD06JZ960pj/J2wsvZ5Fgsi0Dyh/bmI= X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.29,78,1794873600"; d="scan'208";a="64543026" Received: from aer-l-core-01.cisco.com ([144.254.74.202]) by aer-iport-4.cisco.com with ESMTP/TLS/TLS_AES_256_GCM_SHA384; 04 Dec 2026 12:29:37 +0000 Received: from sjc-ads-7871.cisco.com (sjc-ads-7871.cisco.com [10.30.222.158]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aer-l-core-01.cisco.com (Postfix) with ESMTPS id 81115D6545 for ; Fri, 4 Dec 2026 12:29:37 +0000 (GMT) Received: by sjc-ads-7871.cisco.com (Postfix, from userid 1889728) id 2354FCBF201; Fri, 4 Dec 2026 04:29:36 -0800 (PST) From: Yogita Urade To: openembedded-devel@lists.openembedded.org Subject: [oe][meta-python][wrynose][PATCH 2/2] python3-sqlparse: Fix CVE-2026-112307 Date: Fri, 4 Dec 2026 04:29:35 -0800 Message-Id: <20261204122935.2451864-2-yurade@cisco.com> X-Mailer: git-send-email 2.35.6 In-Reply-To: <20261204122935.2451864-1-yurade@cisco.com> References: <20261204122935.2451864-1-yurade@cisco.com> MIME-Version: 1.0 X-Outbound-Client-TLS: ANONYMOUS;sjc-ads-7871.cisco.com [10.30.222.158];TLSv1.3;TLS_AES_256_GCM_SHA384;256 X-Outbound-SMTP-Client: 10.30.222.158, sjc-ads-7871.cisco.com X-Outbound-Node: aer-l-core-01.cisco.com List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Fri, 04 Dec 2026 12:29:49 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/134032 This patch applies the upstream fix as referenced in [2], using the commit shown in [1]. [1] https://github.com/andialbrecht/sqlparse/commit/bb3c50a52dc2f267c786f0d99c27b25519f9331f [2] https://github.com/andialbrecht/sqlparse/pull/937 [3] https://nvd.nist.gov/vuln/detail/cve-2026-112307 Signed-off-by: Yogita Urade --- .../python3-sqlparse/CVE-2026-112307.patch | 98 +++++++++++++++++++ .../python/python3-sqlparse_0.5.5.bb | 1 + 2 files changed, 99 insertions(+) create mode 100644 meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-112307.patch diff --git a/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-112307.patch b/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-112307.patch new file mode 100644 index 0000000000..4793952ead --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-sqlparse/CVE-2026-112307.patch @@ -0,0 +1,98 @@ +From bb3c50a52dc2f267c786f0d99c27b25519f9331f Mon Sep 17 00:00:00 2001 +From: cve-zh00 +Date: Tue, 20 Oct 2026 10:56:23 -0300 +Subject: [PATCH] fix: escape dollar signs in PHP output format (CVE-2026-112307) + +PHP interpolates $var, ${expr} and {$expr} inside double-quoted strings, +so SQL text containing them could inject PHP code into the snippet +generated by output_format='php'. Escape "$" as "\$" after the existing +backslash and double-quote escaping. + +Adds regression tests for SQL literals, ${expr}/{${expr}} payloads, +PostgreSQL dollar quoting, quoted identifiers, comments and a preceding +backslash. + +CVE: CVE-2026-112307 +Upstream-Status: Backport [https://github.com/andialbrecht/sqlparse/commit/bb3c50a52dc2f267c786f0d99c27b25519f9331f] + +Backport Changes: +- Omitted CHANGELOG because its upstream master hunk conflicts with the + target 0.5.5 changelog context; the entry is documentation-only. + +Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> +Signed-off-by: Yogita Urade +--- + sqlparse/filters/output.py | 8 ++++++-- + tests/test_format.py | 39 +++++++++++++++++++++++++++++++++++++++ + 2 files changed, 45 insertions(+), 2 deletions(-) + +diff --git a/sqlparse/filters/output.py b/sqlparse/filters/output.py +index 697ebc3..06015ec 100644 +--- a/sqlparse/filters/output.py ++++ b/sqlparse/filters/output.py +@@ -114,9 +114,13 @@ class OutputPHPFilter(OutputFilter): + + # Escape backslashes before quotes so a backslash preceding a + # quote cannot break out of the generated string literal +- # (GHSA-3496-9g83-7v6x). ++ # (GHSA-3496-9g83-7v6x). Dollar signs are escaped last because ++ # PHP interpolates $var, ${expr} and {$expr} inside double-quoted ++ # strings (CVE-2026-112307). + else: +- token.value = token.value.replace('\\', '\\\\').replace('"', '\\"') ++ token.value = (token.value.replace('\\', '\\\\') ++ .replace('"', '\\"') ++ .replace('$', '\\$')) + + # Put the token + yield sql.Token(T.Text, token.value) +diff --git a/tests/test_format.py b/tests/test_format.py +index 9349506..06c9342 100644 +--- a/tests/test_format.py ++++ b/tests/test_format.py +@@ -705,6 +705,45 @@ class TestOutputFormat: + f = lambda sql: sqlparse.format(sql, output_format='php') + assert f(sql) == '$sql = "select \'\\\\foo\\\\\'";' + ++ @pytest.mark.parametrize('sql, expected', [ ++ # plain variable interpolation ++ ("SELECT '$name'", r'''$sql = "SELECT '\$name'";'''), ++ # expression interpolation payloads (CVE-2026-112307) ++ ("SELECT '${expr}'", r'''$sql = "SELECT '\${expr}'";'''), ++ ("SELECT '{${expr}}'", r'''$sql = "SELECT '{\${expr}}'";'''), ++ ("SELECT '{$obj->prop}'", r'''$sql = "SELECT '{\$obj->prop}'";'''), ++ # PostgreSQL dollar-quoted strings ++ ('SELECT $body$text$body$', ++ r'''$sql = "SELECT \$body\$text\$body\$";'''), ++ # quoted identifiers and comments ++ ('SELECT "$table"', r'''$sql = "SELECT \"\$table\"";'''), ++ ('SELECT 1 /* $name */', r'''$sql = "SELECT 1 /* \$name */";'''), ++ # an existing backslash must not neutralize the dollar escape ++ ("SELECT '\\$name'", r'''$sql = "SELECT '\\\$name'";'''), ++ ]) ++ def test_php_escapes_dollar_signs(self, sql, expected): ++ # CVE-2026-112307: "$" starts variable/expression interpolation in ++ # PHP double-quoted strings and must be escaped. ++ assert sqlparse.format(sql, output_format='php') == expected ++ ++ def test_php_dollar_escape_multiline(self): ++ sql = 'select $a$x$a$\nfrom foo where b = \'$c\'' ++ formatted = sqlparse.format(sql, output_format='php') ++ assert formatted == '\n'.join([ ++ '$sql = "select \\$a\\$x\\$a\\$ ";', ++ '$sql .= "from foo where b = \'\\$c\'";']) ++ ++ def test_php_variable_name_keeps_dollar(self): ++ # only SQL content is escaped, not the generated assignment target ++ formatted = sqlparse.format('select 1; select 2', output_format='php') ++ assert formatted == '$sql = "select 1; ";\n$sql2 = "select 2";' ++ ++ def test_python_dollar_signs_unchanged(self): ++ # "$" has no special meaning in single-quoted Python strings ++ sql = "select '$name' from $t$x$t$" ++ formatted = sqlparse.format(sql, output_format='python') ++ assert formatted == "sql = 'select \\'$name\\' from $t$x$t$'" ++ + def test_sql(self): + # "sql" is an allowed option but has no effect + sql = 'select * from foo;' diff --git a/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb b/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb index 62d0318f84..0da78b8a03 100644 --- a/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb +++ b/meta-python/recipes-devtools/python/python3-sqlparse_0.5.5.bb @@ -12,6 +12,7 @@ SRC_URI += "file://CVE-2026-54284-1.patch \ file://CVE-2026-59894.patch \ file://CVE-2026-71491.patch \ file://CVE-2026-84305.patch \ + file://CVE-2026-112307.patch \ " CVE_PRODUCT = "sqlparse"