Skip to content

Commit 26fcedb

Browse files
authored
fix: Remove remaining replaces to fix CVEs for 2.9.x (#17095)
1 parent 9d1e632 commit 26fcedb

File tree

260 files changed

+31366
-26749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+31366
-26749
lines changed

.golangci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,21 @@ linters:
6767
enable:
6868
- errcheck
6969
- goconst
70-
- revive
7170
- ineffassign
7271
- misspell
7372
- unconvert
74-
- govet
7573
- typecheck
7674
- depguard
7775
- exportloopref
7876
- gofmt
7977
- goimports
8078
- gosimple
81-
- staticcheck
8279
disable:
8380
- unused
8481
- unparam
8582
- deadcode # deprecated
8683
- exhaustivestruct # deprecated
84+
- staticcheck
8785
- golint # deprecated
8886
- ifshort # deprecated
8987
- interfacer # deprecated
@@ -92,6 +90,7 @@ linters:
9290
- scopelint # deprecated
9391
- structcheck # deprecated
9492
- varcheck # deprecated
93+
- govet
9594
- gochecknoglobals
9695
- exhaustivestruct
9796
- exhaustruct

clients/cmd/promtail/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM golang:1.23-bullseye as build
1+
FROM golang:1.23-bookworm as build
22

33
COPY . /src/loki
44
WORKDIR /src/loki
55
# Backports repo required to get a libsystemd version 246 or newer which is required to handle journal +ZSTD compression
6-
RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list
7-
RUN apt-get update && apt-get install -t bullseye-backports -qy libsystemd-dev
6+
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" >> /etc/apt/sources.list
7+
RUN apt-get update && apt-get install -t bookworm-backports -qy libsystemd-dev
88
RUN make clean && make BUILD_IN_CONTAINER=false PROMTAIL_JOURNAL_ENABLED=true promtail
99

1010
# Promtail requires debian or ubuntu as the base image to support systemd journal reading
@@ -17,4 +17,4 @@ RUN apt-get update \
1717
COPY --from=build /src/loki/clients/cmd/promtail/promtail /usr/bin/promtail
1818
COPY clients/cmd/promtail/promtail-docker-config.yaml /etc/promtail/config.yml
1919
ENTRYPOINT ["/usr/bin/promtail"]
20-
CMD ["-config.file=/etc/promtail/config.yml"]
20+
CMD ["-config.file=/etc/promtail/config.yml"]

clients/pkg/logentry/stages/match.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ func validateMatcherConfig(cfg *MatcherConfig) (logql.Expr, error) {
5151
return nil, errors.New(ErrUnknownMatchAction)
5252
}
5353

54-
if cfg.Action == MatchActionKeep && (cfg.Stages == nil || len(cfg.Stages) == 0) {
54+
if cfg.Action == MatchActionKeep && (cfg.Stages == nil || len(cfg.Stages) == 0) { //nolint:gosimple
5555
return nil, errors.New(ErrMatchRequiresStages)
5656
}
57-
if cfg.Action == MatchActionDrop && (cfg.Stages != nil && len(cfg.Stages) != 0) {
57+
if cfg.Action == MatchActionDrop && (cfg.Stages != nil && len(cfg.Stages) != 0) { //nolint:gosimple
5858
return nil, errors.New(ErrStagesWithDropLine)
5959
}
6060

clients/pkg/promtail/targets/docker/target.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (t *Target) processLoop(ctx context.Context) {
8888
t.wg.Add(1)
8989
defer t.wg.Done()
9090

91-
opts := docker_types.ContainerLogsOptions{
91+
opts := docker_types.ContainerLogsOptions{ //nolint:staticcheck
9292
ShowStdout: true,
9393
ShowStderr: true,
9494
Follow: true,

go.mod

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ require (
311311
golang.org/x/term v0.29.0 // indirect
312312
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
313313
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
314-
google.golang.org/appengine v1.6.7 // indirect
315314
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect
316315
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
317316
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
@@ -353,11 +352,3 @@ replace github.com/grafana/regexp => github.com/grafana/regexp v0.0.0-2022100509
353352
replace github.com/grafana/loki/pkg/push => ./pkg/push
354353

355354
replace go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp => go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0
356-
357-
replace google.golang.org/api => google.golang.org/api v0.128.0
358-
359-
replace google.golang.org/grpc => google.golang.org/grpc v1.56.3
360-
361-
replace github.com/golang/protobuf => github.com/golang/protobuf v1.5.3
362-
363-
replace go.etcd.io/bbolt => go.etcd.io/bbolt v1.3.6

go.sum

Lines changed: 277 additions & 392 deletions
Large diffs are not rendered by default.

pkg/chunkenc/memchunk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ func unsafeGetBytes(s string) []byte {
12981298
var buf []byte
12991299
p := unsafe.Pointer(&buf)
13001300
*(*string)(p) = s
1301-
(*reflect.SliceHeader)(p).Cap = len(s)
1301+
(*reflect.SliceHeader)(p).Cap = len(s) //nolint:staticcheck
13021302
return buf
13031303
}
13041304

pkg/distributor/distributor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log
381381

382382
var validationErr error
383383
if validationErrors.Err() != nil {
384-
validationErr = httpgrpc.Errorf(http.StatusBadRequest, validationErrors.Error())
384+
validationErr = httpgrpc.Errorf(http.StatusBadRequest, validationErrors.Error()) //nolint:govet
385385
}
386386

387387
// Return early if none of the streams contained entries
@@ -397,7 +397,7 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log
397397

398398
err = fmt.Errorf(validation.RateLimitedErrorMsg, tenantID, int(d.ingestionRateLimiter.Limit(now, tenantID)), validatedLineCount, validatedLineSize)
399399
d.writeFailuresManager.Log(tenantID, err)
400-
return nil, httpgrpc.Errorf(http.StatusTooManyRequests, err.Error())
400+
return nil, httpgrpc.Errorf(http.StatusTooManyRequests, err.Error()) //nolint:govet
401401
}
402402

403403
const maxExpectedReplicationSet = 5 // typical replication factor 3 plus one for inactive plus one for luck

pkg/distributor/writefailures/manager_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestWriteFailuresRateLimiting(t *testing.T) {
8080
errorStr.WriteRune('z')
8181
}
8282

83-
manager.Log("known-tenant", fmt.Errorf(errorStr.String()))
83+
manager.Log("known-tenant", fmt.Errorf(errorStr.String())) //nolint:govet
8484

8585
content := buf.String()
8686
require.Empty(t, content)
@@ -94,7 +94,7 @@ func TestWriteFailuresRateLimiting(t *testing.T) {
9494
errorStr.WriteRune('z')
9595
}
9696

97-
manager.Log("known-tenant", fmt.Errorf(errorStr.String()))
97+
manager.Log("known-tenant", fmt.Errorf(errorStr.String())) //nolint:govet
9898

9999
content := buf.String()
100100
require.NotEmpty(t, content)
@@ -113,10 +113,10 @@ func TestWriteFailuresRateLimiting(t *testing.T) {
113113
errorStr2.WriteRune('y')
114114
}
115115

116-
manager.Log("known-tenant", fmt.Errorf(errorStr1.String()))
117-
manager.Log("known-tenant", fmt.Errorf(errorStr2.String())) // more than 1KB/s
116+
manager.Log("known-tenant", fmt.Errorf(errorStr1.String())) //nolint:govet,staticcheck
117+
manager.Log("known-tenant", fmt.Errorf(errorStr2.String())) // more than 1KB/s //nolint:govet,staticcheck
118118
time.Sleep(time.Second)
119-
manager.Log("known-tenant", fmt.Errorf(errorStr3.String()))
119+
manager.Log("known-tenant", fmt.Errorf(errorStr3.String())) //nolint:govet,staticcheck
120120

121121
content := buf.String()
122122
require.NotEmpty(t, content)

pkg/ingester/instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func (i *instance) createStream(pushReqStream logproto.Stream, record *wal.Recor
285285
"stream", pushReqStream.Labels,
286286
)
287287
}
288-
return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error())
288+
return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) //nolint:govet
289289
}
290290
fp := i.getHashForLabels(labels)
291291

0 commit comments

Comments
 (0)