From d0e289ea3dd2392e7e898e2aed77fe110e2001ad Mon Sep 17 00:00:00 2001 From: Mehran Seifalinia <70560051+Mehran-Seifalinia@users.noreply.github.com> Date: Mon, 21 Apr 2025 16:18:14 +0330 Subject: [PATCH] Fix incorrect usage of os.MkdirTemp pattern and redundant redefinition of defaultOpts (#6183) * Fix incorrect usage of os.MkdirTemp pattern - Replaced the incorrect pattern "nuclei-nvd-%s" with a correct one "nuclei-nvd" in the os.MkdirTemp function call. NOTE: The incorrect usage of %s in os.MkdirTemp caused it to be ignored, leading to potential issues with naming conventions for temporary directories and confusion in directory structure. The original function attempted to use string interpolation in a context where Go doesn't support it in os.MkdirTemp, which could result in unexpected behavior or errors when the directory name is processed. * Removed redundant redefinition of defaultOpts in init() - Redefining defaultOpts inside init() could lead to confusion, as it hides the global variable, causing the changes to be applied only within the init() scope and potentially causing unexpected behavior in other parts of the program. --- cmd/tmc/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/tmc/main.go b/cmd/tmc/main.go index e7f9477d7..521929c75 100644 --- a/cmd/tmc/main.go +++ b/cmd/tmc/main.go @@ -65,7 +65,6 @@ func init() { allTagsRegex = append(allTagsRegex, re) } - defaultOpts := types.DefaultOptions() // need to set headless to true for headless templates defaultOpts.Headless = true defaultOpts.EnableCodeTemplates = true @@ -132,7 +131,7 @@ func main() { } func process(opts options) error { - tempDir, err := os.MkdirTemp("", "nuclei-nvd-%s") + tempDir, err := os.MkdirTemp("", "nuclei-nvd") if err != nil { return err }