diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-08-11 21:44:53 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-08-11 21:44:53 +0900 |
| commit | 6c3458a5ec37a5b69957ad17c84de58984698f25 (patch) | |
| tree | be5c5716e7488fcf1bc1a58de0ded0b9238f34cb /src/Agent.Windows/Security/SecurityAudit.cs | |
| parent | b5ccecca01007f2a2459265df6d749fbfd31aa84 (diff) | |
Audit and align v1 runtime design
Diffstat (limited to 'src/Agent.Windows/Security/SecurityAudit.cs')
| -rw-r--r-- | src/Agent.Windows/Security/SecurityAudit.cs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Agent.Windows/Security/SecurityAudit.cs b/src/Agent.Windows/Security/SecurityAudit.cs index 8858c2b..616b08f 100644 --- a/src/Agent.Windows/Security/SecurityAudit.cs +++ b/src/Agent.Windows/Security/SecurityAudit.cs @@ -2,7 +2,8 @@ using System.Text.Json; namespace Agent.Windows.Security; -public sealed record SecurityAuditEvent(DateTimeOffset Timestamp, Guid TaskId, string Event, string Outcome, IReadOnlyDictionary<string, string> Data); +public sealed record SecurityAuditEvent(DateTimeOffset Timestamp, Guid TaskId, string Event, string Outcome, + IReadOnlyDictionary<string, string> Data, Guid? SessionId = null, string? ErrorCode = null); public interface ISecurityAuditSink { @@ -12,11 +13,12 @@ public interface ISecurityAuditSink public sealed class JsonLinesSecurityAuditSink(string path) : ISecurityAuditSink { private readonly object _sync = new(); + private static readonly JsonSerializerOptions Json = new(JsonSerializerDefaults.Web); public void Write(SecurityAuditEvent auditEvent) { string? directory = Path.GetDirectoryName(Path.GetFullPath(path)); if (directory is not null) Directory.CreateDirectory(directory); - string line = JsonSerializer.Serialize(auditEvent); + string line = JsonSerializer.Serialize(auditEvent, Json); lock (_sync) File.AppendAllText(path, line + Environment.NewLine); } } |
