fix(secrets-ui): preserve metadata on rotate + audit unexpected mutation/reveal failures

This commit is contained in:
Joseph Doherty
2026-07-15 17:31:34 -04:00
parent 0ab276dac0
commit 294f53b49a
8 changed files with 306 additions and 37 deletions
@@ -73,6 +73,15 @@ else
_error = "Unable to decrypt secret.";
outcome = AuditOutcome.Failure;
}
catch (Exception)
{
// Any other unexpected store/cipher fault (e.g. master key unavailable, timeout) must
// still be audited as a Failure and surfaced to the user, not left to tear down the
// circuit. The value is never shown.
_value = null;
_error = "Unable to reveal secret.";
outcome = AuditOutcome.Failure;
}
finally
{
_busy = false;
@@ -80,18 +89,26 @@ else
}
string actor = await SecretActorResolver.ResolveAsync(Services, AuthState);
await Audit.WriteAsync(
new AuditEvent
{
EventId = Guid.NewGuid(),
OccurredAtUtc = DateTimeOffset.UtcNow,
Actor = actor,
Action = "secret.reveal",
Outcome = outcome,
Category = "Secrets",
Target = Name.Value,
},
_cts.Token);
try
{
await Audit.WriteAsync(
new AuditEvent
{
EventId = Guid.NewGuid(),
OccurredAtUtc = DateTimeOffset.UtcNow,
Actor = actor,
Action = "secret.reveal",
Outcome = outcome,
Category = "Secrets",
Target = Name.Value,
DetailsJson = outcome == AuditOutcome.Failure ? "{\"reason\":\"error\"}" : null,
},
_cts.Token);
}
catch
{
// Best-effort audit; never let an audit-write fault surface into the event pipeline.
}
}
private void Hide()