From 670dc398e4d0ca5824b0c4b15b643b49a2a93bc1 Mon Sep 17 00:00:00 2001 From: 0xmuralik Date: Tue, 18 Oct 2022 12:14:29 +0530 Subject: [PATCH] nosec G705 --- app/app.go | 2 ++ go.mod | 2 +- go.sum | 4 ++-- gql/util.go | 1 + rpc/ethereum/pubsub/pubsub.go | 2 ++ rpc/namespaces/ethereum/eth/filters/api.go | 1 + rpc/namespaces/ethereum/eth/filters/filter_system.go | 1 + rpc/websockets.go | 1 + tests/rpc/rpc_test.go | 3 --- x/evm/simulation/operations.go | 6 ++---- x/evm/statedb/journal.go | 1 + x/evm/statedb/state_object.go | 1 + x/nameservice/genesis.go | 2 +- 13 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/app.go b/app/app.go index 14957358..c5153a40 100644 --- a/app/app.go +++ b/app/app.go @@ -768,6 +768,7 @@ func (app *EthermintApp) LoadHeight(height int64) error { // ModuleAccountAddrs returns all the app's module account addresses. func (app *EthermintApp) ModuleAccountAddrs() map[string]bool { modAccAddrs := make(map[string]bool) + // #nosec G705 for acc := range maccPerms { modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true } @@ -779,6 +780,7 @@ func (app *EthermintApp) ModuleAccountAddrs() map[string]bool { // allowed to receive external tokens. func (app *EthermintApp) BlockedAddrs() map[string]bool { blockedAddrs := make(map[string]bool) + // #nosec G705 for acc := range maccPerms { blockedAddrs[authtypes.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc] } diff --git a/go.mod b/go.mod index 5d5827c1..7d6be002 100644 --- a/go.mod +++ b/go.mod @@ -198,7 +198,7 @@ require ( golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 // indirect golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect - golang.org/x/sys v0.0.0-20220908150016-7ac13a9a928d // indirect + golang.org/x/sys v0.0.0-20220913175220-63ea55921009 // indirect golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.93.0 // indirect diff --git a/go.sum b/go.sum index 40152fef..6b4c5a8e 100644 --- a/go.sum +++ b/go.sum @@ -1456,8 +1456,8 @@ golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908150016-7ac13a9a928d h1:RoyzQTK76Rktm3p4xyZslc8T8I1tBz4UEjZCzeh57mM= -golang.org/x/sys v0.0.0-20220908150016-7ac13a9a928d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220913175220-63ea55921009 h1:PuvuRMeLWqsf/ZdT1UUZz0syhioyv1mzuFZsXs4fvhw= +golang.org/x/sys v0.0.0-20220913175220-63ea55921009/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= diff --git a/gql/util.go b/gql/util.go index f510b511..4cfe9578 100644 --- a/gql/util.go +++ b/gql/util.go @@ -193,6 +193,7 @@ func mapToKeyValuePairs(attrs map[string]interface{}) ([]*KeyValue, error) { trueVal := true falseVal := false + // #nosec G705 for key, value := range attrs { kvPair := &KeyValue{ Key: key, diff --git a/rpc/ethereum/pubsub/pubsub.go b/rpc/ethereum/pubsub/pubsub.go index 4ac7f34c..176bbec9 100644 --- a/rpc/ethereum/pubsub/pubsub.go +++ b/rpc/ethereum/pubsub/pubsub.go @@ -124,6 +124,7 @@ func (m *memEventBus) closeAllSubscribers(name string) { subsribers := m.subscribers[name] delete(m.subscribers, name) + // #nosec G705 for _, sub := range subsribers { close(sub) } @@ -134,6 +135,7 @@ func (m *memEventBus) publishAllSubscribers(name string, msg coretypes.ResultEve subsribers := m.subscribers[name] m.subscribersMux.RUnlock() + // #nosec G705 for _, sub := range subsribers { select { case sub <- msg: diff --git a/rpc/namespaces/ethereum/eth/filters/api.go b/rpc/namespaces/ethereum/eth/filters/api.go index 1e0461cc..2d598ff7 100644 --- a/rpc/namespaces/ethereum/eth/filters/api.go +++ b/rpc/namespaces/ethereum/eth/filters/api.go @@ -102,6 +102,7 @@ func (api *PublicFilterAPI) timeoutLoop() { for { <-ticker.C api.filtersMu.Lock() + // #nosec G705 for id, f := range api.filters { select { case <-f.deadline.C: diff --git a/rpc/namespaces/ethereum/eth/filters/filter_system.go b/rpc/namespaces/ethereum/eth/filters/filter_system.go index 9b756685..b16b2cbb 100644 --- a/rpc/namespaces/ethereum/eth/filters/filter_system.go +++ b/rpc/namespaces/ethereum/eth/filters/filter_system.go @@ -240,6 +240,7 @@ func (es *EventSystem) eventLoop() { delete(es.index[f.typ], f.id) var channelInUse bool + // #nosec G705 for _, sub := range es.index[f.typ] { if sub.event == f.event { channelInUse = true diff --git a/rpc/websockets.go b/rpc/websockets.go index 181bb3a3..179c996d 100644 --- a/rpc/websockets.go +++ b/rpc/websockets.go @@ -173,6 +173,7 @@ func (s *websocketsServer) readLoop(wsConn *wsConn) { subscriptions := make(map[rpc.ID]pubsub.UnsubscribeFunc) defer func() { // cancel all subscriptions when connection closed + // #nosec G705 for _, unsubFn := range subscriptions { unsubFn() } diff --git a/tests/rpc/rpc_test.go b/tests/rpc/rpc_test.go index 83d9fd73..95c46a8f 100644 --- a/tests/rpc/rpc_test.go +++ b/tests/rpc/rpc_test.go @@ -87,7 +87,6 @@ func call(t *testing.T, method string, params interface{}) *Response { require.NoError(t, err) time.Sleep(1 * time.Second) - /* #nosec */ res, err := http.Post(HOST, "application/json", bytes.NewBuffer(req)) require.NoError(t, err) @@ -110,7 +109,6 @@ func callWithError(method string, params interface{}) (*Response, error) { } time.Sleep(1 * time.Second) - /* #nosec */ res, err := http.Post(HOST, "application/json", bytes.NewBuffer(req)) if err != nil { return nil, err @@ -246,7 +244,6 @@ func TestEth_GetFilterChanges_WrongID(t *testing.T) { req, err := json.Marshal(createRequest("eth_getFilterChanges", []string{"0x1122334400000077"})) require.NoError(t, err) - /* #nosec */ res, err := http.Post(HOST, "application/json", bytes.NewBuffer(req)) require.NoError(t, err) diff --git a/x/evm/simulation/operations.go b/x/evm/simulation/operations.go index 9f4e8bbe..7f8960ca 100644 --- a/x/evm/simulation/operations.go +++ b/x/evm/simulation/operations.go @@ -32,13 +32,11 @@ import ( "github.com/ethereum/go-ethereum/crypto" ) +// #nosec 101 const ( - /* #nosec */ OpWeightMsgEthSimpleTransfer = "op_weight_msg_eth_simple_transfer" - /* #nosec */ OpWeightMsgEthCreateContract = "op_weight_msg_eth_create_contract" - /* #nosec */ - OpWeightMsgEthCallContract = "op_weight_msg_eth_call_contract" + OpWeightMsgEthCallContract = "op_weight_msg_eth_call_contract" ) const ( diff --git a/x/evm/statedb/journal.go b/x/evm/statedb/journal.go index 49f61c00..5e96cf1b 100644 --- a/x/evm/statedb/journal.go +++ b/x/evm/statedb/journal.go @@ -53,6 +53,7 @@ func newJournal() *journal { func (j *journal) sortedDirties() []common.Address { keys := make([]common.Address, len(j.dirties)) i := 0 + // #nosec G705 for k := range j.dirties { keys[i] = k i++ diff --git a/x/evm/statedb/state_object.go b/x/evm/statedb/state_object.go index 3ebb800c..3717b4bd 100644 --- a/x/evm/statedb/state_object.go +++ b/x/evm/statedb/state_object.go @@ -39,6 +39,7 @@ type Storage map[common.Hash]common.Hash func (s Storage) SortedKeys() []common.Hash { keys := make([]common.Hash, len(s)) i := 0 + // #nosec G705 for k := range s { keys[i] = k i++ diff --git a/x/nameservice/genesis.go b/x/nameservice/genesis.go index ccd198a5..ae6413b5 100644 --- a/x/nameservice/genesis.go +++ b/x/nameservice/genesis.go @@ -60,7 +60,7 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState { authorities := keeper.ListNameAuthorityRecords(ctx) authorityEntries := []types.AuthorityEntry{} - // #nosec + // #nosec G705 for name, record := range authorities { authorityEntries = append(authorityEntries, types.AuthorityEntry{ Name: name,