Fixed some bugs introduced from merge

This commit is contained in:
Ice3man543 2021-02-08 02:07:19 +05:30
parent 2cc6b2283e
commit 99e8fe1601
8 changed files with 35 additions and 29 deletions

View File

@ -233,12 +233,13 @@ func (r *Runner) RunEnumeration() {
for _, cluster := range clusters { for _, cluster := range clusters {
if len(cluster) > 1 && !r.options.OfflineHTTP { if len(cluster) > 1 && !r.options.OfflineHTTP {
executerOpts := protocols.ExecuterOptions{ executerOpts := protocols.ExecuterOptions{
Output: r.output, Output: r.output,
Options: r.options, Options: r.options,
Progress: r.progress, Progress: r.progress,
Catalogue: r.catalogue, Catalogue: r.catalogue,
RateLimiter: r.ratelimiter, RateLimiter: r.ratelimiter,
ProjectFile: r.projectFile, IssuesClient: r.issuesClient,
ProjectFile: r.projectFile,
} }
clusterID := fmt.Sprintf("cluster-%s", xid.New().String()) clusterID := fmt.Sprintf("cluster-%s", xid.New().String())

View File

@ -44,12 +44,13 @@ func (r *Runner) getParsedTemplatesFor(templatePaths []string, severities []stri
// parseTemplateFile returns the parsed template file // parseTemplateFile returns the parsed template file
func (r *Runner) parseTemplateFile(file string) (*templates.Template, error) { func (r *Runner) parseTemplateFile(file string) (*templates.Template, error) {
executerOpts := protocols.ExecuterOptions{ executerOpts := protocols.ExecuterOptions{
Output: r.output, Output: r.output,
Options: r.options, Options: r.options,
Progress: r.progress, Progress: r.progress,
Catalogue: r.catalogue, Catalogue: r.catalogue,
RateLimiter: r.ratelimiter, IssuesClient: r.issuesClient,
ProjectFile: r.projectFile, RateLimiter: r.ratelimiter,
ProjectFile: r.projectFile,
} }
template, err := templates.Parse(file, executerOpts) template, err := templates.Parse(file, executerOpts)
if err != nil { if err != nil {

View File

@ -111,6 +111,7 @@ func NewMockExecuterOptions(options *types.Options, info *TemplateInfo) *protoco
Options: options, Options: options,
Progress: progress, Progress: progress,
ProjectFile: nil, ProjectFile: nil,
IssuesClient: nil,
Catalogue: catalogue.New(options.TemplatesDirectory), Catalogue: catalogue.New(options.TemplatesDirectory),
RateLimiter: ratelimit.New(options.RateLimit), RateLimiter: ratelimit.New(options.RateLimit),
} }

View File

@ -24,12 +24,13 @@ func TestHTTPRequestsCluster(t *testing.T) {
list := make(map[string]*templates.Template) list := make(map[string]*templates.Template)
for _, template := range templatesList { for _, template := range templatesList {
executerOpts := protocols.ExecuterOptions{ executerOpts := protocols.ExecuterOptions{
Output: &mockOutput{}, Output: &mockOutput{},
Options: &types.Options{}, Options: &types.Options{},
Progress: nil, Progress: nil,
Catalogue: catalogue, Catalogue: catalogue,
RateLimiter: nil, RateLimiter: nil,
ProjectFile: nil, IssuesClient: nil,
ProjectFile: nil,
} }
t, err := templates.Parse(template, executerOpts) t, err := templates.Parse(template, executerOpts)
if err != nil { if err != nil {

View File

@ -146,7 +146,7 @@ func (r *Request) makeResultEventItem(wrapped *output.InternalWrappedEvent) *out
} }
if r.options.Options.JSONRequests { if r.options.Options.JSONRequests {
data.Request = types.ToString(wrapped.InternalEvent["request"]) data.Request = types.ToString(wrapped.InternalEvent["request"])
data.Response = types.ToString(wrapped.InternalEvent["raw"]) data.Response = types.ToString(wrapped.InternalEvent["response"])
} }
return data return data
} }

View File

@ -17,9 +17,9 @@ func Summary(output *output.ResultEvent) string {
builder.WriteString("[") builder.WriteString("[")
builder.WriteString(template) builder.WriteString(template)
builder.WriteString("] [") builder.WriteString("] [")
builder.WriteString(output.Info["severity"]) builder.WriteString(types.ToString(output.Info["severity"]))
builder.WriteString("] ") builder.WriteString("] ")
builder.WriteString(output.Info["name"]) builder.WriteString(types.ToString(output.Info["name"]))
builder.WriteString(" found on ") builder.WriteString(" found on ")
builder.WriteString(output.Host) builder.WriteString(output.Host)
data := builder.String() data := builder.String()

View File

@ -10,6 +10,7 @@ import (
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/issues/github" "github.com/projectdiscovery/nuclei/v2/pkg/reporting/issues/github"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/issues/gitlab" "github.com/projectdiscovery/nuclei/v2/pkg/reporting/issues/gitlab"
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/issues/jira" "github.com/projectdiscovery/nuclei/v2/pkg/reporting/issues/jira"
"github.com/projectdiscovery/nuclei/v2/pkg/types"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
@ -50,7 +51,7 @@ func (f *Filter) Compile() {
// GetMatch returns true if a filter matches result event // GetMatch returns true if a filter matches result event
func (f *Filter) GetMatch(event *output.ResultEvent) bool { func (f *Filter) GetMatch(event *output.ResultEvent) bool {
severity := event.Info["severity"] severity := types.ToString(event.Info["severity"])
if len(f.severity) > 0 { if len(f.severity) > 0 {
if stringSliceContains(f.severity, severity) { if stringSliceContains(f.severity, severity) {
return true return true
@ -59,7 +60,7 @@ func (f *Filter) GetMatch(event *output.ResultEvent) bool {
} }
tags := event.Info["tags"] tags := event.Info["tags"]
tagParts := strings.Split(tags, ",") tagParts := strings.Split(types.ToString(tags), ",")
for i, tag := range tagParts { for i, tag := range tagParts {
tagParts[i] = strings.TrimSpace(tag) tagParts[i] = strings.TrimSpace(tag)
} }

View File

@ -152,12 +152,13 @@ func (t *Template) parseWorkflowTemplate(workflow *workflows.WorkflowTemplate, o
} }
for _, path := range paths { for _, path := range paths {
opts := protocols.ExecuterOptions{ opts := protocols.ExecuterOptions{
Output: options.Output, Output: options.Output,
Options: options.Options, Options: options.Options,
Progress: options.Progress, Progress: options.Progress,
Catalogue: options.Catalogue, Catalogue: options.Catalogue,
RateLimiter: options.RateLimiter, RateLimiter: options.RateLimiter,
ProjectFile: options.ProjectFile, IssuesClient: options.IssuesClient,
ProjectFile: options.ProjectFile,
} }
template, err := Parse(path, opts) template, err := Parse(path, opts)
if err != nil { if err != nil {