Skip to content

Commit

Permalink
Switch uuid package to get around GO-2020-0018
Browse files Browse the repository at this point in the history
Replace the github.com/satori/go.uuid package with the github.com/gofrs/uuid
package to work around the GO-2020-0018 vulnerability.
The vulnerability is fixed in satori/go.uuid#75,
but a release has never been tagged.
  • Loading branch information
rutgerc-klarrio committed May 31, 2022
1 parent 3bb7499 commit d7bdffc
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 71 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ require (
github.com/docker/leadership v0.1.0
github.com/docker/libkv v0.2.1
github.com/evanphx/json-patch v4.5.0+incompatible
github.com/gofrs/uuid v4.2.0+incompatible
github.com/golang/mock v1.4.0
github.com/google/go-cmp v0.4.0
github.com/hashicorp/consul/api v1.4.0
github.com/lib/pq v1.3.0
github.com/mattn/go-isatty v0.0.12
github.com/mitchellh/copystructure v1.0.0
github.com/prometheus/client_golang v1.4.1
github.com/satori/go.uuid v1.2.0
github.com/sgotti/gexpect v0.0.0-20210315095146-1ec64e69809b
github.com/sorintlab/pollon v0.0.0-20181009091703-248c68238c16
github.com/spf13/cobra v0.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I=
Expand Down Expand Up @@ -290,8 +292,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sgotti/gexpect v0.0.0-20210315095146-1ec64e69809b h1:rGT0mqolw5UvjfByF0vWfFEhtL7Hn6P7dNKz7iHBMdA=
Expand Down
6 changes: 3 additions & 3 deletions internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"reflect"
"strings"

"github.com/satori/go.uuid"
"github.com/gofrs/uuid"
)

const (
Expand All @@ -50,12 +50,12 @@ var Roles = []Role{
}

func UID() string {
u := uuid.NewV4()
u := uuid.Must(uuid.NewV4())
return fmt.Sprintf("%x", u[:4])
}

func UUID() string {
return uuid.NewV4().String()
return uuid.Must(uuid.NewV4()).String()
}

const (
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/sorintlab/stolon/internal/common"
"github.com/sorintlab/stolon/internal/store"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
)

func TestServerParameters(t *testing.T) {
Expand All @@ -52,7 +52,7 @@ func TestServerParameters(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -149,7 +149,7 @@ func TestWalLevel(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -264,7 +264,7 @@ func TestWalKeepSegments(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -437,7 +437,7 @@ func TestAlterSystem(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -509,7 +509,7 @@ func TestAdditionalReplicationSlots(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, false, false, nil)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -658,7 +658,7 @@ func TestAutomaticPgRestart(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -782,7 +782,7 @@ func TestAdvertise(t *testing.T) {
storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)
defer tstore.Stop()

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down
50 changes: 25 additions & 25 deletions tests/integration/ha_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"testing"
"time"

uuid "github.com/satori/go.uuid"
"github.com/gofrs/uuid"
"github.com/sorintlab/stolon/internal/cluster"
"github.com/sorintlab/stolon/internal/common"
pg "github.com/sorintlab/stolon/internal/postgresql"
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestInitWithMultipleKeepers(t *testing.T) {

storeEndpoints := fmt.Sprintf("%s:%s", tstore.listenAddress, tstore.port)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

storePath := filepath.Join(common.StorePrefix, clusterName)

Expand Down Expand Up @@ -333,7 +333,7 @@ func testMasterStandby(t *testing.T, syncRepl bool) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, false, nil)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -388,7 +388,7 @@ func testFailover(t *testing.T, syncRepl bool, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -397,7 +397,7 @@ func testFailover(t *testing.T, syncRepl bool, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -499,7 +499,7 @@ func testFailoverFailed(t *testing.T, syncRepl bool, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -508,7 +508,7 @@ func testFailoverFailed(t *testing.T, syncRepl bool, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -611,7 +611,7 @@ func testFailoverTooMuchLag(t *testing.T, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -620,7 +620,7 @@ func testFailoverTooMuchLag(t *testing.T, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, false, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -690,7 +690,7 @@ func testOldMasterRestart(t *testing.T, syncRepl, minSync0 bool, usePgrewind boo
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -699,7 +699,7 @@ func testOldMasterRestart(t *testing.T, syncRepl, minSync0 bool, usePgrewind boo
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

specOptions := []optionSetter{
withMinSync0(minSync0),
Expand Down Expand Up @@ -844,7 +844,7 @@ func testPartition1(t *testing.T, syncRepl, minSync0, usePgrewind bool, standbyC
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -853,7 +853,7 @@ func testPartition1(t *testing.T, syncRepl, minSync0, usePgrewind bool, standbyC
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

specOptions := []optionSetter{
withMinSync0(minSync0),
Expand Down Expand Up @@ -1010,7 +1010,7 @@ func testTimelineFork(t *testing.T, syncRepl, usePgrewind bool) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, usePgrewind, nil)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -1206,7 +1206,7 @@ func testMasterChangedAddress(t *testing.T, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -1215,7 +1215,7 @@ func testMasterChangedAddress(t *testing.T, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, false, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -1301,7 +1301,7 @@ func TestFailedStandby(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1392,7 +1392,7 @@ func TestLoweredMaxStandbysPerSender(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1457,7 +1457,7 @@ func TestKeeperRemoval(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1565,7 +1565,7 @@ func testKeeperRemovalStolonCtl(t *testing.T, syncRepl bool) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1691,7 +1691,7 @@ func TestStandbyCantSync(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

initialClusterSpec := &cluster.ClusterSpec{
InitMode: cluster.ClusterInitModeP(cluster.ClusterInitModeNew),
Expand Down Expand Up @@ -1821,7 +1821,7 @@ func TestDisappearedKeeperData(t *testing.T) {
}
defer os.RemoveAll(dir)

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, false, false, nil)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -1905,7 +1905,7 @@ func testForceFail(t *testing.T, syncRepl bool, standbyCluster bool) {
var ptk *TestKeeper
var primary *TestKeeper
if standbyCluster {
primaryClusterName := uuid.NewV4().String()
primaryClusterName := uuid.Must(uuid.NewV4()).String()
ptks, ptss, ptp, ptstore := setupServers(t, primaryClusterName, dir, 1, 1, false, false, nil)
defer shutdown(ptks, ptss, ptp, ptstore)
for _, ptk = range ptks {
Expand All @@ -1914,7 +1914,7 @@ func testForceFail(t *testing.T, syncRepl bool, standbyCluster bool) {
primary = ptk
}

clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()

tks, tss, tp, tstore := setupServers(t, clusterName, dir, 2, 1, syncRepl, false, ptk)
defer shutdown(tks, tss, tp, tstore)
Expand Down Expand Up @@ -2017,7 +2017,7 @@ func testSyncStandbyNotInSync(t *testing.T, minSync0 bool) {
t.Fatalf("unexpected err: %v", err)
}
defer os.RemoveAll(dir)
clusterName := uuid.NewV4().String()
clusterName := uuid.Must(uuid.NewV4()).String()
clusterOpts := []optionSetter{
withMinSync0(minSync0),
}
Expand Down
Loading

0 comments on commit d7bdffc

Please sign in to comment.