From b81c608c45ee8af66ac9ecd2616921adb3640837 Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Thu, 16 Jan 2025 15:32:20 +0530 Subject: [PATCH] nix: use golangci-lint compatible with go 1.22 --- nix/overlay.nix | 6 +++--- params/config.go | 3 ++- protocol/communities/persistence.go | 2 ++ services/wallet/token/token.go | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/nix/overlay.nix b/nix/overlay.nix index 2f98e77de7d..53b3e5773a8 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -31,14 +31,14 @@ in rec { golangci-lint = prev.golangci-lint.override { buildGoModule = args: prev.buildGo122Module ( args // rec { - version = "1.54.0"; + version = "1.59.1"; src = prev.fetchFromGitHub { owner = "golangci"; repo = "golangci-lint"; rev = "v${version}"; - hash = "sha256-UXN5gN1SNv3uvBCliJQ+5PSGHRL7RyU6pmZtGUTFsrQ="; + hash = "sha256-VFU/qGyKBMYr0wtHXyaMjS5fXKAHWe99wDZuSyH8opg="; }; - vendorHash = "sha256-jUlK/A0HxBrIby2C0zYFtnxQX1bgKVyypI3QdH4u/rg="; + vendorHash = "sha256-yYwYISK1wM/mSlAcDSIwYRo8sRWgw2u+SsvgjH+Z/7M="; }); }; diff --git a/params/config.go b/params/config.go index 9bb5df3392c..2b733b06cab 100644 --- a/params/config.go +++ b/params/config.go @@ -1128,7 +1128,8 @@ func (c *NodeConfig) Save() error { } configFilePath := filepath.Join(c.DataDir, "config.json") - if err := ioutil.WriteFile(configFilePath, data, os.ModePerm); err != nil { + // G306: Expect WriteFile permissions to be 0600 or less (gosec) + if err := ioutil.WriteFile(configFilePath, data, 0600); err != nil { return err } diff --git a/protocol/communities/persistence.go b/protocol/communities/persistence.go index 84e20645e05..d88226e4569 100644 --- a/protocol/communities/persistence.go +++ b/protocol/communities/persistence.go @@ -2098,6 +2098,7 @@ func (p *Persistence) GetCommunityRequestsToJoinRevealedAddresses(communityID [] func (p *Persistence) GetEncryptionKeyRequests(communityID []byte, channelIDs map[string]struct{}) (map[string]*EncryptionKeysRequestRecord, error) { result := map[string]*EncryptionKeysRequestRecord{} + //nolint:gosec query := "SELECT channel_id, requested_at, requested_count FROM community_encryption_keys_requests WHERE community_id = ? AND channel_id IN (?" + strings.Repeat(",?", len(channelIDs)-1) + ")" args := make([]interface{}, 0, len(channelIDs)+1) @@ -2158,6 +2159,7 @@ func (p *Persistence) UpdateAndPruneEncryptionKeyRequests(communityID types.HexB } // Delete entries that do not match the channelIDs list + //nolint:gosec deleteQuery := "DELETE FROM community_encryption_keys_requests WHERE community_id = ? AND channel_id NOT IN (?" + strings.Repeat(",?", len(channelIDs)-1) + ")" args := make([]interface{}, 0, len(channelIDs)+1) args = append(args, communityID) diff --git a/services/wallet/token/token.go b/services/wallet/token/token.go index fa47b7b565f..46ea7e69443 100644 --- a/services/wallet/token/token.go +++ b/services/wallet/token/token.go @@ -820,6 +820,7 @@ func (tm *Manager) GetCachedBalancesByChain(accounts, tokenAddresses []common.Ad chainIDStrings[i] = fmt.Sprintf("%d", chainID) } + //nolint: gosec query := `SELECT chain_id, user_address, token_address, raw_balance FROM token_balances WHERE user_address IN (` + strings.Join(accountStrings, ",") + `)