From 32c5e5f2408498df4a5d55ed5c87575115bc4213 Mon Sep 17 00:00:00 2001 From: David Suarez Date: Sun, 19 Sep 2021 11:50:37 -0500 Subject: [PATCH] Fix security warning following instructions --- api/httpListener_test.go | 7 +++---- go.mod | 4 +++- go.sum | 10 +++++----- security/auth.go | 2 +- security/cognito.go | 2 +- test/e2e.go | 7 ++++--- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/api/httpListener_test.go b/api/httpListener_test.go index 3dbb9f5..0df1be1 100644 --- a/api/httpListener_test.go +++ b/api/httpListener_test.go @@ -33,11 +33,7 @@ func (routes testRoutes) StartServer() bool { } func init() { - //start listener log.Println("Init called on listener test") - go StartHTTPListener(testRoutes{}) - // TODO: listen to startup vs. assuming like below, this will work for now - time.Sleep(1 * time.Second) //set local http client for validation httpClient = &http.Client{} } @@ -46,6 +42,9 @@ func init() { //TestHealthCheck - Validates healthcheck was setup as expected (validates default host/port as side effect) func TestHealthCheck(t *testing.T) { + go StartHTTPListener(testRoutes{}) + // TODO: listen to startup vs. assuming like below, this will work for now + time.Sleep(1 * time.Second) //Setting as real integration style client vs. unit test style in mux example resp, err := httpClient.Get(os.Getenv("PROCESS_LISTEN_URI") + "/health") if err != nil { diff --git a/go.mod b/go.mod index 323dfc7..6085af0 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,11 @@ module github.com/suared/core +go 1.16 + require ( github.com/aws/aws-sdk-go v1.23.17 - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/getsentry/sentry-go v0.4.0 + github.com/golang-jwt/jwt/v4 v4.0.0 github.com/gorilla/mux v1.7.3 github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8 github.com/joho/godotenv v1.3.0 diff --git a/go.sum b/go.sum index 1849a2c..c4adfd8 100644 --- a/go.sum +++ b/go.sum @@ -20,7 +20,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -43,6 +42,8 @@ github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22 github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/golang-jwt/jwt/v4 v4.0.0 h1:RAqyYixv1p7uEnocuy8P1nru5wprCh/MH2BIlW5z5/o= +github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= @@ -109,8 +110,8 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -167,8 +168,8 @@ golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -182,8 +183,8 @@ golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -194,7 +195,6 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= diff --git a/security/auth.go b/security/auth.go index 05c349f..1a3956f 100644 --- a/security/auth.go +++ b/security/auth.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "github.com/dgrijalva/jwt-go" + jwt "github.com/golang-jwt/jwt/v4" ) var authKey key diff --git a/security/cognito.go b/security/cognito.go index 30b30b5..1d8d009 100644 --- a/security/cognito.go +++ b/security/cognito.go @@ -19,7 +19,7 @@ import ( "strings" "time" - jwt "github.com/dgrijalva/jwt-go" + jwt "github.com/golang-jwt/jwt/v4" ) var jwks map[string]map[string]JWKKey diff --git a/test/e2e.go b/test/e2e.go index 39f7f78..d210fc0 100644 --- a/test/e2e.go +++ b/test/e2e.go @@ -3,6 +3,7 @@ package test import ( "bytes" "errors" + "fmt" "io/ioutil" "net/http" ) @@ -27,7 +28,7 @@ func SimpleGet(uri string) (string, error) { // Check the status code is what we expect. if status := resp.StatusCode; status != http.StatusOK { - err = errors.New(string(status) + ": " + stringbody + ": accessing: " + uri) + err = errors.New(fmt.Sprint(status) + ": " + stringbody + ": accessing: " + uri) } return stringbody, err @@ -51,13 +52,13 @@ func SimplePost(uri string, jsonBytes []byte) (string, error) { // Check the status code is what we expect. if status := resp.StatusCode; status != http.StatusOK { - err = errors.New(string(status) + ":" + stringbody) + err = errors.New(fmt.Sprint(status) + ":" + stringbody) return "", err } if len(locationArray) == 0 { //log.Printf("Fell into location header miss error, locArray: %v, len: %v", locationArray, len(locationArray)) - err = errors.New(stringbody + ": No or Unexpected Location Header. Location header length: " + string(len(locationArray))) + err = errors.New(stringbody + ": No or Unexpected Location Header. Location header length: " + fmt.Sprint(len(locationArray))) return "", err }