Skip to content

Commit

Permalink
imp(statemachine)!: if the allow all host messages wildcard is used, …
Browse files Browse the repository at this point in the history
…then the allow list should have only one element (cosmos#5461)

Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
  • Loading branch information
crodriguezvega and DimitrisJim committed Dec 20, 2023
1 parent 2d0d94a commit a89b95a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/apps/27-interchain-accounts/host/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"slices"
"strings"
)

Expand Down Expand Up @@ -29,6 +30,10 @@ func (p Params) Validate() error {
}

func validateAllowlist(allowMsgs []string) error {
if slices.Contains(allowMsgs, AllowAllHostMsgs) && len(allowMsgs) > 1 {
return fmt.Errorf("allow list must have only one element because the allow all host messages wildcard (%s) is present", AllowAllHostMsgs)
}

for _, typeURL := range allowMsgs {
if strings.TrimSpace(typeURL) == "" {
return fmt.Errorf("parameter must not contain empty strings: %s", allowMsgs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ func TestValidateParams(t *testing.T) {
require.NoError(t, types.NewParams(false, []string{}).Validate())
require.Error(t, types.NewParams(true, []string{""}).Validate())
require.Error(t, types.NewParams(true, []string{" "}).Validate())
require.Error(t, types.NewParams(true, []string{"*", "/cosmos.bank.v1beta1.MsgSend"}).Validate())
}

0 comments on commit a89b95a

Please sign in to comment.