Skip to content

Commit 7b533cc

Browse files
authored
Address vulnerabilities in Mettle repo (#351)
* Cherry-pick dependency-update commits to bump dependencies to latest version and fix merge conflict. * Switches health registration to the official grpc health server implementation compatible with newer grpc * Adds the missing grpc health build dependency * Fixes a go.sum module path typo for cloud.google.com/go/longrunning * Note: In grpc v1.79.3, the HealthServer interface added a new List method and changed the Watch signature, making existing custom health server implementations incompatible. So this PR replace direct registration of custom servers with the official health.NewServer() implementation and update BUILD dependencies accordingly.
1 parent e962d1a commit 7b533cc

5 files changed

Lines changed: 152 additions & 147 deletions

File tree

flair/rpc/rpc.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ func ServeForever(opts grpcutil.Opts, casReplicator, assetReplicator, executorRe
4949
bytestreamRe: regexp.MustCompile("(?:uploads/[0-9a-f-]+/)?(blobs|compressed-blobs/zstd)/([0-9a-f]+)/([0-9]+)"),
5050
timeout: timeout,
5151
}
52+
healthSrv := &healthServer{
53+
replicator: casReplicator,
54+
assetReplicator: assetReplicator,
55+
exeReplicator: executorReplicator,
56+
}
5257
opts.NoHealth = true // We will do this ourselves.
5358
lis, s := grpcutil.NewServer(opts)
5459
pb.RegisterCapabilitiesServer(s, srv)
@@ -62,7 +67,7 @@ func ServeForever(opts grpcutil.Opts, casReplicator, assetReplicator, executorRe
6267
pb.RegisterExecutionServer(s, srv)
6368
}
6469
ppb.RegisterGCServer(s, srv)
65-
hpb.RegisterHealthServer(s, srv)
70+
hpb.RegisterHealthServer(s, healthSrv)
6671
grpcutil.ServeForever(lis, s)
6772
}
6873

@@ -73,7 +78,15 @@ type server struct {
7378
timeout time.Duration
7479
}
7580

