Skip to content

Commit

Permalink
fixed gosec errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Oct 13, 2023
1 parent c4459ec commit 1efa308
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion common/coin.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package common

import "strconv"
import (
"fmt"
"strconv"
)

func GetCoinType(coin string) (CoinType, error) {
coinInt, err := strconv.ParseInt(coin, 10, 32)
if err != nil {
return CoinType_Cmd, err
}
if coinInt < 0 || coinInt > 3 {
return CoinType_Cmd, fmt.Errorf("invalid coin type %d", coinInt)
}
// #nosec G701 always in range
return CoinType(coinInt), nil
}
6 changes: 4 additions & 2 deletions x/crosschain/client/querytests/in_tx_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (s *CliTestSuite) TestListInTxTrackersByChain() {
s.Run("ByOffset", func() {
step := 2
for i := 0; i < len(objs); i += step {
// #nosec G701 always positive
args := request(nil, uint64(i), uint64(step), false, 5)
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListInTxTrackerByChain(), args)
s.Require().NoError(err)
Expand All @@ -64,6 +65,7 @@ func (s *CliTestSuite) TestListInTxTrackersByChain() {
step := 2
var next []byte
for i := 0; i < len(objs); i += step {
// #nosec G701 always positive
args := request(next, 0, uint64(step), false, 5)
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListInTxTrackerByChain(), args)
s.Require().NoError(err)
Expand All @@ -84,7 +86,7 @@ func (s *CliTestSuite) TestListInTxTrackersByChain() {
var resp types.QueryAllInTxTrackerByChainResponse
s.Require().NoError(s.network.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
s.Require().NoError(err)
s.Require().Equal(len(objs), int(resp.Pagination.Total))
s.Require().Equal(uint64(len(objs)), resp.Pagination.Total)
s.Require().ElementsMatch(nullify.Fill(objs),
nullify.Fill(resp.InTxTracker),
)
Expand All @@ -96,6 +98,6 @@ func (s *CliTestSuite) TestListInTxTrackersByChain() {
var resp types.QueryAllInTxTrackerByChainResponse
s.Require().NoError(s.network.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
s.Require().NoError(err)
s.Require().Equal(0, int(resp.Pagination.Total))
s.Require().Equal(uint64(0), resp.Pagination.Total)
})
}
1 change: 1 addition & 0 deletions zetaclient/inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (ob *BitcoinChainClient) CheckReceiptForBtcTxHash(txHash string, vote bool)
if err != nil {
return "", err
}
// #nosec G701 always positive
event, err := GetBtcEvent(*tx, tss, uint64(block.Height), &ob.logger.WatchInTx)
if err != nil {
return "", err
Expand Down

0 comments on commit 1efa308

Please sign in to comment.