fix(config-db): encrypt deployment configuration JSON at rest (CDB-1, WP1 task 1.8)
The flattened config embeds each bound data connection's decrypted protocol JSON, and PendingDeployments / DeployedConfigSnapshots stored it verbatim - the credentials dp:protocol:v1 protects on DataConnections sat in plaintext in two more tables and every backup. - DeploymentConfigSecretConverter (own DP purpose, dp:config:v1: prefix) on both ConfigurationJson columns: every write protected, reads accept legacy plaintext so un-migrated rows keep working. Schema-only contexts refuse the write. - DeploymentConfigSecretUpgrade: one-time startup re-protect from MigrationHelper (after the protocol upgrade). A startup backfill, not an EF migration, because the Data Protection key ring is not reachable from a SQL migration script. Plaintext-detecting (NOT LIKE prefix), paged by Id, binary compare-and-swap (both centrals may run it), idempotent, and not a startup gate (logged + retried next start). - No EF model change (has-pending-model-changes: none); no migration. Tests: SQLite round-trip (raw column has no secret, EF read equals original) for both tables, legacy plaintext readable then re-protected idempotently, schema-only write refused, and the upgrade on real SQL Server. PendingDeploymentRepositoryIntegrationTests now supplies a key ring. Deploy gate: upgrade both central nodes together (old binaries cannot read protected rows).
This commit is contained in:
@@ -66,6 +66,11 @@ public static class MigrationHelper
|
||||
|
||||
await DataConnectionSecretUpgrade.UpgradeAsync(dbContext, cancellationToken);
|
||||
|
||||
// CDB-1: re-protect deployment configuration JSON written before it was encrypted at
|
||||
// rest. Not a gate (plaintext rows stay readable); failures are logged and retried at
|
||||
// the next start.
|
||||
await DeploymentConfigSecretUpgrade.UpgradeAsync(dbContext, logger, cancellationToken);
|
||||
|
||||
// Safety-net normalizer: rewrite any already-persisted List attribute values from the
|
||||
// old array-of-strings JSON form to the new native-typed form. Idempotent and never
|
||||
// aborts startup for data reasons (per-row skip + log). Safe even if both central
|
||||
|
||||
Reference in New Issue
Block a user