diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b39ee0bf3..4fee8e160 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,16 +16,16 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.22 + go-version: 1.23 - name: Run linters - uses: golangci/golangci-lint-action@v3.7.0 + uses: golangci/golangci-lint-action@v6.1.1 with: - version: v1.55.2 + version: v1.62.2 test: runs-on: ubuntu-latest strategy: matrix: - go: ['1.21', '1.22'] + go: ['1.22', '1.23'] steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '1.21' + go-version: '1.23' - uses: actions/cache@v3 with: path: ~/go/pkg/mod diff --git a/.golangci.yml b/.golangci.yml index a8ee70a8f..ebda9acf3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ run: - go: '1.21' + go: '1.23' timeout: 10m linters-settings: diff --git a/entproto/adapter.go b/entproto/adapter.go index 3c42e16c7..a34ac2766 100644 --- a/entproto/adapter.go +++ b/entproto/adapter.go @@ -17,6 +17,7 @@ package entproto import ( "errors" "fmt" + "math" "path" "path/filepath" "strings" @@ -387,7 +388,10 @@ func (a *Adapter) extractEdgeFieldDescriptor(source *gen.Type, e *gen.Edge) (*de return nil, fmt.Errorf("entproto: edge %q has number 1 which is reserved for id", e.Name) } - fieldNum := int32(edgeAnnotation.Number) + if num := int64(edgeAnnotation.Number); num > math.MaxInt32 || num < math.MinInt32 { + return nil, fmt.Errorf("value %v overflows int32", num) + } + fieldNum := int32(edgeAnnotation.Number) //nolint:gosec fieldDesc := &descriptorpb.FieldDescriptorProto{ Number: &fieldNum, Name: &e.Name, @@ -461,7 +465,10 @@ func toProtoFieldDescriptor(f *gen.Field) (*descriptorpb.FieldDescriptorProto, e if err != nil { return nil, err } - fieldNumber := int32(fann.Number) + if num := int64(fann.Number); num > math.MaxInt32 || num < math.MinInt32 { + return nil, fmt.Errorf("value %v overflows int32", num) + } + fieldNumber := int32(fann.Number) //nolint:gosec if fieldNumber == 1 && strings.ToUpper(f.Name) != "ID" { return nil, fmt.Errorf("entproto: field %q has number 1 which is reserved for id", f.Name) } diff --git a/go.mod b/go.mod index 556d262f5..28e0d6cb1 100644 --- a/go.mod +++ b/go.mod @@ -42,6 +42,7 @@ require ( github.com/go-faster/jx v0.40.0 // indirect github.com/go-faster/yamlx v0.4.1 // indirect github.com/golang/protobuf v1.5.4 // indirect + github.com/google/addlicense v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect diff --git a/go.sum b/go.sum index bab06ed95..58aac26b5 100644 --- a/go.sum +++ b/go.sum @@ -34,6 +34,8 @@ github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/bmatcuk/doublestar/v4 v4.0.2 h1:X0krlUVAVmtr2cRoTqR8aDMrDqnB36ht8wpWTiQ3jsA= +github.com/bmatcuk/doublestar/v4 v4.0.2/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -74,6 +76,8 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/addlicense v1.1.1 h1:jpVf9qPbU8rz5MxKo7d+RMcNHkqxi4YJi/laauX4aAE= +github.com/google/addlicense v1.1.1/go.mod h1:Sm/DHu7Jk+T5miFHHehdIjbi4M5+dJDRS3Cq0rncIxA= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=