From cb58258bd7a43ba0c89b4b1265f17100c1161589 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Mon, 5 Mar 2018 16:14:26 +0100 Subject: [PATCH] refact: returning pointers for both js request and js response --- modules/http_proxy_js_request.go | 4 ++-- modules/http_proxy_script.go | 2 +- session/session_core_handlers.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/http_proxy_js_request.go b/modules/http_proxy_js_request.go index 17741d3f..6b98fa17 100644 --- a/modules/http_proxy_js_request.go +++ b/modules/http_proxy_js_request.go @@ -27,7 +27,7 @@ type JSRequest struct { req *http.Request } -func NewJSRequest(req *http.Request) JSRequest { +func NewJSRequest(req *http.Request) *JSRequest { headers := make([]JSHeader, 0) cType := "" @@ -41,7 +41,7 @@ func NewJSRequest(req *http.Request) JSRequest { } } - return JSRequest{ + return &JSRequest{ Client: strings.Split(req.RemoteAddr, ":")[0], Method: req.Method, Version: fmt.Sprintf("%d.%d", req.ProtoMajor, req.ProtoMinor), diff --git a/modules/http_proxy_script.go b/modules/http_proxy_script.go index 7342a3da..ec29620d 100644 --- a/modules/http_proxy_script.go +++ b/modules/http_proxy_script.go @@ -63,7 +63,7 @@ func LoadHttpProxyScript(path string, sess *session.Session) (err error, s *Http func (s *HttpProxyScript) doRequestDefines(req *http.Request) (err error, jsres *JSResponse) { // convert request and define empty response to be optionally filled jsreq := NewJSRequest(req) - if err = s.VM.Set("req", &jsreq); err != nil { + if err = s.VM.Set("req", jsreq); err != nil { log.Error("Error while defining request: %s", err) return } diff --git a/session/session_core_handlers.go b/session/session_core_handlers.go index 3cd5ecd5..ada1ed30 100644 --- a/session/session_core_handlers.go +++ b/session/session_core_handlers.go @@ -153,11 +153,11 @@ func (s *Session) sleepHandler(args []string, sess *Session) error { func (s *Session) getHandler(args []string, sess *Session) error { key := args[0] - if strings.Contains(key, "*") { + if strings.Contains(key, "*") { prev_ns := "" fmt.Println() - last := len(key) - 1 + last := len(key) - 1 prefix := key[:last] for _, k := range s.Env.Sorted() { if strings.HasPrefix(k, prefix) {