feat(dingtalk): enable secure multimodal image QA

This commit is contained in:
姚章浩
2026-07-16 00:17:16 +08:00
parent 4022040e98
commit c9c4f0aaa5
59 changed files with 3279 additions and 429 deletions
+26
View File
@@ -17,6 +17,32 @@ func newEntry(level logrus.Level, msg string, data logrus.Fields) *logrus.Entry
return e
}
func TestLLMCallRecordFormatRedactsDataURIInSectionsAndErrors(t *testing.T) {
secret := "TOPSECRETBASE64"
record := &LLMCallRecord{
Sections: []RecordSection{{Title: "Response", Content: "data:image/png;base64," + secret}},
Error: "provider echoed data:text/plain," + secret,
}
got := formatRecord(record)
if strings.Contains(got, secret) || strings.Contains(strings.ToLower(got), "data:") {
t.Fatalf("record leaked data URI: %q", got)
}
}
func TestFormatMessagesRedactsImageValues(t *testing.T) {
secret := "TOPSECRETBASE64"
got := FormatMessages([]LLMMessage{{
Role: "user",
Images: []string{"data:image/png;base64," + secret},
}})
if strings.Contains(got, secret) || strings.Contains(strings.ToLower(got), "data:image") {
t.Fatalf("FormatMessages leaked image value: %q", got)
}
if !strings.Contains(got, "redacted") {
t.Fatalf("FormatMessages missing redaction marker: %q", got)
}
}
func TestFormat_DefaultModeUnchanged(t *testing.T) {
f := &CustomFormatter{} // no template, no color
entry := newEntry(logrus.InfoLevel, "hello", logrus.Fields{