fix(ai): prevent customer iccid disclosure
This commit is contained in:
@@ -68,6 +68,33 @@ func TestNormalizeCustomerReplyHidesThrottlingDenial(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeCustomerReplyRedactsICCID(t *testing.T) {
|
||||
reply, err := NormalizeCustomerReply("设备号:37012617001708\nICCID 已查询到:**8986042302268012345**\n业务状态:正常")
|
||||
if err != nil {
|
||||
t.Fatalf("NormalizeCustomerReply() error = %v", err)
|
||||
}
|
||||
for _, forbidden := range []string{"8986042302268012345", "ICCID 已查询到"} {
|
||||
if strings.Contains(reply, forbidden) {
|
||||
t.Fatalf("ICCID leaked through normalized reply: %q", reply)
|
||||
}
|
||||
}
|
||||
for _, expected := range []string{"设备号:37012617001708", "业务状态:正常", restrictedICCIDFallback} {
|
||||
if !strings.Contains(reply, expected) {
|
||||
t.Fatalf("expected %q in sanitized reply: %q", expected, reply)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeCustomerReplyRedactsBareFormattedICCID(t *testing.T) {
|
||||
reply, err := NormalizeCustomerReply("查询结果:89 8604 2302 2680 12345")
|
||||
if err != nil {
|
||||
t.Fatalf("NormalizeCustomerReply() error = %v", err)
|
||||
}
|
||||
if strings.Contains(reply, "8604") || !strings.Contains(reply, restrictedICCIDFallback) {
|
||||
t.Fatalf("formatted ICCID was not redacted: %q", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPolicyGuardRejectsTotalCallsAndOversizedArguments(t *testing.T) {
|
||||
definition, err := DefaultRegistry.Resolve(toolx.BuiltinKnowledgeRetrieve.Code)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user