Files
geo/server/internal/ops/app/desktop_bug_report_test.go

43 lines
1.1 KiB
Go

package app
import "testing"
func TestDropPublicDesktopBugIdentityFields(t *testing.T) {
fields := map[string]string{
"tenant_id": "1",
"_tenant_id": "2",
"workspace_id": "3",
"_workspace_id": "4",
"user_id": "5",
"_user_id": "6",
"client_id": "spoofed-client",
"_client_id": "spoofed-electron-client",
"desktop_client_id": "spoofed-desktop-client",
"_desktop_client_id": "spoofed-electron-desktop-client",
"title": "renderer crash",
"guid": "crash-guid",
}
sanitized := dropPublicDesktopBugIdentityFields(fields)
for _, key := range []string{
"tenant_id",
"_tenant_id",
"workspace_id",
"_workspace_id",
"user_id",
"_user_id",
"client_id",
"_client_id",
"desktop_client_id",
"_desktop_client_id",
} {
if _, ok := sanitized[key]; ok {
t.Fatalf("sanitized fields retained spoofable identity key %q", key)
}
}
if sanitized["title"] != "renderer crash" || sanitized["guid"] != "crash-guid" {
t.Fatalf("sanitized fields dropped non-identity metadata: %#v", sanitized)
}
}