76-
func (s *server) Check(context.Context, *hpb.HealthCheckRequest) (*hpb.HealthCheckResponse, error) {
81+
// healthServer is a separate struct (rather than embedding hpb.UnimplementedHealthServer into server)
82+
// because ppb.UnimplementedGCServer and hpb.UnimplementedHealthServer both define a List method with
83+
// different signatures, which would cause a compile-time conflict.
84+
type healthServer struct {
85+
hpb.UnimplementedHealthServer
86+
replicator, assetReplicator, exeReplicator *trie.Replicator
87+
}
88+
89+
func (s *healthServer) Check(context.Context, *hpb.HealthCheckRequest) (*hpb.HealthCheckResponse, error) {
7790
for _, r := range []*trie.Replicator{s.replicator, s.assetReplicator, s.exeReplicator} {
7891
if r != nil {
7992
if err := r.Healthcheck(); err != nil {
@@ -86,10 +99,6 @@ func (s *server) Check(context.Context, *hpb.HealthCheckRequest) (*hpb.HealthChe
8699
return &hpb.HealthCheckResponse{Status: hpb.HealthCheckResponse_SERVING}, nil
87100
}
88101

89-
func (s *server) Watch(*hpb.HealthCheckRequest, hpb.Health_WatchServer) error {
90-
return status.Errorf(codes.Unimplemented, "grpc_health_v1.Watch not implemented")
91-
}
92-
93102
func (s *server) GetCapabilities(ctx context.Context, req *pb.GetCapabilitiesRequest) (*pb.ServerCapabilities, error) {
94103
// This always does the same thing as Elan.
95104
// We might consider upping some of the size limits though since it will multiplex batch requests so will be more

go.mod

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/thought-machine/please-servers
22

3-
go 1.22
3+
go 1.24.0
44

55
require (
66
cloud.google.com/go/profiler v0.4.0
@@ -11,13 +11,11 @@ require (
1111
github.com/dgraph-io/ristretto v0.1.1
1212
github.com/dustin/go-humanize v1.0.1
1313
github.com/go-redis/redis/v8 v8.11.5
14-
github.com/golang/protobuf v1.5.3
15-
github.com/golang/snappy v0.0.4 // This is a required dep that Go mod tidy gets rid of. This breaks Please if it gets removed though.
16-
github.com/google/go-cmp v0.6.0 // This is a required dep that Go mod tidy gets rid of. This breaks Please if it gets removed though.
14+
github.com/golang/protobuf v1.5.4
1715
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0
1816
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1
1917
github.com/hashicorp/go-multierror v1.1.1
20-
github.com/hashicorp/go-retryablehttp v0.7.5
18+
github.com/hashicorp/go-retryablehttp v0.7.7
2119
github.com/klauspost/compress v1.17.4
2220
github.com/mostynb/go-grpc-compression v1.2.2
2321
github.com/peterebden/go-cli-init/v4 v4.0.2
@@ -27,42 +25,41 @@ require (
2725
github.com/prometheus/common v0.45.0
2826
github.com/shirou/gopsutil v3.21.11+incompatible
2927
github.com/sirupsen/logrus v1.9.3
30-
github.com/stretchr/testify v1.8.4
28+
github.com/stretchr/testify v1.11.1
3129
github.com/thought-machine/http-admin v1.1.1
3230
go.uber.org/automaxprocs v1.5.3
3331
gocloud.dev v0.36.0
34-
golang.org/x/crypto v0.17.0
32+
golang.org/x/crypto v0.46.0
3533
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc
36-
golang.org/x/sync v0.6.0
34+
golang.org/x/sync v0.19.0
3735
golang.org/x/time v0.5.0
3836
google.golang.org/api v0.155.0
3937
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917
4038
google.golang.org/genproto/googleapis/bytestream v0.0.0-20240102182953-50ed04b92917
41-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917
42-
google.golang.org/grpc v1.60.1
43-
google.golang.org/protobuf v1.33.0
39+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217
40+
google.golang.org/grpc v1.79.3
41+
google.golang.org/protobuf v1.36.10
4442
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
4543
)
4644

4745
require (
4846
cloud.google.com/go v0.111.0 // indirect
49-
cloud.google.com/go/compute v1.23.3 // indirect
50-
cloud.google.com/go/compute/metadata v0.2.3 // indirect
47+
cloud.google.com/go/compute/metadata v0.9.0 // indirect
5148
cloud.google.com/go/iam v1.1.5 // indirect
5249
cloud.google.com/go/longrunning v0.5.4 // indirect
5350
github.com/beorn7/perks v1.0.1 // indirect
54-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
51+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5552
github.com/davecgh/go-spew v1.1.1 // indirect
5653
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
5754
github.com/felixge/httpsnoop v1.0.4 // indirect
58-
github.com/go-logr/logr v1.4.1 // indirect
55+
github.com/go-logr/logr v1.4.3 // indirect
5956
github.com/go-logr/stdr v1.2.2 // indirect
6057
github.com/go-ole/go-ole v1.3.0 // indirect
61-
github.com/golang/glog v1.2.0 // indirect
58+
github.com/golang/glog v1.2.5 // indirect
6259
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
6360
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 // indirect
6461
github.com/google/s2a-go v0.1.7 // indirect
65-
github.com/google/uuid v1.5.0 // indirect
62+
github.com/google/uuid v1.6.0 // indirect
6663
github.com/google/wire v0.5.0 // indirect
6764
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
6865
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
@@ -80,19 +77,19 @@ require (
8077
github.com/thought-machine/go-flags v1.6.3 // indirect
8178
github.com/yusufpapurcu/wmi v1.2.3 // indirect
8279
go.opencensus.io v0.24.0 // indirect
80+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
8381
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
8482
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
85-
go.opentelemetry.io/otel v1.21.0 // indirect
86-
go.opentelemetry.io/otel/metric v1.21.0 // indirect
87-
go.opentelemetry.io/otel/trace v1.21.0 // indirect
88-
golang.org/x/net v0.19.0 // indirect
89-
golang.org/x/oauth2 v0.15.0 // indirect
90-
golang.org/x/sys v0.16.0 // indirect
91-
golang.org/x/term v0.16.0 // indirect
92-
golang.org/x/text v0.14.0 // indirect
83+
go.opentelemetry.io/otel v1.39.0 // indirect
84+
go.opentelemetry.io/otel/metric v1.39.0 // indirect
85+
go.opentelemetry.io/otel/trace v1.39.0 // indirect
86+
golang.org/x/net v0.48.0 // indirect
87+
golang.org/x/oauth2 v0.34.0 // indirect
88+
golang.org/x/sys v0.39.0 // indirect
89+
golang.org/x/term v0.38.0 // indirect
90+
golang.org/x/text v0.32.0 // indirect
9391
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
94-
google.golang.org/appengine v1.6.8 // indirect
95-
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
92+
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
9693
gopkg.in/yaml.v3 v3.0.1 // indirect
9794
)
9895

0 commit comments

Comments
 (0)