feat(dingtalk): enable secure multimodal image QA
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCompactImageDataURLForLogFullyRedactsImages(t *testing.T) {
|
||||
cases := []string{
|
||||
"data:image/png;base64,YWJj",
|
||||
"DATA:image/png;BASE64," + strings.Repeat("QUJD", 100),
|
||||
`{"image":"data:image\\/png;base64,TOPSECRET"}`,
|
||||
"data:image/png,%89PNG%0D%0A",
|
||||
"data:text/plain,NONIMAGESECRET",
|
||||
"data%3Aimage%2Fpng%3Bbase64%2CENCODEDSECRET",
|
||||
`data\u003aimage/png;base64,ESCAPEDSECRET`,
|
||||
}
|
||||
for _, raw := range cases {
|
||||
got := CompactImageDataURLForLog(raw)
|
||||
if !strings.Contains(got, "[image-data-redacted]") {
|
||||
t.Fatalf("CompactImageDataURLForLog(%q) = %q", raw, got)
|
||||
}
|
||||
for _, secret := range []string{"YWJj", "QUJD", "TOPSECRET", "%89PNG", "NONIMAGESECRET", "ENCODEDSECRET", "ESCAPEDSECRET"} {
|
||||
if strings.Contains(got, secret) {
|
||||
t.Fatalf("sanitized output retained %q: %q", secret, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user