fix: deserialize should only expose @exposed fields#78
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens the @expose security contract by ensuring deserialization only materializes fields explicitly marked with @expose, preventing accidental leakage of unexposed columns (e.g. secrets) from bare .from().execute() results and from scalar subqueries that deserialize record composites.
Changes:
- Adds
@expose-awaredeserializeRowsfiltering (drops unmarked columns when an exposed-field Set is present). - Extends
Record.of(...)to accept an optional exposed-field Set so scalar subqueries (.scalar()) can filter composite record deserialization. - Adds RPC tests covering multiple selection shapes for
@exposegating (but scalar cases currently lack assertions).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util.ts | Adds expose-aware deserializeRows implementation and duck-typed deserializable check. |
| src/types/overrides/record.ts | Updates Record.of to optionally filter deserialized composite fields by exposed set. |
| src/rpc.test.ts | Adds RPC tests for @expose gating across query shapes (scalar cases currently only log). |
| src/exoeval/tool.ts | Adds exposedFieldsOf() helper to extract exposed-field Set from marker-bearing instances. |
| src/database.ts | Routes query/mutation execution through new deserializeRows(..., exposedFieldsOf(output)). |
| src/builder/query.ts | Removes old deserializeRows implementation; updates scalar subquery path to pass exposed fields into Record.of. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+277
to
+279
| // What do the embedded Record array elements contain? Should NOT have password. | ||
| // eslint-disable-next-line no-console | ||
| console.log("[scalar many] rows:", JSON.stringify(rows)); |
26bac25 to
e627194
Compare
aedb53a to
ade7903
Compare
Comment on lines
+73
to
+77
| throw new Error( | ||
| `deserializeRows: output column '${k}' is not a typed pg expression (got ${JSON.stringify(type)}). ` + | ||
| `The select callback must return an object whose values are Any instances.`, | ||
| ); | ||
| } |
Comment on lines
+60
to
+64
| if (exposed == null) { | ||
| throw new Error( | ||
| `deserializeRows: expected a plain object or an @expose-marked table instance as shape, got ${JSON.stringify(shape)}`, | ||
| ); | ||
| } |
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.
No description provided.