sync: 同步 v1.0.4 开源代码并脱敏

This commit is contained in:
MiFaZhan
2026-10-29 14:52:43 +08:00
parent 32e4316ee4
commit 6893e21f07
136 changed files with 9851 additions and 436 deletions
+11 -11
View File
@@ -127,8 +127,8 @@ func TestApplyBatchMixedGroups(t *testing.T) {
repo := NewRepository()
if err := repo.ApplyBatch(ctx, []Result{
{CardID: 1, Synced: true, ValueChanged: true, Imei: "865466070817587"}, // 值变更
{CardID: 2, Synced: true, ValueChanged: false}, // 心跳
{CardID: 3, Synced: false}, // 失败跳过
{CardID: 2, Synced: true, ValueChanged: false}, // 心跳
{CardID: 3, Synced: false}, // 失败跳过
{CardID: 4, Synced: true, ValueChanged: true, Imei: "111222333444555"}, // 从空到有值
}); err != nil {
t.Fatalf("ApplyBatch: %v", err)
@@ -156,12 +156,12 @@ func TestApplyBatchRejectsInvalidImeiValue(t *testing.T) {
repo := NewRepository()
malicious := []string{
"865466070817587'", // 引号逃逸
"865466070817587'; DROP TABLE x; --", // 注入尝试
"865466070817587 OR 1=1", // 逻辑注入
"abc", // 非数字
"865466070817587;999999999999999", // 分号拼接(本链路不支持多值)
strings.Repeat("9", 33), // 超长
"865466070817587'", // 引号逃逸
"865466070817587'; DROP TABLE x; --", // 注入尝试
"865466070817587 OR 1=1", // 逻辑注入
"abc", // 非数字
"865466070817587;999999999999999", // 分号拼接(本链路不支持多值)
strings.Repeat("9", 33), // 超长
}
for _, value := range malicious {
err := repo.ApplyBatch(ctx, []Result{
@@ -185,9 +185,9 @@ func TestApplyBatchAcceptsBoundaryLengths(t *testing.T) {
repo := NewRepository()
values := []string{
"865466070817587", // 15 位
"86546607081758712", // 17 位
strings.Repeat("9", 32), // varchar(32) 上限
"865466070817587", // 15 位
"86546607081758712", // 17 位
strings.Repeat("9", 32), // varchar(32) 上限
}
for i, value := range values {
cardID := int64(i + 1)