fix(security): warn-only compatibility for deployed drivers + upgrade preflight (#815)
User decision: save, Test Connect, live browse and the deploy gate keep refusing out-of-namespace credential references, but an ALREADY-DEPLOYED driver must not fault at the upgrade restart or (Galaxy) at the next gateway reconnect, since ReopenAsync re-resolves Gateway.ApiKeySecretRef. - LegacyCredentialReferenceTracker (Core.Abstractions): the one, deprecated, call-site-chosen compatibility path. Running Galaxy (InitializeAsync, ReopenAsync, ack fallback) and OpcUaClient (session open) pass it and keep the pre-#815 semantics (case-insensitive prefixes, Galaxy file:, OpcUaClient literal pass-through) with a rate-limited Warning (driver/field/allowed form, never the value) and a credential-compat:<field> diagnostics entry (both drivers now implement IDriverDiagnostics). Browsers and probes pass none and stay hard-fail; Heidenhain has none. - Deploy-gate message names the migration. - Upgrade preflight: CredentialReferencePreflightService (admin nodes, once after ApplicationStarted, ConfigDb only, resolves nothing) logs a Warning per Draft row / Deployed-artifact finding; the /raw banner shows them plus Running drivers reporting warn-only use (driver-health diagnostics). - docs/security.md: exact replacement table (incl. the old form default env:MX_API_KEY, file:, un-namespaced secret:, casing changes), the ReopenAsync reconnect behaviour, the warn-only window and its removal. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+29
@@ -124,6 +124,35 @@ public sealed class OpcUaClientSecretResolutionTests
|
||||
resolved.Password.ShouldBe("pw");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// lmxopcua#815 warn-only compatibility (deprecated): the RUNNING driver's session open keeps the old semantics
|
||||
/// for an out-of-namespace value — a case-insensitive <c>secret:</c> resolves, anything else is a literal — and
|
||||
/// warns once; the browser (no tracker) refuses the same value (see the theory above).
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task The_running_driver_keeps_old_semantics_for_a_legacy_value_and_warns()
|
||||
{
|
||||
var warnings = new List<string>();
|
||||
var tracker = new LegacyCredentialReferenceTracker(DriverCredentialPolicy.OpcUaClientScope, "ouc", warnings.Add);
|
||||
var legacyOptions = new OpcUaClientDriverOptions
|
||||
{
|
||||
Password = $"SECRET:{KnownPwName}", // pre-#815: case-insensitive secret: resolved
|
||||
UserCertificatePassword = "env:NOT_A_REF", // pre-#815: only secret: resolved — a literal password
|
||||
};
|
||||
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
var resolved = await OpcUaClientSecretResolution.ResolveSecretRefsAsync(
|
||||
legacyOptions, FakeResolver(), CancellationToken.None, tracker);
|
||||
resolved.Password.ShouldBe(KnownPwValue);
|
||||
resolved.UserCertificatePassword.ShouldBe("env:NOT_A_REF");
|
||||
}
|
||||
|
||||
warnings.Count.ShouldBe(2); // one per field, rate-limited across the three session opens
|
||||
warnings.ShouldAllBe(w => !w.Contains(KnownPwValue));
|
||||
tracker.Diagnostics.Count.ShouldBe(2);
|
||||
}
|
||||
|
||||
private sealed class CountingResolver : ISecretResolver
|
||||
{
|
||||
public int Calls { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user