Skip to content

Commit 5e6f606

Browse files
committed
TUN-6293: Update yaml v3 to latest hotfix
This addresses https://security.snyk.io/vuln/SNYK-GOLANG-GOPKGINYAMLV3-2841557 by updating yaml v3 to latest version. It also stops using yaml v2 directly (we were using both v2 and v3 mixed). We still rely on yaml v2 indirectly, via urfave cli, though. Note that the security vulnerability does not affect v2.
1 parent 919227f commit 5e6f606

Some content is hidden

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

64 files changed

+93
-11793
lines changed

cmd/cloudflared/tunnel/subcommands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/urfave/cli/v2"
2121
"github.com/urfave/cli/v2/altsrc"
2222
"golang.org/x/net/idna"
23-
yaml "gopkg.in/yaml.v2"
23+
yaml "gopkg.in/yaml.v3"
2424

2525
"github.com/cloudflare/cloudflared/cfapi"
2626
"github.com/cloudflare/cloudflared/cmd/cloudflared/cliutil"

config/configuration_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/stretchr/testify/assert"
99
"github.com/stretchr/testify/require"
10-
yaml "gopkg.in/yaml.v2"
10+
yaml "gopkg.in/yaml.v3"
1111
)
1212

1313
func TestConfigFileSettings(t *testing.T) {
@@ -111,7 +111,7 @@ counters:
111111

112112
}
113113

114-
var rawConfig = []byte(`
114+
var rawJsonConfig = []byte(`
115115
{
116116
"connectTimeout": 10,
117117
"tlsTimeout": 30,
@@ -148,15 +148,14 @@ func TestMarshalUnmarshalOriginRequest(t *testing.T) {
148148
name string
149149
marshalFunc func(in interface{}) (out []byte, err error)
150150
unMarshalFunc func(in []byte, out interface{}) (err error)
151-
baseUnit time.Duration
152151
}{
153-
{"json", json.Marshal, json.Unmarshal, time.Second},
154-
{"yaml", yaml.Marshal, yaml.Unmarshal, time.Nanosecond},
152+
{"json", json.Marshal, json.Unmarshal},
153+
{"yaml", yaml.Marshal, yaml.Unmarshal},
155154
}
156155

157156
for _, tc := range testCases {
158157
t.Run(tc.name, func(t *testing.T) {
159-
assertConfig(t, tc.marshalFunc, tc.unMarshalFunc, tc.baseUnit)
158+
assertConfig(t, tc.marshalFunc, tc.unMarshalFunc)
160159
})
161160
}
162161
}
@@ -165,18 +164,17 @@ func assertConfig(
165164
t *testing.T,
166165
marshalFunc func(in interface{}) (out []byte, err error),
167166
unMarshalFunc func(in []byte, out interface{}) (err error),
168-
baseUnit time.Duration,
169167
) {
170168
var config OriginRequestConfig
171169
var config2 OriginRequestConfig
172170

173-
assert.NoError(t, unMarshalFunc(rawConfig, &config))
171+
assert.NoError(t, json.Unmarshal(rawJsonConfig, &config))
174172

175-
assert.Equal(t, baseUnit*10, config.ConnectTimeout.Duration)
176-
assert.Equal(t, baseUnit*30, config.TLSTimeout.Duration)
177-
assert.Equal(t, baseUnit*30, config.TCPKeepAlive.Duration)
173+
assert.Equal(t, time.Second*10, config.ConnectTimeout.Duration)
174+
assert.Equal(t, time.Second*30, config.TLSTimeout.Duration)
175+
assert.Equal(t, time.Second*30, config.TCPKeepAlive.Duration)
178176
assert.Equal(t, true, *config.NoHappyEyeballs)
179-
assert.Equal(t, baseUnit*60, config.KeepAliveTimeout.Duration)
177+
assert.Equal(t, time.Second*60, config.KeepAliveTimeout.Duration)
180178
assert.Equal(t, 10, *config.KeepAliveConnections)
181179
assert.Equal(t, "app.tunnel.com", *config.HTTPHostHeader)
182180
assert.Equal(t, "app.tunnel.com", *config.OriginServerName)

config/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/pkg/errors"
88
"github.com/rs/zerolog"
9-
yaml "gopkg.in/yaml.v2"
9+
yaml "gopkg.in/yaml.v3"
1010

1111
"github.com/cloudflare/cloudflared/watcher"
1212
)

go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ require (
4444
gopkg.in/coreos/go-oidc.v2 v2.2.1
4545
gopkg.in/natefinch/lumberjack.v2 v2.0.0
4646
gopkg.in/square/go-jose.v2 v2.6.0
47-
gopkg.in/yaml.v2 v2.4.0
48-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
47+
gopkg.in/yaml.v3 v3.0.1
4948
zombiezen.com/go/capnproto2 v2.18.0+incompatible
5049
)
5150

@@ -64,7 +63,6 @@ require (
6463
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
6564
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect
6665
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
67-
github.com/francoispqt/gojay v1.2.13 // indirect
6866
github.com/gdamore/encoding v1.0.0 // indirect
6967
github.com/go-logr/logr v1.2.3 // indirect
7068
github.com/go-logr/stdr v1.2.2 // indirect
@@ -102,6 +100,7 @@ require (
102100
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect
103101
google.golang.org/grpc v1.45.0 // indirect
104102
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
103+
gopkg.in/yaml.v2 v2.4.0 // indirect
105104
)
106105

107106
replace github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI
184184
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
185185
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
186186
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
187-
github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=
188187
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
189188
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
190189
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -1110,8 +1109,9 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
11101109
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
11111110
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
11121111
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1113-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
11141112
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1113+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1114+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
11151115
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
11161116
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
11171117
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

ingress/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/stretchr/testify/require"
1010
"github.com/urfave/cli/v2"
11-
yaml "gopkg.in/yaml.v2"
11+
yaml "gopkg.in/yaml.v3"
1212

1313
"github.com/cloudflare/cloudflared/config"
1414
"github.com/cloudflare/cloudflared/ipaccess"

ingress/ingress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/stretchr/testify/assert"
1313
"github.com/stretchr/testify/require"
1414
"github.com/urfave/cli/v2"
15-
yaml "gopkg.in/yaml.v2"
15+
yaml "gopkg.in/yaml.v3"
1616

1717
"github.com/cloudflare/cloudflared/config"
1818
"github.com/cloudflare/cloudflared/ipaccess"

vendor/github.com/francoispqt/gojay/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

vendor/github.com/francoispqt/gojay/.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

vendor/github.com/francoispqt/gojay/Gopkg.lock

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)