fix code rabbit

This commit is contained in:
Alban Stourbe 2025-06-24 18:45:35 +02:00
parent 1a9a7563c0
commit 99914e1a32

View File

@ -582,7 +582,7 @@ Additional documentation is available at: https://docs.nuclei.sh/getting-started
} }
if !options.Vars.IsEmpty() { if !options.Vars.IsEmpty() {
// Maybe we should add vars to the config file as well? // Maybe we should add vars to the config file as well even if they are set via flags?
file, err := os.Open(cfgFile) file, err := os.Open(cfgFile)
if err != nil { if err != nil {
gologger.Fatal().Msgf("Could not open config file: %s\n", err) gologger.Fatal().Msgf("Could not open config file: %s\n", err)
@ -596,15 +596,17 @@ Additional documentation is available at: https://docs.nuclei.sh/getting-started
variables := data["var"] variables := data["var"]
if variables != nil { if variables != nil {
for _, value := range variables.([]interface{}) { if varSlice, ok := variables.([]interface{}); ok {
if strVal, ok := value.(string); ok { for _, value := range varSlice {
options.Vars.Set(strVal) if strVal, ok := value.(string); ok {
} else { options.Vars.Set(strVal)
gologger.Warning().Msgf("Skipping non-string variable in config: %#v", value) } else {
gologger.Warning().Msgf("Skipping non-string variable in config: %#v", value)
}
} }
} else {
gologger.Warning().Msgf("No 'var' section found in config file: %s", cfgFile)
} }
} else {
gologger.Warning().Msgf("No 'var' section found in config file: %s", cfgFile)
} }
} }