mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-07 07:03:34 +08:00
✅ test(audit): 修复脱敏断言随机误报
- 将敏感信息检查限定到 SQL 文本和错误字段 - 避免审计 UUID、时间戳及哈希短串碰撞导致误报
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -300,10 +298,10 @@ func TestBackendWriteWorkflowsRecordFixedAuditSources(t *testing.T) {
|
||||
if len(events) != 1 || events[0].Status != "error" {
|
||||
t.Fatalf("failing SQL file execution was not audited: %#v", events)
|
||||
}
|
||||
serialized, _ := json.Marshal(events[0])
|
||||
redactedPayload := events[0].SQLText + "\n" + events[0].Error
|
||||
for _, secret := range []string{"private-secret", "777", "private-failure.sql", "broken_proc"} {
|
||||
if bytes.Contains(serialized, []byte(secret)) {
|
||||
t.Fatalf("failing SQL file audit leaked %q: %s", secret, serialized)
|
||||
if strings.Contains(redactedPayload, secret) {
|
||||
t.Fatalf("failing SQL file audit payload leaked %q: %q", secret, redactedPayload)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user