Skip to content

Commit

Permalink
added in-workflow cookie reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzack9999 committed Jul 16, 2020
1 parent a256a56 commit 6671343
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions v2/internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net/http/cookiejar"
"os"
"strings"
"sync"
Expand Down Expand Up @@ -342,6 +343,14 @@ func (r *Runner) ProcessWorkflowWithList(workflow *workflows.Workflow) {
func (r *Runner) ProcessWorkflow(workflow *workflows.Workflow, URL string) error {
script := tengo.NewScript([]byte(workflow.Logic))
script.SetImports(stdlib.GetModuleMap(stdlib.AllModuleNames()...))
var jar *cookiejar.Jar
if workflow.CookieReuse {
var err error
jar, err = cookiejar.New(nil)
if err != nil {
return err
}
}
for name, value := range workflow.Variables {
var writer *bufio.Writer
if r.output != nil {
Expand Down Expand Up @@ -377,6 +386,7 @@ func (r *Runner) ProcessWorkflow(workflow *workflows.Workflow, URL string) error
ProxyURL: r.options.ProxyURL,
ProxySocksURL: r.options.ProxySocksURL,
CustomHeaders: r.options.CustomHeaders,
CookieJar: jar,
}
} else if len(t.RequestsDNS) > 0 {
template.DNSOptions = &executer.DNSOptions{
Expand Down Expand Up @@ -427,6 +437,7 @@ func (r *Runner) ProcessWorkflow(workflow *workflows.Workflow, URL string) error
ProxyURL: r.options.ProxyURL,
ProxySocksURL: r.options.ProxySocksURL,
CustomHeaders: r.options.CustomHeaders,
CookieJar: jar,
}
} else if len(t.RequestsDNS) > 0 {
template.DNSOptions = &executer.DNSOptions{
Expand Down
2 changes: 2 additions & 0 deletions v2/pkg/workflows/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type Workflow struct {
ID string `yaml:"id"`
// Info contains information about the template
Info Info `yaml:"info"`
// CookieReuse makes all cookies shared by templates within the workflow
CookieReuse bool `yaml:"cookie-reuse,omitempty"`
// Variables contains the variables accessible to the pseudo-code
Variables map[string]string `yaml:"variables"`
// Logic contains the workflow pseudo-code
Expand Down

0 comments on commit 6671343

Please sign in to comment.