summaryrefslogtreecommitdiffstats
path: root/recipes-containers/kubernetes
diff options
context:
space:
mode:
authorZhixiong Chi <zhixiong.chi@windriver.com>2020-05-12 01:52:32 -0700
committerBruce Ashfield <bruce.ashfield@gmail.com>2020-05-19 17:17:41 -0400
commit1a8a7996a1130d35501c0e0e62a364dcb013ffe7 (patch)
tree582002ea2e9128cdb63c2b6488f203721a67009b /recipes-containers/kubernetes
parent1bb515609594215aaf950555211e18c6c9a8e308 (diff)
downloadmeta-virtualization-1a8a7996a1130d35501c0e0e62a364dcb013ffe7.tar.gz
kubernetes: CVE-2020-8551 and CVE-2020-8552
Backport the CVE patches from the upstream: https://github.com/kubernetes/kubernetes.git Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers/kubernetes')
-rw-r--r--recipes-containers/kubernetes/kubernetes/CVE-2020-8551.patch303
-rw-r--r--recipes-containers/kubernetes/kubernetes/CVE-2020-8552.patch170
-rw-r--r--recipes-containers/kubernetes/kubernetes_git.bb2
3 files changed, 475 insertions, 0 deletions
diff --git a/recipes-containers/kubernetes/kubernetes/CVE-2020-8551.patch b/recipes-containers/kubernetes/kubernetes/CVE-2020-8551.patch
new file mode 100644
index 00000000..f1f87b0b
--- /dev/null
+++ b/recipes-containers/kubernetes/kubernetes/CVE-2020-8551.patch
@@ -0,0 +1,303 @@
1From 9bae583cb0c46380866c3df5d7a6d26aac335818 Mon Sep 17 00:00:00 2001
2From: Walter Fender <wfender@google.com>
3Date: Thu, 6 Feb 2020 19:10:18 -0800
4Subject: [PATCH] Add code to fix kubelet/metrics memory issue.
5
6Bucketing url paths based on concept/handling.
7Bucketing code placed by handling code to encourage usage.
8Added unit tests.
9Fix format.
10
11CVE: CVE-2020-8551
12Upstream-Status: Backport [https://github.com/kubernetes/kubernetes.git]
13Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
14---
15 pkg/kubelet/server/server.go | 56 ++++++++++++++++++++++++++++---
16 pkg/kubelet/server/server_test.go | 54 ++++++++++++++++++++++++++++-
17 2 files changed, 105 insertions(+), 5 deletions(-)
18
19diff --git a/src/import/pkg/kubelet/server/server.go b/src/import/pkg/kubelet/server/server.go
20index c1f1975fe43..f924304fc12 100644
21--- a/src/import/pkg/kubelet/server/server.go
22+++ b/src/import/pkg/kubelet/server/server.go
23@@ -90,6 +90,7 @@ type Server struct {
24 auth AuthInterface
25 host HostInterface
26 restfulCont containerInterface
27+ metricsBuckets map[string]bool
28 resourceAnalyzer stats.ResourceAnalyzer
29 redirectContainerStreaming bool
30 }
31@@ -224,6 +225,7 @@ func NewServer(
32 resourceAnalyzer: resourceAnalyzer,
33 auth: auth,
34 restfulCont: &filteringContainer{Container: restful.NewContainer()},
35+ metricsBuckets: make(map[string]bool),
36 redirectContainerStreaming: redirectContainerStreaming,
37 }
38 if auth != nil {
39@@ -279,14 +281,32 @@ func (s *Server) InstallAuthFilter() {
40 })
41 }
42
43+// addMetricsBucketMatcher adds a regexp matcher and the relevant bucket to use when
44+// it matches. Please be aware this is not thread safe and should not be used dynamically
45+func (s *Server) addMetricsBucketMatcher(bucket string) {
46+ s.metricsBuckets[bucket] = true
47+}
48+
49+// getMetricBucket find the appropriate metrics reporting bucket for the given path
50+func (s *Server) getMetricBucket(path string) string {
51+ root := getURLRootPath(path)
52+ if s.metricsBuckets[root] == true {
53+ return root
54+ }
55+ return "Invalid path"
56+}
57+
58 // InstallDefaultHandlers registers the default set of supported HTTP request
59 // patterns with the restful Container.
60 func (s *Server) InstallDefaultHandlers(enableCAdvisorJSONEndpoints bool) {
61+ s.addMetricsBucketMatcher("healthz")
62 healthz.InstallHandler(s.restfulCont,
63 healthz.PingHealthz,
64 healthz.LogHealthz,
65 healthz.NamedCheck("syncloop", s.syncLoopHealthCheck),
66 )
67+
68+ s.addMetricsBucketMatcher("pods")
69 ws := new(restful.WebService)
70 ws.
71 Path("/pods").
72@@ -296,7 +316,14 @@ func (s *Server) InstallDefaultHandlers(enableCAdvisorJSONEndpoints bool) {
73 Operation("getPods"))
74 s.restfulCont.Add(ws)
75
76+ s.addMetricsBucketMatcher("stats")
77 s.restfulCont.Add(stats.CreateHandlers(statsPath, s.host, s.resourceAnalyzer, enableCAdvisorJSONEndpoints))
78+
79+ s.addMetricsBucketMatcher("metrics")
80+ s.addMetricsBucketMatcher("metrics/cadvisor")
81+ s.addMetricsBucketMatcher("metrics/probes")
82+ s.addMetricsBucketMatcher("metrics/resource/v1alpha1")
83+ s.addMetricsBucketMatcher("metrics/resource")
84 //lint:ignore SA1019 https://github.com/kubernetes/enhancements/issues/1206
85 s.restfulCont.Handle(metricsPath, legacyregistry.Handler())
86
87@@ -316,6 +346,7 @@ func (s *Server) InstallDefaultHandlers(enableCAdvisorJSONEndpoints bool) {
88 promhttp.HandlerFor(r, promhttp.HandlerOpts{ErrorHandling: promhttp.ContinueOnError}),
89 )
90
91+ s.addMetricsBucketMatcher("metrics/resource/v1alpha1")
92 v1alpha1ResourceRegistry := prometheus.NewRegistry()
93 v1alpha1ResourceRegistry.MustRegister(stats.NewPrometheusResourceMetricCollector(s.resourceAnalyzer, v1alpha1.Config()))
94 s.restfulCont.Handle(path.Join(resourceMetricsPathPrefix, v1alpha1.Version),
95@@ -325,11 +357,14 @@ func (s *Server) InstallDefaultHandlers(enableCAdvisorJSONEndpoints bool) {
96
97 p := compbasemetrics.NewKubeRegistry()
98 compbasemetrics.RegisterProcessStartTime(p.RawRegister)
99+
100+ s.addMetricsBucketMatcher("metrics/probes")
101 p.MustRegister(prober.ProberResults)
102 s.restfulCont.Handle(proberMetricsPath,
103 promhttp.HandlerFor(p, promhttp.HandlerOpts{ErrorHandling: promhttp.ContinueOnError}),
104 )
105
106+ s.addMetricsBucketMatcher("spec")
107 if enableCAdvisorJSONEndpoints {
108 ws := new(restful.WebService)
109 ws.
110@@ -349,6 +384,7 @@ const pprofBasePath = "/debug/pprof/"
111 func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
112 klog.Infof("Adding debug handlers to kubelet server.")
113
114+ s.addMetricsBucketMatcher("run")
115 ws := new(restful.WebService)
116 ws.
117 Path("/run")
118@@ -360,6 +396,7 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
119 Operation("getRun"))
120 s.restfulCont.Add(ws)
121
122+ s.addMetricsBucketMatcher("exec")
123 ws = new(restful.WebService)
124 ws.
125 Path("/exec")
126@@ -377,6 +414,7 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
127 Operation("getExec"))
128 s.restfulCont.Add(ws)
129
130+ s.addMetricsBucketMatcher("attach")
131 ws = new(restful.WebService)
132 ws.
133 Path("/attach")
134@@ -394,6 +432,7 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
135 Operation("getAttach"))
136 s.restfulCont.Add(ws)
137
138+ s.addMetricsBucketMatcher("portForward")
139 ws = new(restful.WebService)
140 ws.
141 Path("/portForward")
142@@ -411,6 +450,7 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
143 Operation("getPortForward"))
144 s.restfulCont.Add(ws)
145
146+ s.addMetricsBucketMatcher("logs")
147 ws = new(restful.WebService)
148 ws.
149 Path(logsPath)
150@@ -423,6 +463,7 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
151 Param(ws.PathParameter("logpath", "path to the log").DataType("string")))
152 s.restfulCont.Add(ws)
153
154+ s.addMetricsBucketMatcher("containerLogs")
155 ws = new(restful.WebService)
156 ws.
157 Path("/containerLogs")
158@@ -431,8 +472,10 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
159 Operation("getContainerLogs"))
160 s.restfulCont.Add(ws)
161
162+ s.addMetricsBucketMatcher("configz")
163 configz.InstallHandler(s.restfulCont)
164
165+ s.addMetricsBucketMatcher("debug")
166 handlePprofEndpoint := func(req *restful.Request, resp *restful.Response) {
167 name := strings.TrimPrefix(req.Request.URL.Path, pprofBasePath)
168 switch name {
169@@ -448,7 +491,6 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
170 pprof.Index(resp, req.Request)
171 }
172 }
173-
174 // Setup pprof handlers.
175 ws = new(restful.WebService).Path(pprofBasePath)
176 ws.Route(ws.GET("/{subpath:*}").To(func(req *restful.Request, resp *restful.Response) {
177@@ -461,6 +503,7 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
178 s.restfulCont.Handle("/debug/flags/v", routes.StringFlagPutHandler(logs.GlogSetter))
179
180 // The /runningpods endpoint is used for testing only.
181+ s.addMetricsBucketMatcher("runningpods")
182 ws = new(restful.WebService)
183 ws.
184 Path("/runningpods/").
185@@ -470,6 +513,7 @@ func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
186 Operation("getRunningPods"))
187 s.restfulCont.Add(ws)
188
189+ s.addMetricsBucketMatcher("cri")
190 if criHandler != nil {
191 s.restfulCont.Handle("/cri/", criHandler)
192 }
193@@ -481,6 +525,14 @@ func (s *Server) InstallDebuggingDisabledHandlers() {
194 http.Error(w, "Debug endpoints are disabled.", http.StatusMethodNotAllowed)
195 })
196
197+ s.addMetricsBucketMatcher("run")
198+ s.addMetricsBucketMatcher("exec")
199+ s.addMetricsBucketMatcher("attach")
200+ s.addMetricsBucketMatcher("portForward")
201+ s.addMetricsBucketMatcher("containerLogs")
202+ s.addMetricsBucketMatcher("runningpods")
203+ s.addMetricsBucketMatcher("pprof")
204+ s.addMetricsBucketMatcher("logs")
205 paths := []string{
206 "/run/", "/exec/", "/attach/", "/portForward/", "/containerLogs/",
207 "/runningpods/", pprofBasePath, logsPath}
208@@ -814,10 +849,10 @@ func (s *Server) getPortForward(request *restful.Request, response *restful.Resp
209 proxyStream(response.ResponseWriter, request.Request, url)
210 }
211
212-// trimURLPath trims a URL path.
213+// getURLRootPath trims a URL path.
214 // For paths in the format of "/metrics/xxx", "metrics/xxx" is returned;
215 // For all other paths, the first part of the path is returned.
216-func trimURLPath(path string) string {
217+func getURLRootPath(path string) string {
218 parts := strings.SplitN(strings.TrimPrefix(path, "/"), "/", 3)
219 if len(parts) == 0 {
220 return path
221@@ -865,7 +900,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
222 serverType = "readwrite"
223 }
224
225- method, path := req.Method, trimURLPath(req.URL.Path)
226+ method, path := req.Method, s.getMetricBucket(req.URL.Path)
227
228 longRunning := strconv.FormatBool(isLongRunningRequest(path))
229
230diff --git a/src/import/pkg/kubelet/server/server_test.go b/src/import/pkg/kubelet/server/server_test.go
231index 4761d21afb7..a95e5d19f0b 100644
232--- a/src/import/pkg/kubelet/server/server_test.go
233+++ b/src/import/pkg/kubelet/server/server_test.go
234@@ -1612,6 +1612,58 @@ func TestCRIHandler(t *testing.T) {
235 assert.Equal(t, query, fw.criHandler.RequestReceived.URL.RawQuery)
236 }
237
238+func TestMetricBuckets(t *testing.T) {
239+ tests := map[string]struct {
240+ url string
241+ bucket string
242+ }{
243+ "healthz endpoint": {url: "/healthz", bucket: "healthz"},
244+ "attach": {url: "/attach/podNamespace/podID/containerName", bucket: "attach"},
245+ "attach with uid": {url: "/attach/podNamespace/podID/uid/containerName", bucket: "attach"},
246+ "configz": {url: "/configz", bucket: "configz"},
247+ "containerLogs": {url: "/containerLogs/podNamespace/podID/containerName", bucket: "containerLogs"},
248+ "cri": {url: "/cri/", bucket: "cri"},
249+ "cri with sub": {url: "/cri/foo", bucket: "cri"},
250+ "debug v flags": {url: "/debug/flags/v", bucket: "debug"},
251+ "pprof with sub": {url: "/debug/pprof/subpath", bucket: "debug"},
252+ "exec": {url: "/exec/podNamespace/podID/containerName", bucket: "exec"},
253+ "exec with uid": {url: "/exec/podNamespace/podID/uid/containerName", bucket: "exec"},
254+ "healthz": {url: "/healthz/", bucket: "healthz"},
255+ "healthz log sub": {url: "/healthz/log", bucket: "healthz"},
256+ "healthz ping": {url: "/healthz/ping", bucket: "healthz"},
257+ "healthz sync loop": {url: "/healthz/syncloop", bucket: "healthz"},
258+ "logs": {url: "/logs/", bucket: "logs"},
259+ "logs with path": {url: "/logs/logpath", bucket: "logs"},
260+ "metrics": {url: "/metrics", bucket: "metrics"},
261+ "metrics cadvisor sub": {url: "/metrics/cadvisor", bucket: "metrics/cadvisor"},
262+ "metrics probes sub": {url: "/metrics/probes", bucket: "metrics/probes"},
263+ "metrics resource v1alpha1": {url: "/metrics/resource/v1alpha1", bucket: "metrics/resource"},
264+ "metrics resource sub": {url: "/metrics/resource", bucket: "metrics/resource"},
265+ "pods": {url: "/pods/", bucket: "pods"},
266+ "portForward": {url: "/portForward/podNamespace/podID", bucket: "portForward"},
267+ "portForward with uid": {url: "/portForward/podNamespace/podID/uid", bucket: "portForward"},
268+ "run": {url: "/run/podNamespace/podID/containerName", bucket: "run"},
269+ "run with uid": {url: "/run/podNamespace/podID/uid/containerName", bucket: "run"},
270+ "runningpods": {url: "/runningpods/", bucket: "runningpods"},
271+ "spec": {url: "/spec/", bucket: "spec"},
272+ "stats": {url: "/stats/", bucket: "stats"},
273+ "stats container sub": {url: "/stats/container", bucket: "stats"},
274+ "stats summary sub": {url: "/stats/summary", bucket: "stats"},
275+ "stats containerName with uid": {url: "/stats/namespace/podName/uid/containerName", bucket: "stats"},
276+ "stats containerName": {url: "/stats/podName/containerName", bucket: "stats"},
277+ "invalid path": {url: "/junk", bucket: "Invalid path"},
278+ "invalid path starting with good": {url: "/healthzjunk", bucket: "Invalid path"},
279+ }
280+ fw := newServerTest()
281+ defer fw.testHTTPServer.Close()
282+
283+ for _, test := range tests {
284+ path := test.url
285+ bucket := test.bucket
286+ require.Equal(t, fw.serverUnderTest.getMetricBucket(path), bucket)
287+ }
288+}
289+
290 func TestDebuggingDisabledHandlers(t *testing.T) {
291 fw := newServerTestWithDebug(false, false, nil)
292 defer fw.testHTTPServer.Close()
293@@ -1685,6 +1737,6 @@ func TestTrimURLPath(t *testing.T) {
294 }
295
296 for _, test := range tests {
297- assert.Equal(t, test.expected, trimURLPath(test.path), fmt.Sprintf("path is: %s", test.path))
298+ assert.Equal(t, test.expected, getURLRootPath(test.path), fmt.Sprintf("path is: %s", test.path))
299 }
300 }
301--
3022.17.0
303
diff --git a/recipes-containers/kubernetes/kubernetes/CVE-2020-8552.patch b/recipes-containers/kubernetes/kubernetes/CVE-2020-8552.patch
new file mode 100644
index 00000000..85d7fcbb
--- /dev/null
+++ b/recipes-containers/kubernetes/kubernetes/CVE-2020-8552.patch
@@ -0,0 +1,170 @@
1From cc3190968b1f14ddf4067abef849fc41bd6068dc Mon Sep 17 00:00:00 2001
2From: Han Kang <hankang@google.com>
3Date: Wed, 29 Jan 2020 12:25:55 -0800
4Subject: [PATCH] remove client label from apiserver request count metric since
5 it is unbounded
6
7Change-Id: I3a9eacebc9d9dc9ed6347260d9378cdcb5743431
8
9CVE: CVE-2020-8552
10Upstream-Status: Backport [Cherry-picked from https://github.com/kubernetes/kubernetes.git tag:v1.18.0]
11Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
12---
13 .../apiserver/pkg/endpoints/metrics/BUILD | 8 ---
14 .../pkg/endpoints/metrics/metrics.go | 21 ++------
15 .../pkg/endpoints/metrics/metrics_test.go | 54 -------------------
16 3 files changed, 3 insertions(+), 80 deletions(-)
17 delete mode 100644 staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics_test.go
18
19diff --git a/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/BUILD b/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/BUILD
20index 8d13a34eadc..8abb3d1a611 100644
21--- a/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/BUILD
22+++ b/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/BUILD
23@@ -3,13 +3,6 @@ package(default_visibility = ["//visibility:public"])
24 load(
25 "@io_bazel_rules_go//go:def.bzl",
26 "go_library",
27- "go_test",
28-)
29-
30-go_test(
31- name = "go_default_test",
32- srcs = ["metrics_test.go"],
33- embed = [":go_default_library"],
34 )
35
36 go_library(
37@@ -20,7 +13,6 @@ go_library(
38 deps = [
39 "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation:go_default_library",
40 "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
41- "//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
42 "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
43 "//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
44 "//staging/src/k8s.io/apiserver/pkg/features:go_default_library",
45diff --git a/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go b/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go
46index f4e02fbb6a8..c79efdef4e3 100644
47--- a/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go
48+++ b/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go
49@@ -29,7 +29,6 @@ import (
50
51 "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
52 "k8s.io/apimachinery/pkg/types"
53- utilnet "k8s.io/apimachinery/pkg/util/net"
54 utilsets "k8s.io/apimachinery/pkg/util/sets"
55 "k8s.io/apiserver/pkg/endpoints/request"
56 "k8s.io/apiserver/pkg/features"
57@@ -66,14 +65,14 @@ var (
58 requestCounter = compbasemetrics.NewCounterVec(
59 &compbasemetrics.CounterOpts{
60 Name: "apiserver_request_total",
61- Help: "Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, client, and HTTP response contentType and code.",
62+ Help: "Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, and HTTP response contentType and code.",
63 StabilityLevel: compbasemetrics.ALPHA,
64 },
65 // The label_name contentType doesn't follow the label_name convention defined here:
66 // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/instrumentation.md
67 // But changing it would break backwards compatibility. Future label_names
68 // should be all lowercase and separated by underscores.
69- []string{"verb", "dry_run", "group", "version", "resource", "subresource", "scope", "component", "client", "contentType", "code"},
70+ []string{"verb", "dry_run", "group", "version", "resource", "subresource", "scope", "component", "contentType", "code"},
71 )
72 deprecatedRequestCounter = compbasemetrics.NewCounterVec(
73 &compbasemetrics.CounterOpts{
74@@ -243,11 +242,10 @@ func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, comp
75 func MonitorRequest(req *http.Request, verb, group, version, resource, subresource, scope, component, contentType string, httpCode, respSize int, elapsed time.Duration) {
76 reportedVerb := cleanVerb(verb, req)
77 dryRun := cleanDryRun(req.URL)
78- client := cleanUserAgent(utilnet.GetHTTPClient(req))
79 elapsedMicroseconds := float64(elapsed / time.Microsecond)
80 elapsedSeconds := elapsed.Seconds()
81- requestCounter.WithLabelValues(reportedVerb, dryRun, group, version, resource, subresource, scope, component, client, contentType, codeToString(httpCode)).Inc()
82- deprecatedRequestCounter.WithLabelValues(reportedVerb, group, version, resource, subresource, scope, component, client, contentType, codeToString(httpCode)).Inc()
83+ requestCounter.WithLabelValues(reportedVerb, dryRun, group, version, resource, subresource, scope, component, contentType, codeToString(httpCode)).Inc()
84+ deprecatedRequestCounter.WithLabelValues(reportedVerb, group, version, resource, subresource, scope, component, contentType, codeToString(httpCode)).Inc()
85 requestLatencies.WithLabelValues(reportedVerb, dryRun, group, version, resource, subresource, scope, component).Observe(elapsedSeconds)
86 deprecatedRequestLatencies.WithLabelValues(reportedVerb, group, version, resource, subresource, scope, component).Observe(elapsedMicroseconds)
87 deprecatedRequestLatenciesSummary.WithLabelValues(reportedVerb, group, version, resource, subresource, scope, component).Observe(elapsedMicroseconds)
88@@ -355,19 +353,6 @@ func cleanDryRun(u *url.URL) string {
89 return strings.Join(utilsets.NewString(dryRun...).List(), ",")
90 }
91
92-func cleanUserAgent(ua string) string {
93- // We collapse all "web browser"-type user agents into one "browser" to reduce metric cardinality.
94- if strings.HasPrefix(ua, "Mozilla/") {
95- return "Browser"
96- }
97- // If an old "kubectl.exe" has passed us its full path, we discard the path portion.
98- if kubectlExeRegexp.MatchString(ua) {
99- // avoid an allocation
100- ua = kubectlExeRegexp.ReplaceAllString(ua, "$1")
101- }
102- return ua
103-}
104-
105 // ResponseWriterDelegator interface wraps http.ResponseWriter to additionally record content-length, status-code, etc.
106 type ResponseWriterDelegator struct {
107 http.ResponseWriter
108diff --git a/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics_test.go b/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics_test.go
109deleted file mode 100644
110index 4c0a8aa5d27..00000000000
111--- a/src/import/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics_test.go
112+++ /dev/null
113@@ -1,54 +0,0 @@
114-/*
115-Copyright 2015 The Kubernetes Authors.
116-
117-Licensed under the Apache License, Version 2.0 (the "License");
118-you may not use this file except in compliance with the License.
119-You may obtain a copy of the License at
120-
121- http://www.apache.org/licenses/LICENSE-2.0
122-
123-Unless required by applicable law or agreed to in writing, software
124-distributed under the License is distributed on an "AS IS" BASIS,
125-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
126-See the License for the specific language governing permissions and
127-limitations under the License.
128-*/
129-
130-package metrics
131-
132-import "testing"
133-
134-func TestCleanUserAgent(t *testing.T) {
135- panicBuf := []byte{198, 73, 129, 133, 90, 216, 104, 29, 13, 134, 209, 233, 30, 0, 22}
136-
137- for _, tc := range []struct {
138- In string
139- Out string
140- }{
141- {
142- In: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36",
143- Out: "Browser",
144- },
145- {
146- In: "kubectl/v1.2.4",
147- Out: "kubectl/v1.2.4",
148- },
149- {
150- In: `C:\Users\Kubernetes\kubectl.exe/v1.5.4`,
151- Out: "kubectl.exe/v1.5.4",
152- },
153- {
154- In: `C:\Program Files\kubectl.exe/v1.5.4`,
155- Out: "kubectl.exe/v1.5.4",
156- },
157- {
158- // This malicious input courtesy of enisoc.
159- In: string(panicBuf) + "kubectl.exe",
160- Out: "kubectl.exe",
161- },
162- } {
163- if cleanUserAgent(tc.In) != tc.Out {
164- t.Errorf("Failed to clean User-Agent: %s", tc.In)
165- }
166- }
167-}
168--
1692.17.0
170
diff --git a/recipes-containers/kubernetes/kubernetes_git.bb b/recipes-containers/kubernetes/kubernetes_git.bb
index fae554da..c378ccc5 100644
--- a/recipes-containers/kubernetes/kubernetes_git.bb
+++ b/recipes-containers/kubernetes/kubernetes_git.bb
@@ -12,6 +12,8 @@ SRC_URI = "git://github.com/kubernetes/kubernetes.git;branch=release-1.16;name=k
12 file://0001-hack-lib-golang.sh-use-CC-from-environment.patch \ 12 file://0001-hack-lib-golang.sh-use-CC-from-environment.patch \
13 file://0001-cross-don-t-build-tests-by-default.patch \ 13 file://0001-cross-don-t-build-tests-by-default.patch \
14 file://0001-fix-compiling-failure-execvp-bin-bash-Argument-list-.patch \ 14 file://0001-fix-compiling-failure-execvp-bin-bash-Argument-list-.patch \
15 file://CVE-2020-8551.patch \
16 file://CVE-2020-8552.patch \
15 " 17 "
16 18
17DEPENDS += "rsync-native \ 19DEPENDS += "rsync-native \