- 将凭据片段列表提升为全局默认列表,新增 DefaultSensitiveList、NewSensitiveList、Extend 与 SafeWith,支持整体替换或在默认列表之上扩展 - 新增 SetSensitiveDetection 与 SensitiveDetectionEnabled,缺省开启敏感检测,关闭后日志副本不再按名称隐藏凭据字段 - 显式敏感列表、访问日志固定凭据头与 RedactKeys、SQL config_value 与 Redis 认证命令等固定策略不受开关影响 - 同步接入使用指南的能力清单与使用说明
This commit is contained in:
1 parent
90d47c0152
commit
c25bc4528a
6 files changed
+307
-17
No files matched your search
@@ -9,6 +9,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/ginframework/logger/storagevalue"
|
||||
|
||||
mysqlDriver "github.com/go-sql-driver/mysql"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest/observer"
|
||||
@@ -48,6 +50,18 @@ type sqlObservationRow struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
// TestDisabledSensitiveDetectionKeepsCredentialSQLPolicy 验证关闭敏感检测后凭据语句不再整条隐藏,config_value 仍按固定策略隐藏。
|
||||
func TestDisabledSensitiveDetectionKeepsCredentialSQLPolicy(t *testing.T) {
|
||||
storagevalue.SetSensitiveDetection(false)
|
||||
defer storagevalue.SetSensitiveDetection(true)
|
||||
if got := RedactSQL("SELECT ? AS token"); got != "SELECT ? AS token" {
|
||||
t.Fatalf("credential SQL still hidden: %s", got)
|
||||
}
|
||||
if got := RedactSQL("UPDATE setting SET config_value='private-value'"); got != "[REDACTED SQL]" {
|
||||
t.Fatalf("config_value SQL was not hidden: %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSQLExecutionLogsOnce 验证真实 ORM 执行只输出一次插值后的完整 SQL,不重复记录模板或参数。
|
||||
func TestSQLExecutionLogsOnce(t *testing.T) {
|
||||
var (
|
||||
|
||||