Skip to content

Commit 52bade5

Browse files
Merge pull request #6776 from projectdiscovery/fix/tcp-inputs-variable-resolution
fix(network): pass template variables to tcp inputs pre-compilation
2 parents ee8287a + 6a509fa commit 52bade5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/protocols/network/network.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,20 @@ func (request *Request) Compile(options *protocols.ExecutorOptions) error {
179179
request.addresses = append(request.addresses, addressKV{address: address, tls: shouldUseTLS})
180180
}
181181
// Pre-compile any input dsl functions before executing the request.
182+
// Build a map with template variables and -var flag values for pre-compilation
183+
preCompileVars := request.options.Variables.GetAll()
184+
// Merge in -var flag values
185+
if request.options.Options != nil {
186+
generators.MergeMapsInto(preCompileVars, request.options.Options.Vars.AsMap())
187+
}
188+
// Also merge in constants
189+
generators.MergeMapsInto(preCompileVars, request.options.Constants)
190+
182191
for _, input := range request.Inputs {
183192
if input.Type.String() != "" {
184193
continue
185194
}
186-
if compiled, evalErr := expressions.Evaluate(input.Data, map[string]interface{}{}); evalErr == nil {
195+
if compiled, evalErr := expressions.Evaluate(input.Data, preCompileVars); evalErr == nil {
187196
input.Data = compiled
188197
}
189198
}

0 commit comments

Comments
 (0)