Skip to content

Commit fd28620

Browse files
renovate[bot]MrAliasdmathieu
authored
fix(deps): update module github.com/golangci/golangci-lint to v1.60.2 (#6008)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/golangci/golangci-lint](https://togithub.com/golangci/golangci-lint) | `v1.60.1` -> `v1.60.2` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgolangci%2fgolangci-lint/v1.60.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgolangci%2fgolangci-lint/v1.60.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgolangci%2fgolangci-lint/v1.60.1/v1.60.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgolangci%2fgolangci-lint/v1.60.1/v1.60.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>golangci/golangci-lint (github.com/golangci/golangci-lint)</summary> ### [`v1.60.2`](https://togithub.com/golangci/golangci-lint/compare/v1.60.1...v1.60.2) [Compare Source](https://togithub.com/golangci/golangci-lint/compare/v1.60.1...v1.60.2) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/open-telemetry/opentelemetry-go-contrib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yNi4xIiwidXBkYXRlZEluVmVyIjoiMzguMjYuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Tyler Yahn <[email protected]> Co-authored-by: Tyler Yahn <[email protected]> Co-authored-by: Damien Mathieu <[email protected]>
1 parent 21e0a4d commit fd28620

File tree

22 files changed

+157
-92
lines changed

22 files changed

+157
-92
lines changed

bridges/otelslog/handler.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,12 @@ func convertValue(v slog.Value) log.Value {
425425
case slog.KindTime:
426426
return log.Int64Value(v.Time().UnixNano())
427427
case slog.KindUint64:
428-
return log.Int64Value(int64(v.Uint64()))
428+
const maxInt64 = ^uint64(0) >> 1
429+
u := v.Uint64()
430+
if u > maxInt64 {
431+
return log.Float64Value(float64(u))
432+
}
433+
return log.Int64Value(int64(u)) // nolint:gosec // Overflow checked above.
429434
case slog.KindGroup:
430435
g := v.Group()
431436
buf := newKVBuffer(len(g))

bridges/otelzap/encoder.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (m *objectEncoder) AddUint16(k string, v uint16) {
175175
}
176176

177177
func (m *objectEncoder) AddUint8(k string, v uint8) {
178-
m.AddInt64(k, int64(v))
178+
m.AddInt64(k, int64(v)) // nolint: gosec // https://github.com/securego/gosec/issues/1185
179179
}
180180

181181
func (m *objectEncoder) AddUintptr(k string, v uintptr) {
@@ -187,7 +187,7 @@ func assignUintValue(v uint64) log.Value {
187187
if v > maxInt64 {
188188
return log.Float64Value(float64(v))
189189
}
190-
return log.Int64Value(int64(v))
190+
return log.Int64Value(int64(v)) // nolint:gosec // Overflow checked above.
191191
}
192192

193193
// arrayEncoder implements [zapcore.ArrayEncoder].
@@ -272,8 +272,10 @@ func (a *arrayEncoder) AppendTime(v time.Time) { a.AppendInt64(v.UnixNan
272272
func (a *arrayEncoder) AppendUint(v uint) { a.AppendUint64(uint64(v)) }
273273
func (a *arrayEncoder) AppendUint32(v uint32) { a.AppendInt64(int64(v)) }
274274
func (a *arrayEncoder) AppendUint16(v uint16) { a.AppendInt64(int64(v)) }
275-
func (a *arrayEncoder) AppendUint8(v uint8) { a.AppendInt64(int64(v)) }
276275
func (a *arrayEncoder) AppendUintptr(v uintptr) { a.AppendUint64(uint64(v)) }
276+
func (a *arrayEncoder) AppendUint8(v uint8) {
277+
a.AppendInt64(int64(v)) // nolint: gosec // https://github.com/securego/gosec/issues/1185
278+
}
277279

278280
func convertValue(v interface{}) log.Value {
279281
switch v := v.(type) {

bridges/prometheus/producer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ func convertExponentialBuckets(bucketSpans []*dto.BucketSpan, deltas []int64) me
214214
initialOffset := bucketSpans[0].GetOffset() - 1
215215
// We will have one bucket count for each delta, and zeros for the offsets
216216
// after the initial offset.
217-
lenCounts := int32(len(deltas))
217+
lenCounts := len(deltas)
218218
for i, bs := range bucketSpans {
219219
if i != 0 {
220-
lenCounts += bs.GetOffset()
220+
lenCounts += int(bs.GetOffset())
221221
}
222222
}
223223
counts := make([]uint64, lenCounts)

config/metric.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11+
"math"
1112
"net"
1213
"net/http"
1314
"net/url"
@@ -358,8 +359,8 @@ func aggregation(aggr *ViewStreamAggregation) sdkmetric.Aggregation {
358359

359360
if aggr.Base2ExponentialBucketHistogram != nil {
360361
return sdkmetric.AggregationBase2ExponentialHistogram{
361-
MaxSize: int32(intOrZero(aggr.Base2ExponentialBucketHistogram.MaxSize)),
362-
MaxScale: int32(intOrZero(aggr.Base2ExponentialBucketHistogram.MaxScale)),
362+
MaxSize: int32OrZero(aggr.Base2ExponentialBucketHistogram.MaxSize),
363+
MaxScale: int32OrZero(aggr.Base2ExponentialBucketHistogram.MaxScale),
363364
// Need to negate because config has the positive action RecordMinMax.
364365
NoMinMax: !boolOrFalse(aggr.Base2ExponentialBucketHistogram.RecordMinMax),
365366
}
@@ -426,11 +427,18 @@ func boolOrFalse(pBool *bool) bool {
426427
return *pBool
427428
}
428429

429-
func intOrZero(pInt *int) int {
430+
func int32OrZero(pInt *int) int32 {
430431
if pInt == nil {
431432
return 0
432433
}
433-
return *pInt
434+
i := *pInt
435+
if i > math.MaxInt32 {
436+
return math.MaxInt32
437+
}
438+
if i < math.MinInt32 {
439+
return math.MinInt32
440+
}
441+
return int32(i) // nolint: gosec // Overflow and underflow checked above.
434442
}
435443

436444
func strOrEmpty(pStr *string) string {

config/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func keyVal(k string, v any) attribute.KeyValue {
2323
case int8:
2424
return attribute.Int64(k, int64(val))
2525
case uint8:
26-
return attribute.Int64(k, int64(val))
26+
return attribute.Int64(k, int64(val)) // nolint: gosec // https://github.com/securego/gosec/issues/1185
2727
case int16:
2828
return attribute.Int64(k, int64(val))
2929
case uint16:

instrumentation/github.com/emicklei/go-restful/otelrestful/internal/semconvutil/netconv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func splitHostPort(hostport string) (host string, port int) {
195195
if err != nil {
196196
return
197197
}
198-
return host, int(p)
198+
return host, int(p) // nolint: gosec // Bitsize checked to be 16 above.
199199
}
200200

201201
func netProtocol(proto string) (name string, version string) {

instrumentation/github.com/gin-gonic/gin/otelgin/internal/semconvutil/netconv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func splitHostPort(hostport string) (host string, port int) {
195195
if err != nil {
196196
return
197197
}
198-
return host, int(p)
198+
return host, int(p) // nolint: gosec // Bitsize checked to be 16 above.
199199
}
200200

201201
func netProtocol(proto string) (name string, version string) {

instrumentation/github.com/gorilla/mux/otelmux/internal/semconvutil/netconv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func splitHostPort(hostport string) (host string, port int) {
195195
if err != nil {
196196
return
197197
}
198-
return host, int(p)
198+
return host, int(p) // nolint: gosec // Bitsize checked to be 16 above.
199199
}
200200

201201
func netProtocol(proto string) (name string, version string) {

instrumentation/github.com/labstack/echo/otelecho/internal/semconvutil/netconv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func splitHostPort(hostport string) (host string, port int) {
195195
if err != nil {
196196
return
197197
}
198-
return host, int(p)
198+
return host, int(p) // nolint: gosec // Bitsize checked to be 16 above.
199199
}
200200

201201
func netProtocol(proto string) (name string, version string) {

instrumentation/google.golang.org/grpc/otelgrpc/internal/test/test_utils.go

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ import (
4444
)
4545

4646
var (
47-
reqSizes = []int{27182, 8, 1828, 45904}
48-
respSizes = []int{31415, 9, 2653, 58979}
49-
largeReqSize = 271828
50-
largeRespSize = 314159
51-
initialMetadataKey = "x-grpc-test-echo-initial"
52-
trailingMetadataKey = "x-grpc-test-echo-trailing-bin"
47+
reqSizes = []int32{27182, 8, 1828, 45904}
48+
respSizes = []int32{31415, 9, 2653, 58979}
49+
largeReqSize = 271828
50+
largeRespSize int32 = 314159
51+
initialMetadataKey = "x-grpc-test-echo-initial"
52+
trailingMetadataKey = "x-grpc-test-echo-trailing-bin"
5353

5454
logger = grpclog.Component("interop")
5555
)
@@ -87,7 +87,7 @@ func DoLargeUnaryCall(ctx context.Context, tc testpb.TestServiceClient, args ...
8787
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, largeReqSize)
8888
req := &testpb.SimpleRequest{
8989
ResponseType: testpb.PayloadType_COMPRESSABLE,
90-
ResponseSize: int32(largeRespSize),
90+
ResponseSize: largeRespSize,
9191
Payload: pl,
9292
}
9393
reply, err := tc.UnaryCall(ctx, req, args...)
@@ -96,7 +96,7 @@ func DoLargeUnaryCall(ctx context.Context, tc testpb.TestServiceClient, args ...
9696
}
9797
t := reply.GetPayload().GetType()
9898
s := len(reply.GetPayload().GetBody())
99-
if t != testpb.PayloadType_COMPRESSABLE || s != largeRespSize {
99+
if t != testpb.PayloadType_COMPRESSABLE || s != int(largeRespSize) {
100100
logger.Fatalf("Got the reply with type %d len %d; want %d, %d", t, s, testpb.PayloadType_COMPRESSABLE, largeRespSize)
101101
}
102102
}
@@ -107,9 +107,9 @@ func DoClientStreaming(ctx context.Context, tc testpb.TestServiceClient, args ..
107107
if err != nil {
108108
logger.Fatalf("%v.StreamingInputCall(_) = _, %v", tc, err)
109109
}
110-
var sum int
110+
var sum int32
111111
for _, s := range reqSizes {
112-
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, s)
112+
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, int(s))
113113
req := &testpb.StreamingInputCallRequest{
114114
Payload: pl,
115115
}
@@ -122,7 +122,7 @@ func DoClientStreaming(ctx context.Context, tc testpb.TestServiceClient, args ..
122122
if err != nil {
123123
logger.Fatalf("%v.CloseAndRecv() got error %v, want %v", stream, err, nil)
124124
}
125-
if reply.GetAggregatedPayloadSize() != int32(sum) {
125+
if reply.GetAggregatedPayloadSize() != sum {
126126
logger.Fatalf("%v.CloseAndRecv().GetAggregatePayloadSize() = %v; want %v", stream, reply.GetAggregatedPayloadSize(), sum)
127127
}
128128
}
@@ -132,7 +132,7 @@ func DoServerStreaming(ctx context.Context, tc testpb.TestServiceClient, args ..
132132
respParam := make([]*testpb.ResponseParameters, len(respSizes))
133133
for i, s := range respSizes {
134134
respParam[i] = &testpb.ResponseParameters{
135-
Size: int32(s),
135+
Size: s,
136136
}
137137
}
138138
req := &testpb.StreamingOutputCallRequest{
@@ -157,7 +157,7 @@ func DoServerStreaming(ctx context.Context, tc testpb.TestServiceClient, args ..
157157
logger.Fatalf("Got the reply of type %d, want %d", t, testpb.PayloadType_COMPRESSABLE)
158158
}
159159
size := len(reply.GetPayload().GetBody())
160-
if size != respSizes[index] {
160+
if size != int(respSizes[index]) {
161161
logger.Fatalf("Got reply body of length %d, want %d", size, respSizes[index])
162162
}
163163
index++
@@ -181,10 +181,10 @@ func DoPingPong(ctx context.Context, tc testpb.TestServiceClient, args ...grpc.C
181181
for index < len(reqSizes) {
182182
respParam := []*testpb.ResponseParameters{
183183
{
184-
Size: int32(respSizes[index]),
184+
Size: respSizes[index],
185185
},
186186
}
187-
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, reqSizes[index])
187+
pl := ClientNewPayload(testpb.PayloadType_COMPRESSABLE, int(reqSizes[index]))
188188
req := &testpb.StreamingOutputCallRequest{
189189
ResponseType: testpb.PayloadType_COMPRESSABLE,
190190
ResponseParameters: respParam,
@@ -202,7 +202,7 @@ func DoPingPong(ctx context.Context, tc testpb.TestServiceClient, args ...grpc.C
202202
logger.Fatalf("Got the reply of type %d, want %d", t, testpb.PayloadType_COMPRESSABLE)
203203
}
204204
size := len(reply.GetPayload().GetBody())
205-
if size != respSizes[index] {
205+
if size != int(respSizes[index]) {
206206
logger.Fatalf("Got reply body of length %d, want %d", size, respSizes[index])
207207
}
208208
index++
@@ -304,19 +304,21 @@ func (s *testServer) StreamingOutputCall(args *testpb.StreamingOutputCallRequest
304304
}
305305

306306
func (s *testServer) StreamingInputCall(stream testpb.TestService_StreamingInputCallServer) error {
307-
var sum int
307+
var sum int32
308308
for {
309309
in, err := stream.Recv()
310310
if errors.Is(err, io.EOF) {
311311
return stream.SendAndClose(&testpb.StreamingInputCallResponse{
312-
AggregatedPayloadSize: int32(sum),
312+
AggregatedPayloadSize: sum,
313313
})
314314
}
315315
if err != nil {
316316
return err
317317
}
318-
p := in.GetPayload().GetBody()
319-
sum += len(p)
318+
n := len(in.GetPayload().GetBody())
319+
// This could overflow, but given this is a test and the negative value
320+
// should be detectable this should be good enough.
321+
sum += int32(n) // nolint: gosec
320322
}
321323
}
322324

0 commit comments

Comments
 (0)