Skip to content

Commit c1a93c4

Browse files
pull[bot]spoltiandresllh
authored
[pull] main from kserve:main (#326)
* Fixes CVE-2024-45338 (kserve#533) chore: Fix [CVE-2024-45338](https://www.cve.org/CVERecord?id=CVE-2024-45338) - Denial of Service on golang.org/x/net/html #### Motivation #### Modifications #### Result Signed-off-by: Spolti <[email protected]> * [RHOAIENG-14237] Adding REST_PROXY_SKIP_VERIFY env var. (kserve#536) #### Motivation rest-proxy has a new environment variable for allowing the user to skip verification when using TLS #### Modifications Adding the variable to the RESTProxyConfig and to the Deployments #### Result Users will be able to specify if they want to skip verification when using TLS See: [RHOAIENG-14237](https://issues.redhat.com/browse/RHOAIENG-14237) Signed-off-by: Andres Llausas <[email protected]> * Update GoLang, python and base images (kserve#538) Signed-off-by: Spolti <[email protected]> --------- Signed-off-by: Spolti <[email protected]> Signed-off-by: Andres Llausas <[email protected]> Co-authored-by: Filippe Spolti <[email protected]> Co-authored-by: Andres Llausas <[email protected]>
1 parent 1850599 commit c1a93c4

16 files changed

+123
-74
lines changed

Diff for: .github/workflows/fvt-base.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,18 @@ jobs:
4141
- name: Setup go
4242
uses: actions/setup-go@v5
4343
with:
44-
go-version: '1.21'
44+
go-version: '1.22'
4545

4646
- name: Start Minikube
47-
uses: medyagh/[email protected].14
47+
uses: medyagh/[email protected].19
4848
id: minikube
4949
with:
50-
minikube-version: 1.32.0
50+
minikube-version: 1.35.0
5151
container-runtime: docker
52-
kubernetes-version: v1.26.1
52+
kubernetes-version: v1.32.0
5353
cpus: max
5454
memory: max
55+
addons: storage-provisioner
5556

5657
- name: Check pods
5758
run: |

Diff for: .pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
repos:
1515
- repo: https://github.com/golangci/golangci-lint
16-
rev: v1.51.2
16+
rev: v1.60.3
1717
hooks:
1818
- id: golangci-lint
1919
entry: golangci-lint run

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ RUN GOOS=${TARGETOS:-linux} \
5454
###############################################################################
5555
# Stage 2: Copy build assets to create the smallest final runtime image
5656
###############################################################################
57-
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS runtime
57+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.5 AS runtime
5858

5959
ARG USER=2000
6060
ARG IMAGE_VERSION

Diff for: Dockerfile.develop

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
###############################################################################
2222
# Create the develop, test, and build environment
2323
###############################################################################
24-
ARG GOLANG_VERSION=1.21
25-
FROM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION
24+
ARG GOLANG_VERSION=1.22
25+
FROM registry.access.redhat.com/ubi9/go-toolset:$GOLANG_VERSION
2626

2727

2828
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
@@ -44,14 +44,15 @@ ENV HOME=/root
4444
WORKDIR /workspace
4545

4646
# Install build and dev tools
47-
# NOTE: Require python38 to install pre-commit
47+
# NOTE: Require python to install pre-commit
4848
RUN --mount=type=cache,target=/root/.cache/dnf:rw \
4949
dnf install --setopt=cachedir=/root/.cache/dnf -y --nodocs \
5050
nodejs \
5151
jq \
52-
python38 \
53-
&& ln -sf /usr/bin/python3 /usr/bin/python \
54-
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
52+
python3.11 \
53+
python3.11-pip \
54+
&& alternatives --install /usr/bin/python python /usr/bin/python3.11 1 \
55+
&& alternatives --install /usr/bin/pip pip /usr/bin/pip3.11 1 \
5556
&& true
5657

5758
# Install pre-commit

Diff for: controllers/modelmesh/cluster_config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (cc ClusterConfig) Reconcile(ctx context.Context, namespace string, cl clie
7171
return err
7272
}
7373

74-
if cc.SRSpecs == nil || len(cc.SRSpecs) == 0 {
74+
if len(cc.SRSpecs) == 0 {
7575
if !notfound {
7676
return cl.Delete(ctx, m)
7777
}

Diff for: controllers/modelmesh/modelmesh.go

+20-19
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,26 @@ const ModelMeshEtcdPrefix = "mm"
3737

3838
// Models a deployment
3939
type Deployment struct {
40-
ServiceName string
41-
ServicePort uint16
42-
Name string
43-
Namespace string
44-
Owner mf.Owner
45-
SRSpec *kserveapi.ServingRuntimeSpec
46-
DefaultVModelOwner string
47-
Log logr.Logger
48-
Metrics bool
49-
PrometheusPort uint16
50-
PrometheusScheme string
51-
PayloadProcessors string
52-
ModelMeshImage string
53-
ModelMeshResources *corev1.ResourceRequirements
54-
RESTProxyEnabled bool
55-
RESTProxyImage string
56-
RESTProxyResources *corev1.ResourceRequirements
57-
RESTProxyPort uint16
58-
PVCs []string
40+
ServiceName string
41+
ServicePort uint16
42+
Name string
43+
Namespace string
44+
Owner mf.Owner
45+
SRSpec *kserveapi.ServingRuntimeSpec
46+
DefaultVModelOwner string
47+
Log logr.Logger
48+
Metrics bool
49+
PrometheusPort uint16
50+
PrometheusScheme string
51+
PayloadProcessors string
52+
ModelMeshImage string
53+
ModelMeshResources *corev1.ResourceRequirements
54+
RESTProxyEnabled bool
55+
RESTProxySkipVerify bool
56+
RESTProxyImage string
57+
RESTProxyResources *corev1.ResourceRequirements
58+
RESTProxyPort uint16
59+
PVCs []string
5960
// internal fields used when templating
6061
AuthNamespace string
6162
ModelMeshLimitCPU string

Diff for: controllers/modelmesh/proxy.go

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
restProxyGrpcMaxMsgSizeEnvVar = "REST_PROXY_GRPC_MAX_MSG_SIZE_BYTES"
2727
restProxyGrpcPortEnvVar = "REST_PROXY_GRPC_PORT"
2828
restProxyTlsEnvVar = "REST_PROXY_USE_TLS"
29+
restProxySkipVerifyEnvVar = "REST_PROXY_SKIP_VERIFY"
2930
)
3031

3132
func (m *Deployment) addRESTProxyToDeployment(deployment *appsv1.Deployment) error {
@@ -47,6 +48,9 @@ func (m *Deployment) addRESTProxyToDeployment(deployment *appsv1.Deployment) err
4748
}, {
4849
Name: restProxyGrpcMaxMsgSizeEnvVar,
4950
Value: strconv.Itoa(m.GrpcMaxMessageSize),
51+
}, {
52+
Name: restProxySkipVerifyEnvVar,
53+
Value: strconv.FormatBool(m.RESTProxySkipVerify),
5054
},
5155
},
5256
Ports: []corev1.ContainerPort{

Diff for: controllers/servingruntime_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ func (r *ServingRuntimeReconciler) Reconcile(ctx context.Context, req ctrl.Reque
242242
RESTProxyEnabled: cfg.RESTProxy.Enabled,
243243
RESTProxyImage: cfg.RESTProxy.Image.TaggedImage(),
244244
RESTProxyPort: cfg.RESTProxy.Port,
245+
RESTProxySkipVerify: cfg.RESTProxy.SkipVerify,
245246
RESTProxyResources: cfg.RESTProxy.Resources.ToKubernetesType(),
246247
PullerImage: cfg.StorageHelperImage.TaggedImage(),
247248
PullerImageCommand: cfg.StorageHelperImage.Command,

Diff for: controllers/testdata/servingruntime_controller.golden

+2
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ spec:
671671
value: "false"
672672
- name: REST_PROXY_GRPC_MAX_MSG_SIZE_BYTES
673673
value: "16777216"
674+
- name: REST_PROXY_SKIP_VERIFY
675+
value: "false"
674676
image: kserve/rest-proxy:latest
675677
imagePullPolicy: Always
676678
name: rest-proxy

Diff for: fvt/fvtclient.go

+26-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ import (
2828
"strings"
2929
"time"
3030

31-
"google.golang.org/grpc/credentials/insecure"
32-
3331
"github.com/go-logr/logr"
3432
"github.com/kserve/kserve/pkg/apis/serving/v1beta1"
3533
api "github.com/kserve/modelmesh-serving/apis/serving/v1alpha1"
34+
"google.golang.org/grpc/credentials/insecure"
3635

3736
"github.com/onsi/ginkgo/v2"
3837
. "github.com/onsi/gomega"
@@ -497,6 +496,29 @@ func (fvt *FVTClient) TailPodLogs(sinceTime string) {
497496
}
498497
}
499498

499+
func (fvt *FVTClient) PrintContainerEnvsFromAllPods() {
500+
podList, err := fvt.Resource(gvrPods).Namespace(fvt.namespace).List(context.TODO(), metav1.ListOptions{
501+
LabelSelector: "modelmesh-service=modelmesh-serving",
502+
})
503+
if err != nil {
504+
fvt.log.Error(err, "Error listing the pods")
505+
}
506+
for _, podList := range podList.Items {
507+
podName := podList.GetName()
508+
err = fvt.RunKubectl("get", "pod/"+podName, "-o", "yaml")
509+
if err != nil {
510+
fvt.log.Error(err, "Error running kubectl exec env command")
511+
}
512+
}
513+
}
514+
515+
func (fvt *FVTClient) PrintMMConfig() {
516+
err := fvt.RunKubectl("get", "cm", UserConfigMapName, "-o", "yaml")
517+
if err != nil {
518+
fvt.log.Error(err, "Error running get config map command")
519+
}
520+
}
521+
500522
func (fvt *FVTClient) RunKubectl(args ...string) error {
501523
args = append(args, "-n", fvt.namespace)
502524
kubectlCmd := exec.Command("kubectl", args...)
@@ -533,13 +555,13 @@ func (fvt *FVTClient) RunKfsModelMetadata(req *inference.ModelMetadataRequest) (
533555
return grpcClient.ModelMetadata(ctx, req)
534556
}
535557

536-
func (fvt *FVTClient) RunKfsRestInference(modelName string, body []byte, tls bool) (string, error) {
558+
func (fvt *FVTClient) RunKfsRestInference(modelName string, body []byte, useTls bool) (string, error) {
537559
if fvt.restConn == nil {
538560
return "", errors.New("you must connect to model mesh before running an inference")
539561
}
540562

541563
protocol := "http"
542-
if tls {
564+
if useTls {
543565
protocol = "https"
544566
}
545567

Diff for: fvt/globals.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ var NameSpaceScopeMode = false
2828
var DefaultConfig = map[string]interface{}{
2929
"podsPerRuntime": 1,
3030
"restProxy": map[string]interface{}{
31-
"enabled": true,
31+
"enabled": true,
32+
"skipVerify": true,
3233
},
3334
"scaleToZero": map[string]interface{}{
3435
"enabled": false,

Diff for: fvt/predictor/predictor_suite_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ var _ = JustBeforeEach(func() {
8787
})
8888
var _ = JustAfterEach(func() {
8989
if CurrentSpecReport().Failed() {
90+
FVTClientInstance.PrintMMConfig()
9091
FVTClientInstance.PrintPredictors()
9192
FVTClientInstance.PrintIsvcs()
9293
FVTClientInstance.PrintPods()
9394
FVTClientInstance.PrintDescribeNodes()
9495
FVTClientInstance.PrintEvents()
9596
FVTClientInstance.TailPodLogs(startTime)
97+
FVTClientInstance.PrintContainerEnvsFromAllPods()
9698
}
9799
})

Diff for: fvt/predictor/predictor_test.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
package predictor
1616

1717
import (
18+
"crypto/sha1"
1819
"fmt"
1920
"time"
2021

21-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
23-
2422
inference "github.com/kserve/modelmesh-serving/fvt/generated"
2523
tfsframework "github.com/kserve/modelmesh-serving/fvt/generated/tensorflow/core/framework"
2624
tfsapi "github.com/kserve/modelmesh-serving/fvt/generated/tensorflow_serving/apis"
25+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2727

2828
. "github.com/kserve/modelmesh-serving/fvt"
2929
. "github.com/onsi/ginkgo/v2"
@@ -364,10 +364,16 @@ var _ = Describe("Predictor", func() {
364364
BeforeAll(func() {
365365
// load the test predictor object
366366
tfPredictorObject = NewPredictorForFVT("tf-predictor.yaml")
367+
rd := fmt.Sprintf("%x", sha1.Sum([]byte(time.Now().String())))
368+
randomName := fmt.Sprintf("minimal-tf-predictor-%s", rd[len(rd)-5:])
369+
SetString(tfPredictorObject, randomName, "metadata", "name")
370+
367371
tfPredictorName = tfPredictorObject.GetName()
368372

369373
CreatePredictorAndWaitAndExpectLoaded(tfPredictorObject)
370374

375+
WaitForStableActiveDeployState(time.Second * 60)
376+
371377
err := FVTClientInstance.ConnectToModelServing(Insecure)
372378
Expect(err).ToNot(HaveOccurred())
373379
})
@@ -1175,6 +1181,7 @@ var _ = Describe("TLS XGBoost inference", Ordered, Serial, func() {
11751181

11761182
It("should successfully run an inference with basic TLS", func() {
11771183
By("Updating the user ConfigMap to for basic TLS")
1184+
11781185
FVTClientInstance.UpdateConfigMapTLS(BasicTLSConfig)
11791186

11801187
By("Waiting for stable deploy state after UpdateConfigMapTLS")

Diff for: go.mod

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/kserve/modelmesh-serving
22

3-
go 1.21
3+
go 1.22.9
44

55
require (
66
github.com/dereklstinson/cifar v0.0.0-20200421171932-5722a3b6a0c7
@@ -36,7 +36,7 @@ require (
3636
github.com/google/gnostic-models v0.6.8 // indirect
3737
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
3838
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
39-
golang.org/x/sync v0.5.0 // indirect
39+
golang.org/x/sync v0.10.0 // indirect
4040
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect
4141
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
4242
)
@@ -108,14 +108,14 @@ require (
108108
go.opencensus.io v0.24.0 // indirect
109109
go.uber.org/multierr v1.11.0 // indirect
110110
go.uber.org/zap v1.26.0 // indirect
111-
golang.org/x/crypto v0.21.0 // indirect
112-
golang.org/x/net v0.21.0 // indirect
111+
golang.org/x/crypto v0.31.0 // indirect
112+
golang.org/x/net v0.25.0 // indirect
113113
golang.org/x/oauth2 v0.14.0 // indirect
114-
golang.org/x/sys v0.18.0 // indirect
115-
golang.org/x/term v0.18.0 // indirect
116-
golang.org/x/text v0.14.0 // indirect
114+
golang.org/x/sys v0.28.0 // indirect
115+
golang.org/x/term v0.27.0 // indirect
116+
golang.org/x/text v0.21.0 // indirect
117117
golang.org/x/time v0.4.0 // indirect
118-
golang.org/x/tools v0.15.0 // indirect
118+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
119119
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
120120
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
121121
google.golang.org/api v0.151.0 // indirect
@@ -142,6 +142,6 @@ replace (
142142
// before removing it make sure that the next version of the related k8s dependencies contains the fix
143143
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp => go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0
144144

145-
// Fixes CVE-2023-45288
146-
golang.org/x/net => golang.org/x/net v0.23.0
145+
// Fixes CVE-2024-45338
146+
golang.org/x/net => golang.org/x/net v0.33.0
147147
)

0 commit comments

Comments
 (0)