diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 96452bd..d8325c6 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: env: - GO_VER: 1.25.7 + GO_VER: 1.26.0 GINKGO_VER: 2.27.3 jobs: @@ -54,9 +54,9 @@ jobs: go-version: ${{ env.GO_VER }} cache: false - name: golangci-lint - uses: golangci/golangci-lint-action@v8 + uses: golangci/golangci-lint-action@v9 with: - version: v2.5.0 + version: v2.9.0 skip-cache: true problem-matchers: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ee88fa..092080d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: - 'v*' env: - GO_VER: 1.25.7 + GO_VER: 1.26.0 UBUNTU_VER: 22.04 APP_VER: ${{ github.ref_name }} diff --git a/.github/workflows/vulnerability-scan.yml b/.github/workflows/vulnerability-scan.yml index df21ffb..224a4fc 100644 --- a/.github/workflows/vulnerability-scan.yml +++ b/.github/workflows/vulnerability-scan.yml @@ -22,7 +22,7 @@ permissions: jobs: scan-scheduled: if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.2.2" + uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.3.3" with: scan-args: |- --config ./osv-scanner-config.toml @@ -31,7 +31,7 @@ jobs: scan-pr: if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }} - uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.2.2" + uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@v2.3.3" with: scan-args: |- --config ./osv-scanner-config.toml diff --git a/.golangci.yml b/.golangci.yml index 29a769d..3923ecf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,7 @@ version: "2" run: concurrency: 4 - go: "1.25" + go: "1.26" tests: false linters: default: none @@ -56,6 +56,7 @@ linters: - unparam - usestdlibvars - whitespace + - modernize settings: gosec: excludes: diff --git a/cc/chaincode.go b/cc/chaincode.go index 962ced5..1c1831b 100644 --- a/cc/chaincode.go +++ b/cc/chaincode.go @@ -231,7 +231,7 @@ func (c *ACL) setupMethods() error { var err error c.methodOnce.Do(func() { c.methods = make(map[string]methods.Method) - t := reflect.TypeOf(c) + t := reflect.TypeOf(c) //nolint:modernize for i := range t.NumMethod() { method := t.Method(i) diff --git a/cc/querystub/query_stub.go b/cc/querystub/query_stub.go index 820489e..602d9ee 100644 --- a/cc/querystub/query_stub.go +++ b/cc/querystub/query_stub.go @@ -79,7 +79,7 @@ func (qs *queryStub) GetFunctionAndParameters() (function string, params []strin func (qs *queryStub) GetArgsSlice() ([]byte, error) { args := qs.GetArgs() - res := []byte{} + res := []byte{} //nolint:prealloc for _, barg := range args { res = append(res, barg...) } diff --git a/helpers/helpers.go b/helpers/helpers.go index 70ee853..373f819 100644 --- a/helpers/helpers.go +++ b/helpers/helpers.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "errors" "fmt" + "slices" "sort" "strings" "unicode" @@ -180,7 +181,8 @@ func CheckAddress(address string) error { return fmt.Errorf("check decode address : %w", err) } - hash := []byte{version} + hash := make([]byte, 0, len(result)+1) + hash = append(hash, version) hash = append(hash, result...) if len(hash) != sha256Length { @@ -220,12 +222,7 @@ func ValidatePublicKeyType(keyType string, notAllowedTypes ...string) bool { if !ok { return false } - for _, notAllowed := range notAllowedTypes { - if notAllowed == keyType { - return false - } - } - return true + return !slices.Contains(notAllowedTypes, keyType) } func DefaultPublicKeyType() string { diff --git a/helpers/helpers_test.go b/helpers/helpers_test.go index f67e29b..4869a31 100644 --- a/helpers/helpers_test.go +++ b/helpers/helpers_test.go @@ -64,7 +64,7 @@ func TestCheckDuplicates(t *testing.T) { func BenchmarkCheckDuplicates(b *testing.B) { input := []string{"a", "b", "c", "a", "b", "c", "b", "c", "a", "b", "c", "b", "c", "a", "b", "c"} var r []string - for i := 0; i < 1000; i++ { + for range 1000 { r = append(r, input...) } for i := 0; i < b.N; i++ { diff --git a/tests/integration/go.mod b/tests/integration/go.mod index 4395353..7fd0016 100644 --- a/tests/integration/go.mod +++ b/tests/integration/go.mod @@ -1,6 +1,6 @@ module github.com/anoideaopen/acl/tests/integration -go 1.25.7 +go 1.26.0 tool ( github.com/IBM/idemix/tools/idemixgen diff --git a/tests/unit/change_public_key_with_base58_signature_test.go b/tests/unit/change_public_key_with_base58_signature_test.go index 63df527..d83d9a0 100644 --- a/tests/unit/change_public_key_with_base58_signature_test.go +++ b/tests/unit/change_public_key_with_base58_signature_test.go @@ -208,7 +208,7 @@ func (ss *secrets) getSigns() []string { func newSecrets(validators int) (ss *secrets, err error) { ss = &secrets{} - for i := 0; i < validators; i++ { + for range validators { public, secret, err := ed25519.GenerateKey(rand.Reader) if err != nil { return nil, err diff --git a/tests/unit/get_accounts_info_test.go b/tests/unit/get_accounts_info_test.go index bb0267c..b788d89 100644 --- a/tests/unit/get_accounts_info_test.go +++ b/tests/unit/get_accounts_info_test.go @@ -90,12 +90,12 @@ func TestGetAccountsInfo(t *testing.T) { description: "ok", args: func() []string { args := make([]string, 0, 10) - for i := 0; i < 5; i++ { + for range 5 { bytes, err := json.Marshal([]string{common.FnGetAccInfoFn, "FcxURVVuLyR7bMJYYeW34HDKdzEvcMDwfWo1wS9oYmCaeps9N"}) require.NoError(t, err) args = append(args, string(bytes)) } - for i := 0; i < 5; i++ { + for range 5 { bytes, err := json.Marshal([]string{common.FnCheckKeys, "Cv8S2Y7pDT74AUma95Fdy6ZUX5NBVTQR7WRbdq46VR2z"}) require.NoError(t, err) args = append(args, string(bytes))