Files
gabrielvidal 8f06d50528 security(oauth,mcp): harden OAuth 2.1 validation, hosted account scoping and MCP guards
- Render inline 400 error pages on malformed /oauth/authorize requests (preventing DCR open redirects)
- Enforce client auth_method, redirect_uri matching, and failed-auth throttling on /oauth/token
- Flush accounts.json outside lock with compact JSON, idle client pruning, and POST link polling
- Block credential-named textareas/list columns and password inputs in MCP widgets
- Cap MCP field counts upfront, add untrusted-data framing, and pin card.html postMessage origin
2026-11-23 11:32:50 +01:00

39 lines
917 B
Go

package server
import (
"testing"
"github.com/GabrielVidal1/ask-form/internal/form"
)
func TestVetChatFieldsBlocksCredentialTextareasTablesAndPasswordWidgets(t *testing.T) {
cases := []struct {
name string
fields []form.Field
}{
{
name: "textarea named api_key",
fields: []form.Field{{Key: "api_key", Label: "API key", Type: form.Textarea}},
},
{
name: "list column named password",
fields: []form.Field{{
Key: "creds", Label: "Accounts", Type: form.List,
Cols: []form.Column{{Key: "password", Label: "Password", Type: form.Text}},
}},
},
{
name: "widget with password input",
fields: []form.Field{{
Key: "login", Label: "Sign in", Type: form.Widget,
HTML: `<input type="password" id="p">`,
}},
},
}
for _, tc := range cases {
if err := vetChatFields(tc.fields); err == nil {
t.Errorf("%s: expected vetChatFields to refuse", tc.name)
}
}
}