Skip to content

feat(parser-sql, introspect): Apply DROP DDL to schema and harden TLS defaults#147

Merged
mhiro2 merged 2 commits into
mainfrom
fix/parser-sql-introspect-hardening
May 5, 2026
Merged

feat(parser-sql, introspect): Apply DROP DDL to schema and harden TLS defaults#147
mhiro2 merged 2 commits into
mainfrom
fix/parser-sql-introspect-hardening

Conversation

@mhiro2

@mhiro2 mhiro2 commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Make relune-parser-sql apply DROP TABLE / VIEW / TYPE / INDEX and COMMENT ... IS NULL to the in-progress schema and capture MySQL inline column COMMENT so migration-style SQL produces a faithful post-statement schema.
  • Default remote PostgreSQL / MySQL / MariaDB introspection in relune-introspect to verifying TLS, while keeping sslmode=require / ssl-mode=required as an explicit opt-out for self-signed clusters.

Changes

  • 33847b7 : feat(parser-sql): apply DROP DDL to schema and capture column comments
    • Apply DROP TABLE / VIEW / TYPE / INDEX to the parsed schema during the ordered statement pass; DROP TABLE prunes dangling inbound foreign keys while preserving FKs that explicitly target a different schema, and DROP INDEX <schema>.<name> is scoped to its qualified schema instead of removing same-named indexes across other schemas.
    • Treat COMMENT ON {TABLE|COLUMN} ... IS NULL as a deletion so doc / lint / review no longer surface comments that have been cleared by a later statement.
    • Capture inline COLUMN ... COMMENT 'text' from MySQL CREATE TABLE into the column model so MissingColumnComment lint and the HTML viewer reflect authored comments.
  • b40e075 : feat(introspect): verify TLS by default for remote DB connections
    • Default remote PostgreSQL connections to sslmode=verify-full and remote MySQL / MariaDB connections to ssl-mode=verify-identity, requiring server certificate chain and hostname validation before credentials are exchanged.
    • Honour explicit sslmode=require / ssl-mode=required as the documented opt-out for self-signed clusters and keep Unix sockets and loopback TCP on the existing local-only path.
    • Refresh ARCHITECTURE.md, docs/getting-started.md, and docs/cli-reference.md to describe the verifying default and the explicit encrypt-only opt-out.

mhiro2 added 2 commits May 5, 2026 20:02
DROP TABLE / VIEW / TYPE / INDEX now mutate the in-progress schema
during parsing instead of being reported only as warnings, so migration
SQL like `CREATE TABLE users; DROP TABLE users;` produces an empty
final schema and downstream review/diff/lint operate on the actual
post-migration state. DROP TABLE additionally prunes inbound foreign
keys from remaining tables to keep the model self-consistent (FKs
explicitly pointing at a different schema's table are preserved). DROP
INDEX honours schema qualifiers in the PostgreSQL/SQLite syntax so a
`DROP INDEX public.idx` no longer collaterally removes same-named
indexes in other schemas; the MySQL `DROP INDEX name ON table` form
continues to scope to the qualified table.

`COMMENT ON {TABLE|COLUMN} ... IS NULL` is now treated as a comment
deletion, matching PostgreSQL semantics, so doc/lint/review no longer
keep stale comments after they have been cleared by a later statement.

Inline `COLUMN ... COMMENT 'text'` definitions in MySQL CREATE TABLE
statements are captured into the column model so MissingColumnComment
lint and the HTML viewer surface authored comments.
Remote PostgreSQL / MySQL / MariaDB introspection now defaults to
`sslmode=verify-full` and `ssl-mode=verify-identity` respectively, so
the server certificate chain and hostname must validate before
credentials and schema metadata are exchanged. Encrypt-only modes
(`sslmode=require`, `ssl-mode=required`) are still respected when set
explicitly, which is the documented opt-out for self-signed clusters.
Unix sockets and loopback-only TCP connections continue to bypass TLS
enforcement.

The user-facing docs (ARCHITECTURE, getting started, CLI reference)
are updated to describe the verifying default and the explicit opt-out
for self-signed clusters.
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

Code Metrics Report

main (bce4185) #147 (62c46e8) +/-
Coverage 94.4% 94.4% -0.1%
Test Execution Time 1m37s 1m37s 0s
Details
  |                     | main (bce4185) | #147 (62c46e8) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          94.4% |          94.4% | -0.1% |
  |   Files             |             99 |            100 |    +1 |
  |   Lines             |          36516 |          36742 |  +226 |
+ |   Covered           |          34503 |          34704 |  +201 |
  | Test Execution Time |          1m37s |          1m37s |    0s |

Code coverage of files in pull request scope (87.2% → 87.6%)

Files Coverage +/- Status
crates/relune-introspect/src/connect.rs 95.6% +0.3% modified
crates/relune-parser-sql/src/comment.rs 59.5% -0.9% modified
crates/relune-parser-sql/src/context.rs 97.4% 0.0% modified
crates/relune-parser-sql/src/create_table.rs 92.9% +0.2% modified
crates/relune-parser-sql/src/drop.rs 86.1% +86.1% added
crates/relune-parser-sql/src/lib.rs 85.2% +2.2% modified

Reported by octocov

@mhiro2 mhiro2 self-assigned this May 5, 2026
@mhiro2 mhiro2 changed the title feat(parser-sql, introspect): apply DROP DDL and harden TLS defaults feat(parser-sql, introspect): Apply DROP DDL to schema and harden TLS defaults May 5, 2026
@mhiro2 mhiro2 added the enhancement New feature or request label May 5, 2026
@mhiro2
mhiro2 merged commit b27a83f into main May 5, 2026
4 checks passed
@mhiro2
mhiro2 deleted the fix/parser-sql-introspect-hardening branch May 5, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant