feat(logger): 开放敏感内容列表定制并增加敏感检测开关
Verify / verify (push) Canceled after 0s

- 将凭据片段列表提升为全局默认列表,新增 DefaultSensitiveList、NewSensitiveList、Extend 与 SafeWith,支持整体替换或在默认列表之上扩展
- 新增 SetSensitiveDetection 与 SensitiveDetectionEnabled,缺省开启敏感检测,关闭后日志副本不再按名称隐藏凭据字段
- 显式敏感列表、访问日志固定凭据头与 RedactKeys、SQL config_value 与 Redis 认证命令等固定策略不受开关影响
- 同步接入使用指南的能力清单与使用说明
This commit is contained in:
zhangdeman authored and trae-solo-agent committed 2026-11-29 16:39:50 +08:00
1 parent 90d47c0152
commit c25bc4528a
6 files changed
+307 -17

No files matched your search

+14
View File
@@ -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 (
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.