Repository navigation
fix(workspace): match the port in allowStatementExecutionsAgainst - #922
Merged
Merged
Conversation
…xplain why it is disabled
…ion string instead of panicking
The patterns were matched against host/database only, so the documented localhost/* also allowed a production database reached through a port forward, an SSH tunnel or a proxy on another local port. A pattern that names a port, such as 127.0.0.1:54322/*, is now matched against host:port/database and only allows that port. A pattern without a port keeps matching host/database and allows every port. The docs use port-specific patterns, the disabled reason suggests one, and DatabaseSettings::default() no longer allows statement executions.
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.
Based on #879, which needs to merge first. It doesn't depend on #903, #907 or #920.
allowStatementExecutionsAgainstignored the port. Patterns were matched againsthost/database, and the docs recommended["localhost/*", "127.0.0.1/*"]. A port forward, an SSH tunnel,cloud-sql-proxy,fly proxyor pgbouncer make a remote database reachable onlocalhostas well, on another port, so the recommended patterns also allowed executing statements against production:There was also no way to name the port:
localhost:5432/*never matched, because the target string had no port.What changed
host:port/database:127.0.0.1:54322/*only allows port 54322, andlocalhost:*/devallowsdevon any port. A pattern names a port if its host part, the part before the first/, has exactly one:.host/databaseand allows every port, as before. The docs say so and explain why to name the port.::1/*matches every port of::1, as before.127.0.0.1:5432/*, and127.0.0.1:54322/*for a local Supabase project. The config field now has a description, sodocs/schema.json, the CLI reference and the TS bindings explain the matching.127.0.0.1:5432/postgres. Add a matching pattern todb.allowStatementExecutionsAgainst, e.g. ["127.0.0.1:5432/*"]."DatabaseSettings::default().allow_statement_executionsisfalse. It made no difference before, because the default also disables the connection, but a default should not allow executions.For the changelog
Behavior change: patterns in
db.allowStatementExecutionsAgainstcan name a port (host:port/database) and then only allow that port. Patterns without a port still allow every port. A pattern whose host part had exactly one:, which could never match before, now matches againsthost:port/database. Consider switchinglocalhost/*tolocalhost:5432/*.Tests
patterns_with_a_port_only_match_that_port,patterns_without_a_port_match_every_port(including::1/*).connection_string_port_is_matched:localhost:54322/*allows the connection string on port 54322 but not a tunnel on 15432.disabled_reason_suggests_a_pattern_with_the_port, for IPv6 too, andstatement_executions_are_disallowed_by_default.Not covered
Existing configs with
localhost/*keep allowing every local port. Making port-less patterns match only the default port would break configs without a warning, so this PR only changes the docs and the suggested pattern.