fix: Harden URL masking and view dependency detection#43
Merged
Conversation
Database URL sanitization now scrubs secret query parameters in addition to authority credentials, handles mysql/mariadb and postgres/postgresql scheme aliases, and re-scans error messages so query secrets remain masked even after upstream libraries rewrite the scheme or pre-mask authority credentials. The app layer now funnels introspection failures through sanitized_for_url before wrapping them in AppError so leaked connection strings are harder to emit via stderr or tracing.
Mermaid, D2, and DOT exports now escape control characters and brackets, fall back to generated names when graph labels or ids are empty, and deduplicate sanitized Mermaid column identifiers per node so distinct source columns no longer collapse into the same rendered field name. Without these guards, malformed graph input could produce diagram files that downstream tooling fails to parse or that silently collapse foreign keys onto unrelated columns.
View dependency detection now walks sqlparser relations through a shared SqlRelation collector instead of matching lowercase substrings. Comments and CTE aliases no longer create false edges, schema-qualified references resolve correctly, and view-to-view dependencies stay consistent between core and layout because both call the same SqlRelation::matches_table / matches_view helpers. When no dialect can parse a view definition we fall back to an empty relation set and emit a debug log so missing dependencies remain debuggable.
SQL parsing now emits a PARSE-4 warning when the input finishes without producing any tables, views, or enums and also has no hard errors. The diagnostic is propagated through schema input handling so comment-only or whitespace-only SQL no longer looks like a clean empty schema, making it easier to spot files that contain only comments or unsupported statements.
Code Metrics Report
Details | | main (54e2969) | #43 (be21b27) | +/- |
|---------------------|----------------|---------------|-------|
+ | Coverage | 93.7% | 93.8% | +0.0% |
| Files | 71 | 71 | 0 |
| Lines | 28751 | 29404 | +653 |
+ | Covered | 26956 | 27589 | +633 |
- | Test Execution Time | 1m50s | 2m3s | +13s |Code coverage of files in pull request scope (92.3% → 92.8%)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
password,token) in database URLs propagated through introspectionerrors, and handle
postgres/postgresqlandmysql/mariadbscheme aliases so rewritten URLs staysanitized
aliases and SQL comments, and supports schema-qualified relation references
node labels/ids; deduplicate sanitized Mermaid column identifiers
PARSE-4warning when SQL input produces no tables, views, or enums without any hard errors, makingcomment-only or whitespace-only input distinguishable from a clean empty schema
Changes
password,token,api_key, etc.) in addition to authority credentialswhen masking database URLs
postgres/postgresqlandmysql/mariadbscheme aliases and re-scan error messages so querysecrets remain masked even after upstream libraries rewrite the scheme or pre-mask authority credentials
sanitized_for_urlin the app layer so leaked connection stringsare harder to emit via stderr or tracing
\n,\r) and brackets in Mermaid, D2, and DOT output so malformed graphinput no longer produces diagram files that downstream tooling fails to parse
node_N) when graph node labels or ids are empty, and resolve edgeendpoints through the same sanitized name table
user id,user-id,user_idno longer collapse into a single rendered fieldSqlRelationcollector instead of matching lowercasesubstrings, eliminating false edges from comments and CTE aliases
public.usersvsanalytics.users) and exposecollect_sql_relations/SqlRelationfromrelune-coreso layout and core use the same matching helpersPARSE-4warning when SQL input finishes without producing any tables, views, or enums and has nohard errors
looks like a clean empty schema