luraproject / lura

Unsafe defer of .Close method GO-S2307
Security
Major
6 months agoa year old
Deferring unsafe method "Close" on type "io.ReadCloser"
275		t.Error("Making the request:", err.Error())
276		return
277	}
278	defer resp.Body.Close()279	body, ioerr := io.ReadAll(resp.Body)
280	if ioerr != nil {
281		t.Error("Reading the response:", ioerr.Error())
Deferring unsafe method "Close" on type "io.ReadCloser"
106			t.Error("Making the request:", err.Error())
107			return
108		}
109		defer resp.Body.Close()110
111		body, ioerr := io.ReadAll(resp.Body)
112		if ioerr != nil {
Deferring unsafe method "Close" on type "io.ReadCloser"
 50			if req.Body == nil {
 51				return extractor.QueryFromBody(strings.NewReader(""))
 52			}
 53			defer req.Body.Close() 54			return extractor.QueryFromBody(req.Body)
 55		}
 56
Deferring unsafe method "Close" on type "io.ReadCloser"
 43			if req.Body == nil {
 44				return extractor.BodyFromBody(strings.NewReader(""))
 45			}
 46			defer req.Body.Close() 47			return extractor.BodyFromBody(req.Body)
 48		}
 49		generateQueryFn = func(req *Request) (url.Values, error) {
Deferring unsafe method "Close" on type "io.ReadCloser"
318		t.Error("Making the request:", err.Error())
319		return
320	}
321	defer resp.Body.Close()322	body, ioerr := io.ReadAll(resp.Body)
323	if ioerr != nil {
324		t.Error("Reading the response:", ioerr.Error())