File tree Expand file tree Collapse file tree 5 files changed +36
-17
lines changed
Expand file tree Collapse file tree 5 files changed +36
-17
lines changed Original file line number Diff line number Diff line change @@ -75,10 +75,10 @@ func ExtensionRunner(c *fiber.Ctx) error {
7575
7676 output := linux .Execute (command )
7777
78- if helpers .LimanJSON (output ) {
78+ if helpers .IsJSON (output ) {
7979 type LimanMessage struct {
80- Message string `json:"message"`
81- Status int `json:"status"`
80+ Message any `json:"message"`
81+ Status int `json:"status"`
8282 }
8383 msg := & LimanMessage {}
8484
@@ -87,9 +87,15 @@ func ExtensionRunner(c *fiber.Ctx) error {
8787 return c .Type ("json" ).SendString (output )
8888 }
8989
90- if msg != nil && msg .Status > 200 {
90+ if msg != nil && msg .Status > 399 {
9191 return c .Status (201 ).Type ("json" ).SendString (output )
9292 }
93+
94+ if msg != nil {
95+ return c .Status (msg .Status ).Type ("json" ).SendString (output )
96+ }
97+
98+ return c .Type ("json" ).SendString (output )
9399 }
94100
95101 return c .SendString (output )
Original file line number Diff line number Diff line change @@ -78,10 +78,10 @@ func ExternalAPI(c *fiber.Ctx) error {
7878 }
7979
8080 output := linux .Execute (command )
81- if helpers .LimanJSON (output ) {
81+ if helpers .IsJSON (output ) {
8282 type LimanMessage struct {
83- Message string `json:"message"`
84- Status int `json:"status"`
83+ Message any `json:"message"`
84+ Status int `json:"status"`
8585 }
8686 msg := & LimanMessage {}
8787
@@ -90,9 +90,15 @@ func ExternalAPI(c *fiber.Ctx) error {
9090 return c .Type ("json" ).SendString (output )
9191 }
9292
93- if msg != nil && msg .Status > 200 {
93+ if msg != nil && msg .Status > 399 {
9494 return c .Status (201 ).Type ("json" ).SendString (output )
9595 }
96+
97+ if msg != nil {
98+ return c .Status (msg .Status ).Type ("json" ).SendString (output )
99+ }
100+
101+ return c .Type ("json" ).SendString (output )
96102 }
97103
98104 return c .SendString (output )
Original file line number Diff line number Diff line change 11package app_logger
22
33import (
4+ "strings"
5+
46 "github.com/gofiber/fiber/v2"
57 "github.com/google/uuid"
68 "github.com/limanmys/render-engine/pkg/helpers"
@@ -40,6 +42,12 @@ func New() fiber.Handler {
4042
4143 formData := helpers .GetFormData (c )
4244
45+ for k := range formData {
46+ if strings .Contains (strings .ToLower (k ), "password" ) || strings .Contains (strings .ToLower (k ), "token" ) {
47+ formData [k ] = ""
48+ }
49+ }
50+
4351 user_id := ""
4452 if c .Locals ("user_id" ) != nil {
4553 user_id = c .Locals ("user_id" ).(string )
Original file line number Diff line number Diff line change 11package server
22
33import (
4+ "strings"
5+
46 "github.com/gofiber/fiber/v2"
57 "github.com/limanmys/render-engine/pkg/helpers"
68 "github.com/limanmys/render-engine/pkg/logger"
@@ -23,6 +25,12 @@ var ErrorHandler = func(c *fiber.Ctx, err error) error {
2325 if code >= fiber .StatusInternalServerError {
2426 request := helpers .GetFormData (c )
2527
28+ for k := range request {
29+ if strings .Contains (strings .ToLower (k ), "password" ) || strings .Contains (strings .ToLower (k ), "token" ) {
30+ request [k ] = ""
31+ }
32+ }
33+
2634 logger .Sugar ().WithOptions (zap .WithCaller (false )).Errorw (
2735 "recover middleware catch" ,
2836 "status" , code ,
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package helpers
22
33import (
44 "net/url"
5- "strings"
65
76 "github.com/gofiber/fiber/v2"
87)
@@ -22,10 +21,6 @@ func GetFormData(c *fiber.Ctx) map[string]string {
2221 continue
2322 }
2423
25- if strings .Contains (strings .ToLower (key ), "password" ) || strings .Contains (strings .ToLower (key ), "token" ) {
26- continue
27- }
28-
2924 if len (value ) > 0 {
3025 formValues [key ] = value [0 ]
3126 }
@@ -42,10 +37,6 @@ func BodyParser(body []byte) map[string]string {
4237
4338 obj := map [string ]string {}
4439 for k , v := range values {
45- if strings .Contains (strings .ToLower (k ), "password" ) || strings .Contains (strings .ToLower (k ), "token" ) {
46- continue
47- }
48-
4940 if len (v ) > 0 {
5041 obj [k ] = v [0 ]
5142 }
You can’t perform that action at this time.
0 commit comments