diff --git a/cmd/docgen/docgen.go b/cmd/docgen/docgen.go index 51c2a195d..ca075a19c 100644 --- a/cmd/docgen/docgen.go +++ b/cmd/docgen/docgen.go @@ -19,7 +19,9 @@ func writeToFile(filename string, data []byte) { if err != nil { log.Fatalf("Could not create file %s: %s\n", filename, err) } - defer file.Close() + defer func() { + _ = file.Close() + }() _, err = file.Write(data) if err != nil { diff --git a/cmd/functional-test/main.go b/cmd/functional-test/main.go index 8a5cebc59..8cf2db06a 100644 --- a/cmd/functional-test/main.go +++ b/cmd/functional-test/main.go @@ -41,7 +41,9 @@ func runFunctionalTests(debug bool) (error, bool) { if err != nil { return errors.Wrap(err, "could not open test cases"), true } - defer file.Close() + defer func() { + _ = file.Close() + }() errored, failedTestCases := runTestCases(file, debug) diff --git a/cmd/generate-checksum/main.go b/cmd/generate-checksum/main.go index a381387fa..9a3e7b8ed 100644 --- a/cmd/generate-checksum/main.go +++ b/cmd/generate-checksum/main.go @@ -23,7 +23,9 @@ func main() { if err != nil { log.Fatalf("Could not create file: %s\n", err) } - defer file.Close() + defer func() { + _ = file.Close() + }() err = filepath.WalkDir(templatesDirectory, func(path string, d fs.DirEntry, err error) error { if err != nil || d.IsDir() { diff --git a/cmd/integration-test/custom-dir.go b/cmd/integration-test/custom-dir.go index 550027f06..b1ea83cc6 100644 --- a/cmd/integration-test/custom-dir.go +++ b/cmd/integration-test/custom-dir.go @@ -18,7 +18,9 @@ func (h *customConfigDirTest) Execute(filePath string) error { if err != nil { return err } - defer os.RemoveAll(customTempDirectory) + defer func() { + _ = os.RemoveAll(customTempDirectory) + }() results, err := testutils.RunNucleiBareArgsAndGetResults(debug, []string{"NUCLEI_CONFIG_DIR=" + customTempDirectory}, "-t", filePath, "-u", "8x8exch02.8x8.com") if err != nil { return err diff --git a/cmd/integration-test/dsl.go b/cmd/integration-test/dsl.go index 4e4a275ef..c311b8292 100644 --- a/cmd/integration-test/dsl.go +++ b/cmd/integration-test/dsl.go @@ -21,7 +21,7 @@ type dslVersionWarning struct{} func (d *dslVersionWarning) Execute(templatePath string) error { router := httprouter.New() router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - fmt.Fprintf(w, "DSL version parsing warning test") + _, _ = fmt.Fprintf(w, "DSL version parsing warning test") }) ts := httptest.NewServer(router) defer ts.Close() @@ -37,7 +37,7 @@ type dslShowVersionWarning struct{} func (d *dslShowVersionWarning) Execute(templatePath string) error { router := httprouter.New() router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - fmt.Fprintf(w, "DSL version parsing warning test") + _, _ = fmt.Fprintf(w, "DSL version parsing warning test") }) ts := httptest.NewServer(router) defer ts.Close() diff --git a/cmd/integration-test/flow.go b/cmd/integration-test/flow.go index 46ae7cf5f..4c9be49b0 100644 --- a/cmd/integration-test/flow.go +++ b/cmd/integration-test/flow.go @@ -49,7 +49,7 @@ func (t *iterateValuesFlow) Execute(filePath string) error { } router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { w.WriteHeader(http.StatusOK) - _, _ = w.Write([]byte(fmt.Sprint(testemails))) + _, _ = fmt.Fprint(w, fmt.Sprint(testemails)) }) router.GET("/user/"+getBase64(testemails[0]), func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { w.WriteHeader(http.StatusOK) diff --git a/cmd/integration-test/fuzz.go b/cmd/integration-test/fuzz.go index 230fff031..c2c4bee3a 100644 --- a/cmd/integration-test/fuzz.go +++ b/cmd/integration-test/fuzz.go @@ -55,7 +55,7 @@ func (h *httpFuzzQuery) Execute(filePath string) error { router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { w.Header().Set("Content-Type", "text/html") value := r.URL.Query().Get("id") - fmt.Fprintf(w, "This is test matcher text: %v", value) + _, _ = fmt.Fprintf(w, "This is test matcher text: %v", value) }) ts := httptest.NewTLSServer(router) defer ts.Close() @@ -75,7 +75,7 @@ func (h *fuzzModeOverride) Execute(filePath string) error { router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { w.Header().Set("Content-Type", "text/html") value := r.URL.Query().Get("id") - fmt.Fprintf(w, "This is test matcher text: %v", value) + _, _ = fmt.Fprintf(w, "This is test matcher text: %v", value) }) ts := httptest.NewTLSServer(router) defer ts.Close() @@ -120,7 +120,7 @@ func (h *fuzzTypeOverride) Execute(filePath string) error { router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { w.Header().Set("Content-Type", "text/html") value := r.URL.Query().Get("id") - fmt.Fprintf(w, "This is test matcher text: %v", value) + _, _ = fmt.Fprintf(w, "This is test matcher text: %v", value) }) ts := httptest.NewTLSServer(router) defer ts.Close() @@ -164,7 +164,7 @@ func (h *HeadlessFuzzingQuery) Execute(filePath string) error { router := httprouter.New() router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { resp := fmt.Sprintf("
%s", r.URL.Query().Get("url")) - fmt.Fprint(w, resp) + _, _ = fmt.Fprint(w, resp) }) ts := httptest.NewTLSServer(router) defer ts.Close() @@ -190,7 +190,7 @@ func (h *fuzzMultipleMode) Execute(filePath string) error { } w.Header().Set("Content-Type", "text/html") resp := fmt.Sprintf("