Repository navigation
fix(db): keep the server's identity off seed rows read in literal mode - #2306
Merged
Merged
Conversation
A seed-file connection read in literal mode (SEED_LITERAL_VALUES) no longer signs in with the server's own Google identity when its password is empty. BigQuery and Firestore refuse it with a new sentence that names the mode, with the server-identity opt-in on or off. Studio marks such rows with a LITERAL_SEED_FILE symbol key in projectOperatorEntries; isServerWritten is the one definition of a server-written connection and admitServerIdentity reads it. The marker is framed in the provider cache key, so every other key stays byte for byte.
Review round 1: hold the BigQuery doc's quoted refusals to the code with a test, say in .env.example and the SEED_LITERAL_VALUES row that a literal-mode row never uses the server's identity, give ADDING_A_PROVIDER.md the third gate sentence, and correct comments on built-in samples and on where the cache key frames the managed part.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
17 tasks done
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.



A seed-file connection read in literal mode (
SEED_LITERAL_VALUES) no longer signs in with the server's own Google identity when its password is empty.BigQuery and Firestore refuse it with a sentence that names the mode, with or without
BIGQUERY_SERVER_CREDENTIALSorFIRESTORE_SERVER_CREDENTIALS.Literal mode exists for a seed file a platform writes from its users' data, so an empty password there is not the operator's grant.
With literal mode off nothing changes.
What changes
src/lib/types.ts:LITERAL_SEED_FILE, a symbol key on the footing ofTUNNEL_FAR_END, andWithLiteralSeedFile. It is not a field ofDatabaseConnectionor of the seed schema, so no seed file, request body or stored connection can carry it, andJSON.stringifydrops it from every response.src/lib/seed/index.ts:projectOperatorEntriessets the marker besideliteralon every operator entry read in literal mode; this is the only place it is set. Discovered and governed rows carryliteralbut never the marker, and built-in samples carry neither.src/lib/db/auth/server-identity-gate.ts:isServerWritten(connection)ismanaged === trueand no marker.admitServerIdentitytakes the record, refuses withunmanaged, then the newliteralSeedFilesentence, thenwithoutOptIn, and reads the opt-in only last.src/lib/db/auth/google/credentials.ts:resolveGoogleCredentialtakes the connection record (password,managedand the marker) instead of{ text, managed }; both providers pass the record they were given.src/lib/db/provider-cache-key.ts:credentialDigestframes the marker last and only when set, so a provider opened with literal mode off is never served to a marked row, and every other key stays byte for byte.literalSeedFilesentence.docs/SEED_CONNECTIONS.md(literal-mode section and theSEED_LITERAL_VALUESrow),.env.example(the two server-credential variables andSEED_LITERAL_VALUES),docs/ADDING_A_PROVIDER.md(the gate's three sentences),docs/DB_AUTH.md(root pieces, server identity),docs/providers/bigquery.mdanddocs/providers/firestore.md(the condition and the quoted sentence),docs/SECURITY.mdcontrol 3.40, anddocs/BACKLOG.mdD85's pinned count (60 to 61, for the new API test's@/lib/authmock).User-visible changes
Both apply only to a row of a seed file read in literal mode whose password is empty.
"true", the row signed in with the server's own Google identity; it is now refused with theliteralSeedFilesentence, and no token is requested and no request is senttests/api/db/literal-seed-server-identity.test.ts, both providers'credential-policy.test.ts,tests/integration/db/bigquery-provider.test.ts,tests/integration/db/firestore-provider.test.tswithoutOptInsentence; it is now theliteralSeedFilesentencetests/api/db/literal-seed-server-identity.test.tsThe new sentences:
Nothing changes for a seed row read with the mode off, a governed row, a discovered row, a connection a browser sends, or a row with a credential in its password field.
An operator whose literal-mode seed file relied on the server's identity puts a credential on the row, or reads that file with the mode off.
Tests
tests/api/db/literal-seed-server-identity.test.tswas written first and was red: throughPOST /api/db/query, a literal-mode row with an empty password is refused with its sentence and zero requests, with the opt-in on and off; a provider opened with the mode off is not served once the mode is on; the same file with the mode off signs in as the server.server-identity-gate.test.ts: theisServerWrittentruth table and the gate's three refusals in order.tests/unit/db/bigquery/credential-policy.test.ts:docs/providers/bigquery.mdquotes each of BigQuery's three refusal sentences as the code words it, as Firestore's doc test already does.provider-cache-key.test.ts: the same record with and without the marker gets different keys; amanaged: truerecord without it keeps its key byte for byte.index.test.ts,index-kubernetes-discovery.test.ts,literal-values.test.ts,resolve-connection.test.ts) andvisible.test.ts: the marker is on every operator entry in literal mode on both lookups and on the resolved row, and never on a discovered (CapRover, Kubernetes with the review on and off), sample or governed row.Test plan
The full gate and coverage run in CI.