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.
This commit is contained in:
Mehran Seifalinia 2025-04-21 16:18:14 +03:30 committed by GitHub
parent ffb0a92216
commit d0e289ea3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -65,7 +65,6 @@ func init() {
allTagsRegex = append(allTagsRegex, re) allTagsRegex = append(allTagsRegex, re)
} }
defaultOpts := types.DefaultOptions()
// need to set headless to true for headless templates // need to set headless to true for headless templates
defaultOpts.Headless = true defaultOpts.Headless = true
defaultOpts.EnableCodeTemplates = true defaultOpts.EnableCodeTemplates = true
@ -132,7 +131,7 @@ func main() {
} }
func process(opts options) error { func process(opts options) error {
tempDir, err := os.MkdirTemp("", "nuclei-nvd-%s") tempDir, err := os.MkdirTemp("", "nuclei-nvd")
if err != nil { if err != nil {
return err return err
} }