Skip to content

Commit

Permalink
fix(actors): address codeql complaint
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Sep 12, 2024
1 parent 9425188 commit b83d320
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 60 deletions.
24 changes: 0 additions & 24 deletions chain/actors/builtin/multisig/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/crypto/blake2b"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -124,29 +123,6 @@ type ProposeReturn = msig{{.latestVersion}}.ProposeReturn
type ProposeParams = msig{{.latestVersion}}.ProposeParams
type ApproveReturn = msig{{.latestVersion}}.ApproveReturn

func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := msig{{.latestVersion}}.TxnIDParams{ID: msig{{.latestVersion}}.TxnID(id)}
if data != nil {
if data.Requester.Protocol() != address.ID {
return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester)
}
if data.Value.Sign() == -1 {
return nil, xerrors.Errorf("proposal value must be non-negative, was %s", data.Value)
}
if data.To == address.Undef {
return nil, xerrors.Errorf("proposed destination address must be set")
}
pser, err := data.Serialize()
if err != nil {
return nil, err
}
hash := blake2b.Sum256(pser)
params.ProposalHash = hash[:]
}

return actors.SerializeParams(&params)
}

func AllCodes() []cid.Cid {
return []cid.Cid{ {{range .versions}}
(&state{{.}}{}).Code(),
Expand Down
55 changes: 43 additions & 12 deletions chain/actors/builtin/multisig/message.go.template

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions chain/actors/builtin/multisig/message0.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions chain/actors/builtin/multisig/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/crypto/blake2b"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -244,29 +243,6 @@ type ProposeReturn = msig15.ProposeReturn
type ProposeParams = msig15.ProposeParams
type ApproveReturn = msig15.ApproveReturn

func txnParams(id uint64, data *ProposalHashData) ([]byte, error) {
params := msig15.TxnIDParams{ID: msig15.TxnID(id)}
if data != nil {
if data.Requester.Protocol() != address.ID {
return nil, xerrors.Errorf("proposer address must be an ID address, was %s", data.Requester)
}
if data.Value.Sign() == -1 {
return nil, xerrors.Errorf("proposal value must be non-negative, was %s", data.Value)
}
if data.To == address.Undef {
return nil, xerrors.Errorf("proposed destination address must be set")
}
pser, err := data.Serialize()
if err != nil {
return nil, err
}
hash := blake2b.Sum256(pser)
params.ProposalHash = hash[:]
}

return actors.SerializeParams(&params)
}

func AllCodes() []cid.Cid {
return []cid.Cid{
(&state0{}).Code(),
Expand Down

0 comments on commit b83d320

Please sign in to comment.