diff --git a/js/http.go b/js/http.go index 615928cb..685f8ec0 100644 --- a/js/http.go +++ b/js/http.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -64,7 +63,7 @@ func (c httpPackage) Request(method string, uri string, } defer resp.Body.Close() - raw, err := ioutil.ReadAll(resp.Body) + raw, err := io.ReadAll(resp.Body) if err != nil { return httpResponse{Error: err} } @@ -133,7 +132,7 @@ func httpRequest(call otto.FunctionCall) otto.Value { } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return ReportError("Could not read response: %s", err) } diff --git a/modules/api_rest/api_rest_controller.go b/modules/api_rest/api_rest_controller.go index af2c3b99..ccf25cd1 100644 --- a/modules/api_rest/api_rest_controller.go +++ b/modules/api_rest/api_rest_controller.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "os" "regexp" @@ -394,7 +393,7 @@ func (mod *RestAPI) readFile(fileName string, w http.ResponseWriter, r *http.Req } func (mod *RestAPI) writeFile(fileName string, w http.ResponseWriter, r *http.Request) { - data, err := ioutil.ReadAll(r.Body) + data, err := io.ReadAll(r.Body) if err != nil { msg := fmt.Sprintf("invalid file upload: %s", err) mod.Warning(msg) @@ -402,7 +401,7 @@ func (mod *RestAPI) writeFile(fileName string, w http.ResponseWriter, r *http.Re return } - err = ioutil.WriteFile(fileName, data, 0666) + err = os.WriteFile(fileName, data, 0666) if err != nil { msg := fmt.Sprintf("can't write to %s: %s", fileName, err) mod.Warning(msg) diff --git a/modules/http_proxy/http_proxy_base_filters.go b/modules/http_proxy/http_proxy_base_filters.go index 017fc0c3..988807f2 100644 --- a/modules/http_proxy/http_proxy_base_filters.go +++ b/modules/http_proxy/http_proxy_base_filters.go @@ -1,10 +1,10 @@ package http_proxy import ( - "io/ioutil" + "io" "net/http" - "strings" "strconv" + "strings" "github.com/elazarl/goproxy" @@ -74,10 +74,10 @@ func (p *HTTPProxy) isScriptInjectable(res *http.Response) (bool, string) { return false, "" } -func (p *HTTPProxy) doScriptInjection(res *http.Response, cType string) (error) { +func (p *HTTPProxy) doScriptInjection(res *http.Response, cType string) error { defer res.Body.Close() - raw, err := ioutil.ReadAll(res.Body) + raw, err := io.ReadAll(res.Body) if err != nil { return err } else if html := string(raw); strings.Contains(html, "") { @@ -91,7 +91,7 @@ func (p *HTTPProxy) doScriptInjection(res *http.Response, cType string) (error) res.Header.Set("Content-Length", strconv.Itoa(len(html))) // reset the response body to the original unread state - res.Body = ioutil.NopCloser(strings.NewReader(html)) + res.Body = io.NopCloser(strings.NewReader(html)) return nil } diff --git a/modules/http_proxy/http_proxy_base_sslstriper.go b/modules/http_proxy/http_proxy_base_sslstriper.go index d2fd0f4f..e3331b18 100644 --- a/modules/http_proxy/http_proxy_base_sslstriper.go +++ b/modules/http_proxy/http_proxy_base_sslstriper.go @@ -1,7 +1,7 @@ package http_proxy import ( - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -253,7 +253,7 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) { // if we have a text or html content type, fetch the body // and perform sslstripping if s.isContentStrippable(res) { - raw, err := ioutil.ReadAll(res.Body) + raw, err := io.ReadAll(res.Body) if err != nil { log.Error("Could not read response body: %s", err) return @@ -297,9 +297,9 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) { // reset the response body to the original unread state // but with just a string reader, this way further calls - // to ioutil.ReadAll(res.Body) will just return the content + // to ui.ReadAll(res.Body) will just return the content // we stripped without downloading anything again. - res.Body = ioutil.NopCloser(strings.NewReader(body)) + res.Body = io.NopCloser(strings.NewReader(body)) } // fix cookies domain + strip "secure" + "httponly" flags diff --git a/modules/http_proxy/http_proxy_js_request.go b/modules/http_proxy/http_proxy_js_request.go index 563c9b33..859526e4 100644 --- a/modules/http_proxy/http_proxy_js_request.go +++ b/modules/http_proxy/http_proxy_js_request.go @@ -3,7 +3,7 @@ package http_proxy import ( "bytes" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -201,7 +201,7 @@ func (j *JSRequest) RemoveHeader(name string) { } func (j *JSRequest) ReadBody() string { - raw, err := ioutil.ReadAll(j.req.Body) + raw, err := io.ReadAll(j.req.Body) if err != nil { return "" } @@ -209,7 +209,7 @@ func (j *JSRequest) ReadBody() string { j.Body = string(raw) j.bodyRead = true // reset the request body to the original unread state - j.req.Body = ioutil.NopCloser(bytes.NewBuffer(raw)) + j.req.Body = io.NopCloser(bytes.NewBuffer(raw)) return j.Body } diff --git a/modules/http_proxy/http_proxy_js_response.go b/modules/http_proxy/http_proxy_js_response.go index 0e46fa7f..c1bb98bf 100644 --- a/modules/http_proxy/http_proxy_js_response.go +++ b/modules/http_proxy/http_proxy_js_response.go @@ -3,7 +3,7 @@ package http_proxy import ( "bytes" "fmt" - "io/ioutil" + "io" "net/http" "strings" @@ -208,7 +208,7 @@ func (j *JSResponse) ToResponse(req *http.Request) (resp *http.Response) { func (j *JSResponse) ReadBody() string { defer j.resp.Body.Close() - raw, err := ioutil.ReadAll(j.resp.Body) + raw, err := io.ReadAll(j.resp.Body) if err != nil { return "" } @@ -217,7 +217,7 @@ func (j *JSResponse) ReadBody() string { j.bodyRead = true j.bodyClear = false // reset the response body to the original unread state - j.resp.Body = ioutil.NopCloser(bytes.NewBuffer(raw)) + j.resp.Body = io.NopCloser(bytes.NewBuffer(raw)) return j.Body } diff --git a/modules/net_sniff/net_sniff_http.go b/modules/net_sniff/net_sniff_http.go index a111c08b..23e0375c 100644 --- a/modules/net_sniff/net_sniff_http.go +++ b/modules/net_sniff/net_sniff_http.go @@ -4,7 +4,7 @@ import ( "bufio" "bytes" "compress/gzip" - "io/ioutil" + "io" "net" "net/http" "strings" @@ -50,7 +50,7 @@ func toSerializableRequest(req *http.Request) HTTPRequest { body := []byte(nil) ctype := "?" if req.Body != nil { - body, _ = ioutil.ReadAll(req.Body) + body, _ = io.ReadAll(req.Body) } for name, values := range req.Header { @@ -90,7 +90,7 @@ func toSerializableResponse(res *http.Response) HTTPResponse { } if res.Body != nil { - body, _ = ioutil.ReadAll(res.Body) + body, _ = io.ReadAll(res.Body) } // attempt decompression, but since this has been parsed by just