本文件以唯讀方式檢查程式 repo 目前的 audit / MySQL / schema / plugin 結構、候選檔案、測試基準與停止線。使用者尚未確認 5C 七項前,不修改程式 repo。
0. 檢查結論
| 項目 | 結論 |
|---|---|
| 5C 承接位置 | 第一批建議承接在 Application 層 audit contract / fake writer,不直接寫 MySQL。 |
| 既有 audit model | PluginAuditRecord 已存在,語意是安全摘要且明確不負責 DB 寫入。 |
| 既有 MySQL infrastructure | HS.DeviceControl.Infrastructure.MySql 已存在,含 schema、LogWriter、TaskTraceStore、TaskStore 與 manual-only 測試入口。 |
| 本批不建議修改 | 不直接改 MySQL writer、不新增 table、不改既有 DB public contract。 |
1. 候選新增 / 修改檔案
| 類型 | 候選檔案 | 建議 |
|---|---|---|
| Audit model | src/HS.DeviceControl.Application/Auditing/AuditEventRecord.cs | 新增最小 audit event record,保存安全摘要欄位。 |
| Audit writer | src/HS.DeviceControl.Application/Auditing/IAuditEventWriter.cs | 建立 writer contract,不綁 MySQL。 |
| Fake writer | src/HS.DeviceControl.Application/Auditing/InMemoryAuditEventWriter.cs | 提供測試與本機驗證用 fake writer。 |
| Tests | tests/HS.DeviceControl.Application.Tests | 新增 audit event record、writer、敏感資訊遮蔽測試。 |
2. 測試基準
| 測試 | 結果 |
|---|---|
dotnet test tests\HS.DeviceControl.Application.Tests\HS.DeviceControl.Application.Tests.csproj --no-restore | 57 passed / 0 failed / 0 skipped |
dotnet test tests\HS.DeviceControl.Infrastructure.MySql.Tests\HS.DeviceControl.Infrastructure.MySql.Tests.csproj --no-restore | 89 passed / 0 failed / 0 skipped |
dotnet test HS.DeviceControl.sln --no-restore | 516 passed / 0 failed / 0 skipped |
3. 明確停止線
- 不新增正式 audit table。
- 不執行 DDL / ALTER TABLE / formal Apply。
- 不對真實 DB 寫入。
- 不保存 secret、token、connection string、完整路徑、正式 IP、正式 port 或 raw payload。
- 不改既有 MySQL public contract。
- 不做 auth / Swagger 或 Windows Service。
4. 下一步
請等待使用者回覆 5C DB audit 實作前確認表 七項同意後,再進入程式 repo 的第一批 audit contract / fake writer 實作。