feat(dingtalk): enable secure multimodal image QA
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBuildLangfuseMessagesRedactsMultiContentImage(t *testing.T) {
|
||||
secret := "TOPSECRETBASE64"
|
||||
msgs := buildLangfuseMessages([]Message{{
|
||||
Role: "user",
|
||||
MultiContent: []MessageContentPart{
|
||||
{Type: "image_url", ImageURL: &ImageURL{URL: "data:image/png;base64," + secret}},
|
||||
{Type: "text", Text: "describe"},
|
||||
},
|
||||
}})
|
||||
encoded, err := json.Marshal(msgs)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
serialized := string(encoded)
|
||||
if strings.Contains(serialized, secret) || strings.Contains(strings.ToLower(serialized), "data:image") {
|
||||
t.Fatalf("Langfuse input leaked image payload: %s", serialized)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user