mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 18:15:28 +00:00
Merge branch 'dev' into feature-cli-variables
This commit is contained in:
commit
08b467e3ca
@ -97,6 +97,7 @@ on extensive configurability, massive extensibility and ease of use.`)
|
|||||||
flagSet.StringVarP(&options.ResolversFile, "resolvers", "r", "", "file containing resolver list for nuclei"),
|
flagSet.StringVarP(&options.ResolversFile, "resolvers", "r", "", "file containing resolver list for nuclei"),
|
||||||
flagSet.BoolVar(&options.SystemResolvers, "system-resolvers", false, "use system DNS resolving as error fallback"),
|
flagSet.BoolVar(&options.SystemResolvers, "system-resolvers", false, "use system DNS resolving as error fallback"),
|
||||||
flagSet.BoolVar(&options.OfflineHTTP, "passive", false, "enable passive HTTP response processing mode"),
|
flagSet.BoolVar(&options.OfflineHTTP, "passive", false, "enable passive HTTP response processing mode"),
|
||||||
|
flagSet.BoolVar(&options.EnvironmentVariables, "env-vars", false, "Enable environment variables support"),
|
||||||
)
|
)
|
||||||
|
|
||||||
createGroup(flagSet, "interactsh", "interactsh",
|
createGroup(flagSet, "interactsh", "interactsh",
|
||||||
|
|||||||
28
v2/pkg/protocols/common/generators/env.go
Normal file
28
v2/pkg/protocols/common/generators/env.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package generators
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/projectdiscovery/stringsutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
var envVars map[string]interface{}
|
||||||
|
|
||||||
|
func parseEnvVars() map[string]interface{} {
|
||||||
|
sliceEnvVars := os.Environ()
|
||||||
|
parsedEnvVars := make(map[string]interface{}, len(sliceEnvVars))
|
||||||
|
for _, envVar := range sliceEnvVars {
|
||||||
|
key, val := stringsutil.Before(envVar, "="), stringsutil.After(envVar, "=")
|
||||||
|
parsedEnvVars[key] = val
|
||||||
|
}
|
||||||
|
return parsedEnvVars
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnvVars returns a map with all environment variables into a map
|
||||||
|
func EnvVars() map[string]interface{} {
|
||||||
|
if envVars == nil {
|
||||||
|
envVars = parseEnvVars()
|
||||||
|
}
|
||||||
|
|
||||||
|
return envVars
|
||||||
|
}
|
||||||
@ -67,6 +67,11 @@ func (r *requestGenerator) Make(baseURL string, dynamicValues map[string]interfa
|
|||||||
values = generators.MergeMaps(values, r.options.Options.Vars.AsMap())
|
values = generators.MergeMaps(values, r.options.Options.Vars.AsMap())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// merge with env vars
|
||||||
|
if r.options.Options.EnvironmentVariables {
|
||||||
|
values = generators.MergeMaps(values, generators.EnvVars())
|
||||||
|
}
|
||||||
|
|
||||||
// If data contains \n it's a raw request, process it like raw. Else
|
// If data contains \n it's a raw request, process it like raw. Else
|
||||||
// continue with the template based request flow.
|
// continue with the template based request flow.
|
||||||
if isRawRequest {
|
if isRawRequest {
|
||||||
|
|||||||
@ -145,4 +145,6 @@ type Options struct {
|
|||||||
UpdateNuclei bool
|
UpdateNuclei bool
|
||||||
// NoUpdateTemplates disables checking for nuclei templates updates
|
// NoUpdateTemplates disables checking for nuclei templates updates
|
||||||
NoUpdateTemplates bool
|
NoUpdateTemplates bool
|
||||||
|
// EnvironmentVariables enables support for environment variables
|
||||||
|
EnvironmentVariables bool
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user