feat(dingtalk): enable secure multimodal image QA
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user