Repository navigation
fix(security): bound set-returning function lists; authenticate before APQ registration; isolate root field errors - #134
Merged
Merged
Conversation
…e APQ registration; isolate root field errors - Lists returned by set-returning functions (SETOF root functions and computed columns, rows, composites and scalars) compile with LIMIT limits.max_page_size, and the cost estimate prices them at that many rows instead of 10, so max_cost bounds the work below them. - APQ documents are registered only after the request authenticated and the document parsed, passed the document limits and validated. The store is an LRU bounded by persisted_queries.max_bytes (8 MiB) and persisted_queries.max_entry_bytes (64 KiB) instead of 1024 entries of any size. - When a query field's statement fails in a transactional batch (role switching, claims, transactions.per_request) and later fields were skipped, the query runs again with a savepoint per root field. The other fields keep their values; no pg:25P02 field errors, pathless internal error or ERROR log for a client error. - server.request_timeout must be at least 1s; 0 disabled it silently. - An EWKT filter operand or near: reference in another SRID than the column's typmod SRID is invalid_argument instead of pg:XX000. - /schema.graphql requires the credentials /graphql requires. BREAKING CHANGE: set-returning function lists hold at most limits.max_page_size items; server.request_timeout below 1s is rejected; /schema.graphql answers 401 without credentials unless roles.anonymous is set; mismatched EWKT SRIDs are invalid_argument.
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.
Closes #130, closes #131, closes #132
Set-returning function lists (#130)
LIMIT limits.max_page_size. This coversSETOFroot functions and computed columns, for row, composite and scalar results. The LIMIT sits on the function scan, before the relation laterals run.max_page_sizerows instead of 10. A nested connection below one now costs what it costs through a connection. For example,{ manyUsers { id email postsByAuthorId { totalCount nodes { id title body } } } }was estimated at 4041 and is now 40401.max_page_sizeitems. This is documented indocs/configuration.md,docs/upgrading.mdandCHANGELOG.md.APQ (#132)
applyPersistedno longer registers anything itself. It marks the request, andregisterPersistedregisters the document after the request authenticated (HTTP, after the role check) and afterExecutor.CheckDocumentpassed: parse, document limits and validation, through the document cache. Over WebSocket, registration happens afterPreparesucceeds.persisted_queries.max_bytes(8 MiB) andpersisted_queries.max_entry_bytes(64 KiB). It replaces the FIFO of 1024 entries of any size.Root field errors under transactions (#131)
partialTxwith a savepoint per root field. This applies to a database error other than a serialization failure, when the context is still live. The other fields keep their values, and there is nopg:25P02, no pathlessinternalerror and no ERROR log.25P02stays only for skips after a non-field failure (a lost connection, an expired request) and for exhausted serialization retries. This is documented indocs/errors.md.Small items
server.request_timeoutmust be>= 1s;0used to disable it silently.near:reference whose SRID differs from the column's typmod SRID now fails at compile time withinvalid_argument, instead ofpg:XX000 invalid geometry(or an empty result). GeoJSON is still reprojected./schema.graphqlnow needs the same credentials as/graphql(sharedauthenticatehelper). Without valid credentials and with no anonymous role, it answers401, the same as__schema.Tests
limits_test.go), LIMIT on every SETOF shape and SRID rejection (srid_test.go), batch rerun and its exclusions (querytx_test.go), APQ auth, validation and byte bound (apq_test.go), SDL auth (routes_test.go), config validation.setof_e2e_test.go,TestTxQueryFieldErrorUnderRoleSwitching,apq_e2e_test.go(APQ and/schema.graphql),srid_e2e_test.go. Updated expectations inTestTxQueryFieldErrors.LIMIT 100on a set-returning function.go test -race ./...,go vet,golangci-lint, actlint-test,FuzzFilterandFuzzSpatial(10s each).