Skip to content

Commit

Permalink
Merge pull request #167 from AssetMantle/0xankit/issuesFixes
Browse files Browse the repository at this point in the history
`baseReq` sanitization before `MakeMsg`
  • Loading branch information
deepanshutr authored Dec 9, 2022
2 parents 6442066 + 5cf07d9 commit b1b0ad7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions schema/helpers/base/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ func (transaction transaction) RESTRequestHandler(cliContext context.CLIContext)

baseReq := transactionRequest.GetBaseReq()

baseReq = baseReq.Sanitize()
if !baseReq.ValidateBasic(responseWriter) {
rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, "")
return
}

var msg sdkTypes.Msg
msg, err = transactionRequest.MakeMsg()
if err != nil {
rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error())
return
}

baseReq = baseReq.Sanitize()
if !baseReq.ValidateBasic(responseWriter) {
rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, "")
return
}

if err = msg.ValidateBasic(); err != nil {
rest.WriteErrorResponse(responseWriter, http.StatusBadRequest, err.Error())
return
Expand Down
4 changes: 3 additions & 1 deletion schema/lists/base/dataList.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ func (dataList dataList) GetList() []data.Data {
DataList := make([]data.Data, dataList.List.Size())

for i, listable := range dataList.List.Get() {
DataList[i] = listable.(data.Data)
if listable != nil {
DataList[i] = listable.(data.Data)
}
}

return DataList
Expand Down
3 changes: 2 additions & 1 deletion schema/lists/base/dataList_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func Test_dataList_GetList(t *testing.T) {
fields fields
want []data.Data
}{
{"+ve with empty struct", fields{list{}}, []data.Data{}}, // TODO: issue Panic for nil
{"+ve with empty struct", fields{list{}}, []data.Data{}},
{"+ve with empty struct", fields{list{nil}}, []data.Data{nil}},
{"+ve", fields{NewList(dataToListables([]data.Data{NewStringData("Data")}...)...)}, []data.Data{NewStringData("Data")}},
}
for _, tt := range tests {
Expand Down

0 comments on commit b1b0ad7

Please sign in to comment.