From 5cfd7d153cdb77b6552f5460612806391b5378f0 Mon Sep 17 00:00:00 2001 From: poneding Date: Fri, 12 Apr 2024 11:57:07 +0800 Subject: [PATCH] fix: panic encoding alphabet includes duplicate symbols in go1.22 --- cloud/src/rasp-cloud/models/app.go | 12 +- cloud/src/rasp-cloud/tests/coverage.html | 837 +++++++++++++++-------- 2 files changed, 546 insertions(+), 303 deletions(-) diff --git a/cloud/src/rasp-cloud/models/app.go b/cloud/src/rasp-cloud/models/app.go index d26da161d..0d37e264d 100644 --- a/cloud/src/rasp-cloud/models/app.go +++ b/cloud/src/rasp-cloud/models/app.go @@ -24,10 +24,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/astaxie/beego" - "github.com/astaxie/beego/httplib" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" "html/template" "io/ioutil" "math/rand" @@ -45,6 +41,11 @@ import ( "strconv" "strings" "time" + + "github.com/astaxie/beego" + "github.com/astaxie/beego/httplib" + "gopkg.in/mgo.v2" + "gopkg.in/mgo.v2/bson" ) type App struct { @@ -469,8 +470,7 @@ func generateSecret(app *App) string { random := "openrasp_app" + app.Name + app.Id + strconv.FormatInt(time.Now().UnixNano(), 10) + strconv.Itoa(rand.Intn(10000)) sha256Data := sha256.Sum256([]byte(random)) - base64Data := base64.NewEncoding("OPQRSTYZabcdefgABCDEFGHIJKLMNhijklmnopqrUVWXstuvwxyz01234567891q"). - EncodeToString(sha256Data[0:]) + base64Data := base64.StdEncoding.EncodeToString(sha256Data[0:]) return base64Data[0 : len(base64Data)-1] } diff --git a/cloud/src/rasp-cloud/tests/coverage.html b/cloud/src/rasp-cloud/tests/coverage.html index c94540f24..a55bc01fb 100644 --- a/cloud/src/rasp-cloud/tests/coverage.html +++ b/cloud/src/rasp-cloud/tests/coverage.html @@ -1,172 +1,263 @@ - - - - - - -
- -
- not tracked - - not covered - covered - -
-
-
- -
+ +