Skip to content

Commit

Permalink
Fix gosec
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Jul 11, 2024
1 parent c94d844 commit 454a56b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func DoTypedWithBackoff[T any](cb TypedCallback[T], bo Backoff) (T, error) {
err error
)

// #nosec G703 error is propagated
_ = DoWithBackoff(func() error {
result, err = cb()
return err
Expand Down
17 changes: 13 additions & 4 deletions zetaclient/chains/bitcoin/observer/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,24 @@ func (ob *Observer) IsOutboundProcessed(

signer := ob.ZetacoreClient().GetKeys().GetOperatorAddress()

// not used with Bitcoin
const (
gasUsed = 0
gasPrice = 0
gasLimit = 0
)

msg := crosschaintypes.NewMsgVoteOutbound(
signer.String(),
cctx.Index,
res.TxID,

uint64(blockHeight), // #nosec G701 always positive
0, // gas used not used with Bitcoin
math.NewInt(0), // gas price not used with Bitcoin
0, // gas limit not used with Bitcoin
// #nosec G701 always positive
uint64(blockHeight),

gasUsed,
math.NewInt(gasPrice),
gasLimit,

math.NewUintFromBigInt(amountInSat),
chains.ReceiveStatus_success,
Expand Down
7 changes: 6 additions & 1 deletion zetaclient/zetacore/client_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"
"time"

"cosmossdk.io/errors"
"github.com/cenkalti/backoff/v4"
"github.com/pkg/errors"

"github.com/zeta-chain/zetacore/pkg/retry"
"github.com/zeta-chain/zetacore/x/crosschain/types"
Expand Down Expand Up @@ -165,11 +165,16 @@ func (c *Client) monitorVoteInboundResult(
}

func retryWithBackoff(call func() error, attempts int, minInternal, maxInterval time.Duration) error {
if attempts < 1 {
return errors.New("attempts must be positive")
}

bo := backoff.WithMaxRetries(
backoff.NewExponentialBackOff(
backoff.WithInitialInterval(minInternal),
backoff.WithMaxInterval(maxInterval),
),
// #nosec G701 always positive
uint64(attempts),
)

Expand Down

0 comments on commit 454a56b

Please sign in to comment.