Repository navigation
Conversation
The table browser took the database and table of a request as they came and read them with the login of the source, so sources:read reached system schemas the listing hides, like mysql.global_priv. A read and a table listing now check both names against getDatabases and getTables first, and PostgreSQL names a table by its schema, so a bare name never resolves to pg_catalog.
This branch was successfully deployed
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.
Problem
The table browser took the database and table name straight from the request and read them with the login of the source. Someone with only
sources:readcould ask for a system database likemysql.global_priv(password hashes of the database accounts). On PostgreSQL a bare table name also resolved topg_catalogfirst, sopg_authidcould be read.Fix
A read is now only allowed for what the explorer itself lists. The service checks the database against the adapter's database list and the table against its table list before any row is read. PostgreSQL looks up the schema of the table outside the system schemas and always names it in the query, so a bare name never reaches
pg_catalog.Changes
database-read-service.ts:listTablesandreadTableDatarefuse a database the connection does not list, andreadTableDataalso refuses a table the listing does not have (aValidationError).postgres/browser.ts: new schema lookup that skipspg_catalog,information_schema,pg_toastand everypg_schema. The count, data and column queries use the schema-qualified table, and the column query filters by schema.pg_authidis never read as a bare name, schema lookup query).Testing
Unit tests were added and updated in
tests/unit/services/database-read-service.test.tsandtests/unit/adapters/database/postgres-browser.test.ts. I have no evidence of a test run in this diff, so the result is TODO.