Repository navigation
Redact graph source config secrets - #1534
Conversation
aaj3f
left a comment
There was a problem hiding this comment.
✅ Approve.
Well-executed credential-disclosure fix. The CLI's info/iceberg info print paths serialized stored graph-source configs with to_string_pretty and no redaction, dumping live OAuth2 client secrets and bearer tokens to the terminal, while the server route already redacted.
The fix consolidates all rendering into one module that routes through the existing fail-closed redactor, deletes the duplicated leak sites, and hardens the shared redactor for container-shaped secrets and unparseable configs — with the redaction property captured as a tested invariant so a future refactor that drops the call fails the suite.
I verified the denylist covers the two secrets that actually serialize (token, client_secret), that the env-var preservation matches the ConfigValue wire shape precisely, that no other CLI config-print path was missed, and that lossless persistence is untouched. The depth is right: it fixes at the API layer so CLI and server share one redactor.
Adherence to repo commitments
- Patterns/abstractions: ✔ Extends
redact_graph_source_config/build_generic_graph_source_info; collapses three duplicated helpers into one. - Performance (speed first, memory second): ✔ CLI display path only, off the query engine — no regression risk.
- Testing: ✔ New render-seam tests + API container-shape/empty-config tests; ran locally at HEAD → 147 passed, 0 failed. Existing per-variant canaries and lossless-storage assertions still pass.
- Conventions:
⚠️ Clippy-clean (incl. 23 denied lints) andfmt-clean; only gap is the PR title / intermediate commit messages not using thefix(cli):conventional-commit prefix that feeds release notes. No AI-attribution trailers.
Verified locally at branch HEAD: traced secret-key coverage against the real AuthConfig/ConfigValue serialization, swept the CLI crate for missed print paths, confirmed no feature-gating coverage trap, re-ran the targeted redaction/render tests.
Recommend merge.
| let lower = key.to_ascii_lowercase(); | ||
| SECRET_REF_SAFE_KEYS.iter().any(|s| *s == lower) | ||
| } | ||
|
|
There was a problem hiding this comment.
Optional (residual risk, already tracked). SECRET_CONFIG_KEYS is a key-name allowlist, so a secret stored under a key not on the list still prints in the clear — the container-shape hardening only triggers when the outer key is already a secret key.
This is the documented "fails open" behavior tracked in #1504, and this PR correctly brings the CLI to parity with the server rather than solving it here. No change requested; flagging only so the guarantee's edge is explicit in the review record.
| let mut redacted = false; | ||
| match value { | ||
| JsonValue::Object(map) => { | ||
| for (k, v) in map.iter_mut() { |
There was a problem hiding this comment.
Optional (note, not a defect). redact_secret_subtree preserves a string value under any key named env_var/java_property at any depth inside a secret subtree.
That's the intended debugging affordance (those keys hold a name, not a value) and matches ConfigValue::Dynamic, so it's correct — worth only a mental note that a self-inflicted config storing a literal secret under a key literally named env_var would preserve it.
Reconcile graph-source secret redaction + CLI /info display refactor: - ledger_info.rs: union redact_json_secrets — keep lambda's ConfigValue::SecretRef preservation (is_secret_ref_object, checked first) AND main's #1534 fail-closed container handling (redact_secret_subtree / SECRET_REF_SAFE_KEYS). - cli iceberg.rs & info.rs: adopt main's unified graph_source_display module; drop the now-orphaned inline print/redact helpers and their tests (coverage moved to graph_source_display.rs).
PR fluree#1528 (big-Iceberg-audit implementation + browse-parity + family-C, approved by bplatz) was merged while its base still pointed at the scaffolding branch perf/audit-mainmerge-base, so its content landed there instead of main. This merges current main (carrying fluree#1520, fluree#1507, fluree#1514, fluree#1477) into the audit content so the combined tree can be proposed to main. Conflict resolutions: - fluree-db-iceberg/src/mor_guard.rs (add/add): family-C converged superset. Its W1/W2 fail-closed guard bodies are byte-identical to main's; it omits the ensure_summary_scannable / ensure_manifests_scannable planner helpers, which the family-C planners inline. Verified those helpers have no remaining callers. - fluree-db-iceberg/src/lib.rs, scan/planner.rs, scan/send_planner.rs: family-C inlined-guard arms (+ has_delete_manifests ScanPlan stamp). Main's non-conflict additions (parse_manifest_list_with_deletes, the F-AUD-1 mor_guard_tests fixtures) auto-merged and were preserved. - fluree-db-api/src/graph_source/iceberg_catalog.rs: main's W3-evolved preview stats guard (typed 409 error, hoisted allow_mor, table_display, preview_counts_are_upper_bounds) — a functional superset of the audit's older F-AUD-1 form. Its preview_summary_guard called the dropped ensure_summary_scannable; inlined that helper's body (mor_deletes_allowed + ensure_no_summary_deletes), matching how the family-C planners inline the same guard. - fluree-db-api/src/format/mod.rs: family-C crawl formatter (crawl uses format_node_object_binding; the format_binding_with_result re-export is unused). Gated the crawl-only formatter helpers and their Binding import behind the iceberg feature to clear a pre-existing fluree#1528 featureless dead-code gap. - fluree-db-api/src/ledger_info.rs: auto-merged as the union of main's fluree#1534 redaction machinery and the audit /info mor-approximate extensions.
Problem
fluree info <gs>andfluree iceberg info <gs>printed the full graph-source config as pretty JSON — includingcatalog.auth.client_secret, i.e. a live Snowflake PAT / OAuth2 client secret or bearer token.ConfigValuehas a redactingDebugimpl, but every CLI print path serializes via serde, which bypasses it, so the secret landed in terminal scrollback,scriptlogs, and CI output. The server routes already redact throughredact_graph_source_config; the CLI's local print paths were the unpatched surface. (A redactingSerializeon the type itself is not an option: persistence requires lossless serialization — CI-locked tests assert the stored config carries the secret for query-time catalog auth. The type-level fix,ConfigValue::SecretRef, is tracked separately in #1500 §3.)Fix
All CLI graph-source rendering now goes through a single new module,
fluree-db-cli/src/graph_source_display.rs, which routes every config through the existing fail-closed redactor before printing. Local nameservice records are converted withbuild_generic_graph_source_info— the same redacted DTO the server's/inforoute emits (nowpubinfluree-db-api) — so local and remote sources render identically through one renderer, and redaction happens at the API layer rather than being re-implemented per print site. Remote responses are re-redacted client-side as defense-in-depth against unredacting servers; the redactor is idempotent, so already-clean responses render unchanged.The refactor also collapses duplication this bug was hiding in: the two print functions existed verbatim in both
info.rsandiceberg.rs, and the source-type label mapping existed three times across the workspace (CLI ×1 after its own dedup, server ×1, plus the privategraph_source_type_labelinfluree-db-api). All of it now resolves to the one API helper, so a future label or field change cannot drift between the CLI, the server, and the API.Hardening beyond the original leak
fluree-db-api):redact_json_secretsonly masked scalar values under secret keys; a secret hidden in a container shape ({"token": ["tok-1"]},{"client_secret": {"value": "..."}}) passed through unredacted. Containers under a secret key are now redacted with inverted strictness — every scalar leaf inside is masked except theenv_var/java_propertyreference identifiers — closing the gap for hand-authored or out-of-band records while preserving the env-var debugging affordance. This hardens every consumer of the shared redactor (server/info, events route, CLI). Complements Harden redact_graph_source_config: denylist of secret key names fails open for future fields #1504, which tracks the key-name denylist failing open.[redacted:unparseable](matching the server-side semantics) instead of being silently omitted — an operator no longer concludes a misparsed (and possibly secret-bearing) config doesn't exist, and its raw bytes are never echoed.render_*functions returningString, and tests feed secret-bearing records and server responses through the real render seam, asserting the secrets are absent,[redacted]is present, and non-secret identifying fields (client id, scope, catalog URI) survive. A refactor that drops the redaction call now fails the suite instead of silently reintroducing the leak.User-visible output changes
client_secret,token, and other secret values print as"[redacted]"everywhere (the point of the PR).Retracted:whenever the field is present, so remote output for generic (BM25/Vector/Geo) sources gains that line; local output keeps it.Index ID:always prints, showing(none)when the source has no index; previously remote output omitted the line entirely."{}","{ }", and"{\n}"all suppress the Configuration section (previously only the byte-exact"{}"did, via a string comparison in the server DTO builder).[redacted:unparseable]instead of nothing.Verification
Unit tests cover the render seam end-to-end (secret masking local and remote, env-var name preservation, fail-closed unparseable, non-secret configs rendering in full) plus new API-side tests for container-shaped secrets and whitespace-variant empty configs; the existing per-variant redaction canaries and lossless-storage assertions all still pass, including under
--features iceberg. Verified live against the issue's reproduction:fluree iceberg map --oauth2-client-secret "$PAT" ...followed byfluree info <gs> --directandfluree iceberg info <gs>prints"client_secret": "[redacted]"with zero occurrences of the raw secret, while the stored nameservice record still carries it (persistence remains lossless). Clippy is clean andcargo fmt --checkpasses across the touched crates.Closes #1497