[Secrets] SqlServer extensions cannot pass contentRootPath — the store-path hole reopens in hub mode #31
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the scadaproj#15 shared-library review (
code-reviews/Secrets/findings.md, Secrets-002), verified at91fb2b4. Update the finding's Resolution row when fixed.ZB.MOM.WW.Secrets/src/ZB.MOM.WW.Secrets.Replicator.SqlServer/DependencyInjection/SqlServerSecretsServiceCollectionExtensions.cs:94(withZB.MOM.WW.Secrets/src/ZB.MOM.WW.Secrets/DependencyInjection/SecretsServiceCollectionExtensions.cs:76)Description
Both SQL-Server extensions call the 3-arg
AddZbSecrets(config, section), which usescontentRootPath: null. The validator registration is first-wins (SecretsServiceCollectionExtensions.cs:76), so:AddZbSecrets(..., contentRoot)cannot supply the content root.In a pre-host container (no
IHostEnvironment), the under-content-root rule is therefore skipped in hub-replication mode, where the local SQLite store is migrated. This is the exact0.6.0hole that the 4-arg overload exists to close. The family guidance ("use the 4-arg overload at every pre-host call site") cannot be followed with these extensions, and there is no registration order that gets both behaviours right.Failure scenario
The probe used hub mode with
Secrets:SqlitePath = <contentRoot>/data/s.db. It calledAddZbSecretsSqlServerReplication(cfg)and thenAddZbSecrets(cfg, "Secrets", contentRoot), then resolvedSqliteSecretsStoreMigrator, and no validation error was raised. The pre-host expander migrates an empty store inside the content root. The next deploy renames the directory, and the store is lost (the 2026-08-09 incident shape). Positive control: the same configuration with only the 4-argAddZbSecretsthrowsOptionsValidationException.Recommendation
Add a
string? contentRootPathparameter to both SQL-Server extensions and forward it. Also make the validator registration "last explicit content root wins" rather than first-wins, for example by storing the root in an options object that each call may set.Resolution
Unresolved.
Fixed on main 8e2d1e0 (Secrets-002 → Resolved): the three extensions take an optional trailing contentRootPath; the validator uses the last content root explicitly passed to any AddZbSecrets call (a later call without one never clears it). Before: hub-mode extension + 4-arg AddZbSecrets created the store inside the content root silently. Source-compatible; binaries built against 0.6.5 need a rebuild. Evidence: Secrets solution (5 test projects) all pass — Core 246 (1 DPAPI skip), SqlServer 60 (16 live-SQL skips), Akka 44, Grpc 196, Ui 20; each regression test fails with its fix removed. Ships in Secrets 0.6.6 (unpublished).