this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: validate client_type against allowed values

Reject unknown client_type values in ClientFilter.Validate().
Allowed values: irc, slack, discord, api, web.

+17
+5
internal/data/client_filter_test.go
··· 92 92 filter: ClientFilter{ClientNetwork: strPtr("libera"), ClientChannel: strPtr("#general")}, 93 93 wantError: true, 94 94 }, 95 + { 96 + name: "invalid client_type is rejected", 97 + filter: ClientFilter{ClientType: strPtr("foobar")}, 98 + wantError: true, 99 + }, 95 100 } 96 101 97 102 for _, tt := range tests {
+12
internal/data/store.go
··· 86 86 ClientUserName *string `json:"client_user_name,omitempty"` 87 87 } 88 88 89 + // ValidClientTypes is the set of allowed client_type values. 90 + var ValidClientTypes = map[string]bool{ 91 + "irc": true, 92 + "slack": true, 93 + "discord": true, 94 + "api": true, 95 + "web": true, 96 + } 97 + 89 98 type ClientFilter struct { 90 99 ClientType *string 91 100 ClientNetwork *string ··· 99 108 // Validate checks that hierarchical filter dependencies are satisfied. 100 109 // client_network requires client_type, and client_channel requires both. 101 110 func (f ClientFilter) Validate() error { 111 + if f.ClientType != nil && !ValidClientTypes[*f.ClientType] { 112 + return fmt.Errorf("invalid client_type: must be one of irc, slack, discord, api, web") 113 + } 102 114 if f.ClientNetwork != nil && f.ClientType == nil { 103 115 return fmt.Errorf("client_network requires client_type") 104 116 }