From 0526f7abfadf8154fb53a219bb9953d9707ff524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kokelj?= Date: Fri, 26 Apr 2024 11:32:51 +0200 Subject: [PATCH] Ziga/gateway verbose logging and bugfix (#1884) * verbose logging on deployed gateway * fix type checking for user inputs --- .github/workflows/manual-deploy-obscuro-gateway.yml | 2 +- tools/walletextension/httpapi/routes.go | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/manual-deploy-obscuro-gateway.yml b/.github/workflows/manual-deploy-obscuro-gateway.yml index 20f059305e..c49be6783f 100644 --- a/.github/workflows/manual-deploy-obscuro-gateway.yml +++ b/.github/workflows/manual-deploy-obscuro-gateway.yml @@ -137,5 +137,5 @@ jobs: && docker run -d -p 80:80 -p 81:81 --name ${{ github.event.inputs.testnet_type }}-OG-${{ GITHUB.RUN_NUMBER }} \ -e OBSCURO_GATEWAY_VERSION="${{ GITHUB.RUN_NUMBER }}-${{ GITHUB.SHA }}" \ ${{ vars.DOCKER_BUILD_TAG_GATEWAY }} \ - -host=0.0.0.0 -port=8080 -portWS=81 -nodeHost=${{ vars.L2_RPC_URL_VALIDATOR }} \ + -host=0.0.0.0 -port=8080 -portWS=81 -nodeHost=${{ vars.L2_RPC_URL_VALIDATOR }} -verbose=true \ -logPath=sys_out -dbType=mariaDB -dbConnectionURL="obscurouser:${{ secrets.OBSCURO_GATEWAY_MARIADB_USER_PWD }}@tcp(obscurogateway-mariadb-${{ github.event.inputs.testnet_type }}.uksouth.cloudapp.azure.com:3306)/ogdb"' diff --git a/tools/walletextension/httpapi/routes.go b/tools/walletextension/httpapi/routes.go index 883d96d9ed..abb8f9573a 100644 --- a/tools/walletextension/httpapi/routes.go +++ b/tools/walletextension/httpapi/routes.go @@ -332,7 +332,7 @@ func versionRequestHandler(walletExt *rpcapi.Services, userConn UserConn) { } } -// getMessageRequestHandler handles request to /get-message endpoint. +// getMessageRequestHandler handles request to /getmessage endpoint. func getMessageRequestHandler(walletExt *rpcapi.Services, conn UserConn) { // read the request body, err := conn.ReadRequest() @@ -351,8 +351,15 @@ func getMessageRequestHandler(walletExt *rpcapi.Services, conn UserConn) { // get address from the request encryptionToken, ok := reqJSONMap[common.JSONKeyEncryptionToken] - if !ok || len(encryptionToken.(string)) != common.MessageUserIDLen { - handleError(conn, walletExt.Logger(), fmt.Errorf("unable to read encryptionToken field from the request or it is not of correct length")) + if !ok { + handleError(conn, walletExt.Logger(), fmt.Errorf("encryptionToken field not found in the request")) + return + } + if tokenStr, ok := encryptionToken.(string); !ok { + handleError(conn, walletExt.Logger(), fmt.Errorf("encryptionToken field is not a string")) + return + } else if len(tokenStr) != common.MessageUserIDLen { + handleError(conn, walletExt.Logger(), fmt.Errorf("encryptionToken field is not of correct length")) return }