Skip to content

fix(oracle): SQL injection, view comment DOT, and pagination column leak - #2052

Merged
openai0229 merged 6 commits into
OtterMind:mainfrom
HandSonic:fix/oracle-sql-fixes
Jul 25, 2026
Merged

fix(oracle): SQL injection, view comment DOT, and pagination column leak#2052
openai0229 merged 6 commits into
OtterMind:mainfrom
HandSonic:fix/oracle-sql-fixes

Conversation

@HandSonic

@HandSonic HandSonic commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes Oracle SQL generation in three areas:

  1. Metadata filtering safety (OracleMetaData.tables()): escapes both schema and table-name SQL literals before interpolation.
  2. View DDL and comments (OracleSqlBuilder.buildCreateView()): quotes schema/view identifiers with Oracle double-quote escaping, emits the missing . separator, handles schema-less views, and escapes comment string literals without treating backslashes as Oracle escapes.
  3. Pagination consistency (OracleSqlBuilder.buildPageLimit()): always applies the outer projection so the synthetic CAHT2DB_AUTO_ROW_ID column does not leak on the first page, while retaining the lower-bound wrapper for later pages.

Maintainer follow-up adds focused regression coverage for quote, backslash, and apostrophe edge cases.

Split from #1926 per review feedback.

tableName was concatenated directly into SQL without escaping. Table names
containing single quotes (e.g. O'Brien) would break SQL syntax or allow
injection. Now escapes single quotes with replace("'", "''").
View comment SQL was missing DOT between schema and view name identifiers,
producing "SCOTT""MY_VIEW" instead of "SCOTT"."MY_VIEW".
When offset==0 (first page), the outer SELECT * FROM (...) wrapper was
skipped, leaking CAHT2DB_AUTO_ROW_ID into the result set. Now both
wrappers are always applied for consistent column schema across pages.
@HandSonic
HandSonic force-pushed the fix/oracle-sql-fixes branch from da8b56e to d15fa1c Compare July 24, 2026 14:01

@openai0229 openai0229 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full change and added maintainer follow-up commits for Oracle pagination consistency, schema/comment SQL escaping, quoted identifiers, and regression coverage. Local reactor verification passed: tools 26, SPI 54, Oracle 15; git diff --check also passed.

@openai0229
openai0229 merged commit fb24776 into OtterMind:main Jul 25, 2026
19 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Jul 25, 2026
HandSonic added a commit to HandSonic/Chat2DB that referenced this pull request Jul 26, 2026
…intainer review (OtterMind#1914)

- strengthen OracleIdentifierProcessor: INSTANCE, escapeString with
  single-quote doubling, static escapeIdentifier/quoteIdentifierAlways
- OracleMetaData processor singleton delegates to INSTANCE; private
  escapeSqlLiteral (OtterMind#2052) unified to processor escapeString
- builders/DBManager/enums/value processors use the processor (or
  OracleSqlGuards for non-escapable validation)
- OracleSqlEscapes removed; tests migrated (33 green)
openai0229 pushed a commit to HandSonic/Chat2DB that referenced this pull request Jul 29, 2026
…intainer review (OtterMind#1914)

- strengthen OracleIdentifierProcessor: INSTANCE, escapeString with
  single-quote doubling, static escapeIdentifier/quoteIdentifierAlways
- OracleMetaData processor singleton delegates to INSTANCE; private
  escapeSqlLiteral (OtterMind#2052) unified to processor escapeString
- builders/DBManager/enums/value processors use the processor (or
  OracleSqlGuards for non-escapable validation)
- OracleSqlEscapes removed; tests migrated (33 green)
openai0229 added a commit that referenced this pull request Jul 29, 2026
#1914) (#2195)

* fix(oracle): escape SQL identifiers and literals in metadata/DDL paths (#1914)

* refactor(oracle): move escaping into OracleIdentifierProcessor per maintainer review (#1914)

- strengthen OracleIdentifierProcessor: INSTANCE, escapeString with
  single-quote doubling, static escapeIdentifier/quoteIdentifierAlways
- OracleMetaData processor singleton delegates to INSTANCE; private
  escapeSqlLiteral (#2052) unified to processor escapeString
- builders/DBManager/enums/value processors use the processor (or
  OracleSqlGuards for non-escapable validation)
- OracleSqlEscapes removed; tests migrated (33 green)

* fix(oracle): keep SPI quoteIdentifier conditional, reserve always-quote for DDL paths (#1914)

* fix(oracle): preserve legal SQL escaping semantics (#1914)

---------

Co-authored-by: zgq <openai0229@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants