Repository navigation
feat(config): type secrets as such and read config from several files - #857
Draft
cjorge-thegraph wants to merge 1 commit into
Draft
cjorge-thegraph wants to merge 1 commit into
cjorge-thegraph wants to merge 1 commit into
Conversation
Dipper read its whole configuration from 1 JSON file, so every secret had to sit next to settings that are not secret, and the file could then only be kept as a secret, out of review. And the secret fields were typed unevenly: the RPC provider URLs, which carry API keys, and the Kafka password were plain values, and serde quoted a secret it could not read in the error, which ends up in a log. Secrets are now known by type: - `Hidden<T>` leaves a value it cannot deserialise out of the error, as does the signer key's hex adapter, and the Kafka `sasl_password`s become `Hidden<String>`. - `SecretUrl`, for `chain_client.providers` and `alerts.slack_webhook_url`, shows a URL with its scheme, host, port and the shape of its path, masking the user and password, query values, the fragment and every path segment but a version such as `v2`, with a short fingerprint when anything was masked: `https://mainnet.infura.io/v3/*** (fingerprint e1d789)`. A key can look like any word, so dipper does not guess which segment holds it; the fingerprint tells 2 keys apart. A URL that fails to parse is left out of the error. The config now comes from every file on the command line, merged in order: objects key by key, anything else replaced by the later file. The merged result is read once, so an unknown field is refused wherever it came from, and an error names the field (`db.password: ...`); a single file still reports its line and column. Secrets can stay inline in 1 file, as a test setup wants, or go in a later `secrets.json` that holds only the secret fields, kept in a Secret, so the ConfigMap holds none and can be reviewed. The READMEs and the manifest describe both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Replaces #848. Instead of
_filereferences andDIPPER__environment overrides, dipper now knows which fields are secrets by their type, and its configuration can come from several files merged in order.The problem: dipper read its whole configuration from 1 JSON file, so every secret sat next to settings that are not secret. The file could then only be kept as a secret, out of review. The secret fields were also typed unevenly:
Urls, and the Kafkasasl_passwordwas a plainStringwith hand-written redaction.invalid type: string "hunter2-secret", expected u32.Secrets known by type
Hidden<T>(dipper-core) leaves a value it can't deserialise out of the error, and so does the signer key's hex adapter. The error keeps its position.sasl_passwords in dipper-producer are nowHidden<String>. dipper-producer depends on dipper-core for this; it already depended onthegraph-core.SecretUrl(new) is used forchain_client.providersandalerts.slack_webhook_url.v2.https://mainnet.infura.io/v3/*** (fingerprint e1d789). 2 log lines can then be told to use the same key or not, without showing it./v2/rpc-key), so dipper doesn't guess which segment holds it; the fingerprint is what tells keys apart.ChainClientConfig::provider_urls()exposes the real URLs for connecting.Config from several files
dipper-service config.json [secrets.json ...]. Every argument is a file, merged in order: objects key by key, anything else (a string, a number, a list,null) replaced by the later file.deny_unknown_fieldsstill refuses a misspelt field in any file.serde_path_to_error(db.password: …). A single file still reports its line and column.config.jsonfree of secrets in the ConfigMap, reviewable in git, and adds asecrets.jsonholding only the secret fields. That file lives in a Secret, for example one External Secrets renders from the secret store.k8s/README.mdshows the shape ofsecrets.jsonand the extra mount andargs. It notes that a list (chain_client.providers) is replaced whole, and that a changed secret needs a restart. The main README lists the secret fields.Dropped from #848
_filereferencesDIPPER__environment overridesThat removes the review's findings on #848: ambiguous types, values in errors, map defaults wiped by an override, unreachable list items, and the UTF-8 panic.
Not done: a startup warning when a secret field sits inline in the 1st file while a 2nd is given, which would catch a secret committed to the ConfigMap. It is easy to add if wanted.
Tests
a_rejected_secret_is_left_out_of_the_error(dipper-core) failed onmainwith the quoted value above, and passes now.SecretUrl: hosted RPC URLs (Alchemy, Infura, Ankr, QuickNode), a word-like key, Slack, user-info, query and fragment, a URL with nothing to mask, fingerprints,Debug/Display, and rejected values.db.passwordandalerts.slack_webhook_urlwithout their values;rpc-keyin the output. The webhook test now checks that the host shows with the path masked.cargo +nightly fmt,cargo clippy --workspace --all-targets --all-features -D warningsand the workspace tests (950 in dipper-service) pass locally.🤖 Generated with Claude Code