-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(*): add gosec #94
Changes from 13 commits
51aa327
7103090
dd140ca
cc0ceea
97f3890
96dd117
00be4cc
c68f0a9
7dc3493
2805163
6827c6a
5867cc0
b8bf34a
6b18caf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ func (c *Client) GetBestBlock() (uint32, error) { | |
return 0, err | ||
} | ||
|
||
if height < 0 || height > int64(^uint32(0)) { | ||
RafilxTenfen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
panic(fmt.Errorf("height (%d) is out of uint32 range", height)) //software bug, panic | ||
} | ||
|
||
return uint32(height), nil | ||
} | ||
|
||
|
@@ -34,7 +38,11 @@ func (c *Client) GetBlockByHash(blockHash *chainhash.Hash) (*types.IndexedBlock, | |
} | ||
|
||
btcTxs := types.GetWrappedTxs(mBlock) | ||
return types.NewIndexedBlock(int32(blockInfo.Height), &mBlock.Header, btcTxs), mBlock, nil | ||
height := blockInfo.Height | ||
if height < 0 || height > int64(^uint32(0)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems a bit overkill and removing this check and running There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will clean cache and try again There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeap, for me it doesn't appear the error $~ make gosec-local
Results:
Summary:
Gosec : 2.20.0
Files : 90
Lines : 10303
Nosec : 5
Issues : 0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you do any other configuration? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I was on a "dev" version. Fixed, thanks @RafilxTenfen There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah now the CI fails, so seems that we do need it, as our CI used the latest version. I'll be reverting this code then. And you should upgrade to latest version of gosec (2.21.4).
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
And try again @RafilxTenfen |
||
panic(fmt.Errorf("height (%d) is out of uint32 range", height)) //software bug, panic | ||
} | ||
return types.NewIndexedBlock(uint32(height), &mBlock.Header, btcTxs), mBlock, nil | ||
} | ||
|
||
// GetBlockByHeight returns a block with the given height | ||
|
@@ -51,7 +59,7 @@ func (c *Client) GetBlockByHeight(height uint32) (*types.IndexedBlock, *wire.Msg | |
|
||
btcTxs := types.GetWrappedTxs(mBlock) | ||
|
||
return types.NewIndexedBlock(int32(height), &mBlock.Header, btcTxs), mBlock, nil | ||
return types.NewIndexedBlock(height, &mBlock.Header, btcTxs), mBlock, nil | ||
} | ||
|
||
func (c *Client) getBestBlockHashWithRetry() (*chainhash.Hash, error) { | ||
|
@@ -153,7 +161,7 @@ func (c *Client) getBlockVerboseWithRetry(hash *chainhash.Hash) (*btcjson.GetBlo | |
// getChainBlocks returns a chain of indexed blocks from the block at baseHeight to the tipBlock | ||
// note: the caller needs to ensure that tipBlock is on the blockchain | ||
func (c *Client) getChainBlocks(baseHeight uint32, tipBlock *types.IndexedBlock) ([]*types.IndexedBlock, error) { | ||
tipHeight := uint32(tipBlock.Height) | ||
tipHeight := tipBlock.Height | ||
if tipHeight < baseHeight { | ||
return nil, fmt.Errorf("the tip block height %v is less than the base height %v", tipHeight, baseHeight) | ||
} | ||
|
@@ -201,7 +209,7 @@ func (c *Client) FindTailBlocksByHeight(baseHeight uint32) ([]*types.IndexedBloc | |
return nil, err | ||
} | ||
|
||
if baseHeight > uint32(tipIb.Height) { | ||
if baseHeight > tipIb.Height { | ||
return nil, fmt.Errorf("invalid base height %d, should not be higher than tip block %d", baseHeight, tipIb.Height) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,7 +22,7 @@ type SubmitterConfig struct { | |||||||||||||
// ResubmitFeeMultiplier is used to multiply the estimated bumped fee in resubmission | ||||||||||||||
ResubmitFeeMultiplier float64 `mapstructure:"resubmit-fee-multiplier"` | ||||||||||||||
// PollingIntervalSeconds defines the intervals (in seconds) between each polling of Babylon checkpoints | ||||||||||||||
PollingIntervalSeconds uint `mapstructure:"polling-interval-seconds"` | ||||||||||||||
PollingIntervalSeconds int64 `mapstructure:"polling-interval-seconds"` | ||||||||||||||
// ResendIntervalSeconds defines the time (in seconds) which the submitter awaits | ||||||||||||||
// before resubmitting checkpoints to BTC | ||||||||||||||
ResendIntervalSeconds uint `mapstructure:"resend-interval-seconds"` | ||||||||||||||
|
@@ -39,6 +39,10 @@ func (cfg *SubmitterConfig) Validate() error { | |||||||||||||
return errors.New("invalid resubmit-fee-multiplier, should not be less than 1") | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if cfg.PollingIntervalSeconds < 0 { | ||||||||||||||
return errors.New("invalid polling-interval-seconds, should not be less than 0") | ||||||||||||||
} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
return nil | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line