mirror of https://github.com/daffainfo/nuclei.git
[feature] Add coloring to debug information #999
* extracted common MakeResultEvent logic and added the MakeResultEventItem method to the Request interfacedev
parent
76e952ebd2
commit
b5c161d267
|
@ -17,7 +17,7 @@ func CreateEventWithAdditionalOptions(request protocols.Request, outputEvent out
|
||||||
if ok && result != nil {
|
if ok && result != nil {
|
||||||
event.OperatorsResult = result
|
event.OperatorsResult = result
|
||||||
addAdditionalOptions(event)
|
addAdditionalOptions(event)
|
||||||
event.Results = request.MakeResultEvent(event)
|
event.Results = append(event.Results, request.MakeResultEvent(event)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||||
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -115,33 +116,10 @@ func (request *Request) responseToDSLMap(req, resp *dns.Msg, host, matched strin
|
||||||
|
|
||||||
// MakeResultEvent creates a result event from internal wrapped event
|
// MakeResultEvent creates a result event from internal wrapped event
|
||||||
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
||||||
if len(wrapped.OperatorsResult.DynamicValues) > 0 {
|
return protocols.MakeDefaultResultEvent(request, wrapped)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
results := make([]*output.ResultEvent, 0, len(wrapped.OperatorsResult.Matches)+1)
|
|
||||||
|
|
||||||
// If we have multiple matchers with names, write each of them separately.
|
|
||||||
if len(wrapped.OperatorsResult.Matches) > 0 {
|
|
||||||
for k := range wrapped.OperatorsResult.Matches {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.MatcherName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else if len(wrapped.OperatorsResult.Extracts) > 0 {
|
|
||||||
for k, v := range wrapped.OperatorsResult.Extracts {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.ExtractedResults = v
|
|
||||||
data.ExtractorName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) makeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
||||||
data := &output.ResultEvent{
|
data := &output.ResultEvent{
|
||||||
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
||||||
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||||
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,33 +82,13 @@ func (request *Request) responseToDSLMap(raw, host, matched string) output.Inter
|
||||||
|
|
||||||
// MakeResultEvent creates a result event from internal wrapped event
|
// MakeResultEvent creates a result event from internal wrapped event
|
||||||
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
||||||
if len(wrapped.OperatorsResult.DynamicValues) > 0 {
|
results := protocols.MakeDefaultResultEvent(request, wrapped)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
results := make([]*output.ResultEvent, 0, len(wrapped.OperatorsResult.Matches)+1)
|
|
||||||
|
|
||||||
// If we have multiple matchers with names, write each of them separately.
|
|
||||||
if len(wrapped.OperatorsResult.Matches) > 0 {
|
|
||||||
for k := range wrapped.OperatorsResult.Matches {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.MatcherName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else if len(wrapped.OperatorsResult.Extracts) > 0 {
|
|
||||||
for k, v := range wrapped.OperatorsResult.Extracts {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.ExtractedResults = v
|
|
||||||
data.ExtractorName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
raw, ok := wrapped.InternalEvent["raw"]
|
raw, ok := wrapped.InternalEvent["raw"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
rawStr, ok := raw.(string)
|
rawStr, ok := raw.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return results
|
return results
|
||||||
|
@ -138,7 +119,7 @@ func (request *Request) GetCompiledOperators() []*operators.Operators {
|
||||||
return []*operators.Operators{request.CompiledOperators}
|
return []*operators.Operators{request.CompiledOperators}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) makeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
||||||
data := &output.ResultEvent{
|
data := &output.ResultEvent{
|
||||||
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
||||||
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
||||||
|
@ -146,7 +127,7 @@ func (request *Request) makeResultEventItem(wrapped *output.InternalWrappedEvent
|
||||||
Type: "file",
|
Type: "file",
|
||||||
Path: types.ToString(wrapped.InternalEvent["path"]),
|
Path: types.ToString(wrapped.InternalEvent["path"]),
|
||||||
Matched: types.ToString(wrapped.InternalEvent["matched"]),
|
Matched: types.ToString(wrapped.InternalEvent["matched"]),
|
||||||
Host: types.ToString(wrapped.InternalEvent["matched"]),
|
Host: types.ToString(wrapped.InternalEvent["host"]),
|
||||||
ExtractedResults: wrapped.OperatorsResult.OutputExtracts,
|
ExtractedResults: wrapped.OperatorsResult.OutputExtracts,
|
||||||
Response: types.ToString(wrapped.InternalEvent["raw"]),
|
Response: types.ToString(wrapped.InternalEvent["raw"]),
|
||||||
Timestamp: time.Now(),
|
Timestamp: time.Now(),
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||||
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,37 +81,14 @@ func (request *Request) responseToDSLMap(resp, req, host, matched string) output
|
||||||
|
|
||||||
// MakeResultEvent creates a result event from internal wrapped event
|
// MakeResultEvent creates a result event from internal wrapped event
|
||||||
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
||||||
if len(wrapped.OperatorsResult.DynamicValues) > 0 {
|
return protocols.MakeDefaultResultEvent(request, wrapped)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
results := make([]*output.ResultEvent, 0, len(wrapped.OperatorsResult.Matches)+1)
|
|
||||||
|
|
||||||
// If we have multiple matchers with names, write each of them separately.
|
|
||||||
if len(wrapped.OperatorsResult.Matches) > 0 {
|
|
||||||
for k := range wrapped.OperatorsResult.Matches {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.MatcherName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else if len(wrapped.OperatorsResult.Extracts) > 0 {
|
|
||||||
for k, v := range wrapped.OperatorsResult.Extracts {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.ExtractedResults = v
|
|
||||||
data.ExtractorName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) GetCompiledOperators() []*operators.Operators {
|
func (request *Request) GetCompiledOperators() []*operators.Operators {
|
||||||
return []*operators.Operators{request.CompiledOperators}
|
return []*operators.Operators{request.CompiledOperators}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) makeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
||||||
data := &output.ResultEvent{
|
data := &output.ResultEvent{
|
||||||
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
||||||
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||||
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/helpers/responsehighlighter"
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/helpers/responsehighlighter"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||||
)
|
)
|
||||||
|
@ -125,38 +126,14 @@ func (request *Request) responseToDSLMap(resp *http.Response, host, matched, raw
|
||||||
|
|
||||||
// MakeResultEvent creates a result event from internal wrapped event
|
// MakeResultEvent creates a result event from internal wrapped event
|
||||||
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
||||||
if len(wrapped.OperatorsResult.DynamicValues) > 0 && !wrapped.OperatorsResult.Matched {
|
return protocols.MakeDefaultResultEvent(request, wrapped)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
results := make([]*output.ResultEvent, 0, len(wrapped.OperatorsResult.Matches)+1)
|
|
||||||
|
|
||||||
// If we have multiple matchers with names, write each of them separately.
|
|
||||||
if len(wrapped.OperatorsResult.Matches) > 0 {
|
|
||||||
for k := range wrapped.OperatorsResult.Matches {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.MatcherName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else if len(wrapped.OperatorsResult.Extracts) > 0 {
|
|
||||||
for k, v := range wrapped.OperatorsResult.Extracts {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.ExtractedResults = v
|
|
||||||
data.ExtractorName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) GetCompiledOperators() []*operators.Operators {
|
func (request *Request) GetCompiledOperators() []*operators.Operators {
|
||||||
return []*operators.Operators{request.CompiledOperators}
|
return []*operators.Operators{request.CompiledOperators}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) makeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
||||||
data := &output.ResultEvent{
|
data := &output.ResultEvent{
|
||||||
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
||||||
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||||
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,37 +82,14 @@ func (request *Request) responseToDSLMap(req, resp, raw, host, matched string) o
|
||||||
|
|
||||||
// MakeResultEvent creates a result event from internal wrapped event
|
// MakeResultEvent creates a result event from internal wrapped event
|
||||||
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
||||||
if len(wrapped.OperatorsResult.DynamicValues) > 0 {
|
return protocols.MakeDefaultResultEvent(request, wrapped)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
results := make([]*output.ResultEvent, 0, len(wrapped.OperatorsResult.Matches)+1)
|
|
||||||
|
|
||||||
// If we have multiple matchers with names, write each of them separately.
|
|
||||||
if len(wrapped.OperatorsResult.Matches) > 0 {
|
|
||||||
for k := range wrapped.OperatorsResult.Matches {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.MatcherName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else if len(wrapped.OperatorsResult.Extracts) > 0 {
|
|
||||||
for k, v := range wrapped.OperatorsResult.Extracts {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.ExtractedResults = v
|
|
||||||
data.ExtractorName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) GetCompiledOperators() []*operators.Operators {
|
func (request *Request) GetCompiledOperators() []*operators.Operators {
|
||||||
return []*operators.Operators{request.CompiledOperators}
|
return []*operators.Operators{request.CompiledOperators}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) makeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
||||||
data := &output.ResultEvent{
|
data := &output.ResultEvent{
|
||||||
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
||||||
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||||
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/helpers/responsehighlighter"
|
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/helpers/responsehighlighter"
|
||||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||||
)
|
)
|
||||||
|
@ -122,37 +123,14 @@ func (request *Request) responseToDSLMap(resp *http.Response, host, matched, raw
|
||||||
|
|
||||||
// MakeResultEvent creates a result event from internal wrapped event
|
// MakeResultEvent creates a result event from internal wrapped event
|
||||||
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
func (request *Request) MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
||||||
if len(wrapped.OperatorsResult.DynamicValues) > 0 {
|
return protocols.MakeDefaultResultEvent(request, wrapped)
|
||||||
return nil
|
|
||||||
}
|
|
||||||
results := make([]*output.ResultEvent, 0, len(wrapped.OperatorsResult.Matches)+1)
|
|
||||||
|
|
||||||
// If we have multiple matchers with names, write each of them separately.
|
|
||||||
if len(wrapped.OperatorsResult.Matches) > 0 {
|
|
||||||
for k := range wrapped.OperatorsResult.Matches {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.MatcherName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else if len(wrapped.OperatorsResult.Extracts) > 0 {
|
|
||||||
for k, v := range wrapped.OperatorsResult.Extracts {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
data.ExtractedResults = v
|
|
||||||
data.ExtractorName = k
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
data := request.makeResultEventItem(wrapped)
|
|
||||||
results = append(results, data)
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) GetCompiledOperators() []*operators.Operators {
|
func (request *Request) GetCompiledOperators() []*operators.Operators {
|
||||||
return request.compiledOperators
|
return request.compiledOperators
|
||||||
}
|
}
|
||||||
|
|
||||||
func (request *Request) makeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
func (request *Request) MakeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent {
|
||||||
data := &output.ResultEvent{
|
data := &output.ResultEvent{
|
||||||
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
TemplateID: types.ToString(wrapped.InternalEvent["template-id"]),
|
||||||
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
TemplatePath: types.ToString(wrapped.InternalEvent["template-path"]),
|
||||||
|
|
|
@ -82,7 +82,9 @@ type Request interface {
|
||||||
Extract(data map[string]interface{}, matcher *extractors.Extractor) map[string]struct{}
|
Extract(data map[string]interface{}, matcher *extractors.Extractor) map[string]struct{}
|
||||||
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
|
// ExecuteWithResults executes the protocol requests and returns results instead of writing them.
|
||||||
ExecuteWithResults(input string, dynamicValues, previous output.InternalEvent, callback OutputEventCallback) error
|
ExecuteWithResults(input string, dynamicValues, previous output.InternalEvent, callback OutputEventCallback) error
|
||||||
// MakeResultEvent creates a result event from internal wrapped event
|
// MakeResultEventItem creates a result event from internal wrapped event. Intended to be used by MakeResultEventItem internally
|
||||||
|
MakeResultEventItem(wrapped *output.InternalWrappedEvent) *output.ResultEvent
|
||||||
|
// MakeResultEvent creates a flat list of result events from an internal wrapped event, based on successful matchers and extracted data
|
||||||
MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent
|
MakeResultEvent(wrapped *output.InternalWrappedEvent) []*output.ResultEvent
|
||||||
// GetCompiledOperators returns a list of the compiled operators
|
// GetCompiledOperators returns a list of the compiled operators
|
||||||
GetCompiledOperators() []*operators.Operators
|
GetCompiledOperators() []*operators.Operators
|
||||||
|
@ -90,3 +92,31 @@ type Request interface {
|
||||||
|
|
||||||
// OutputEventCallback is a callback event for any results found during scanning.
|
// OutputEventCallback is a callback event for any results found during scanning.
|
||||||
type OutputEventCallback func(result *output.InternalWrappedEvent)
|
type OutputEventCallback func(result *output.InternalWrappedEvent)
|
||||||
|
|
||||||
|
func MakeDefaultResultEvent(request Request, wrapped *output.InternalWrappedEvent) []*output.ResultEvent {
|
||||||
|
if len(wrapped.OperatorsResult.DynamicValues) > 0 && !wrapped.OperatorsResult.Matched {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
results := make([]*output.ResultEvent, 0, len(wrapped.OperatorsResult.Matches)+1)
|
||||||
|
|
||||||
|
// If we have multiple matchers with names, write each of them separately.
|
||||||
|
if len(wrapped.OperatorsResult.Matches) > 0 {
|
||||||
|
for matcherNames := range wrapped.OperatorsResult.Matches {
|
||||||
|
data := request.MakeResultEventItem(wrapped)
|
||||||
|
data.MatcherName = matcherNames
|
||||||
|
results = append(results, data)
|
||||||
|
}
|
||||||
|
} else if len(wrapped.OperatorsResult.Extracts) > 0 {
|
||||||
|
for k, v := range wrapped.OperatorsResult.Extracts {
|
||||||
|
data := request.MakeResultEventItem(wrapped)
|
||||||
|
data.ExtractorName = k
|
||||||
|
data.ExtractedResults = v
|
||||||
|
results = append(results, data)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data := request.MakeResultEventItem(wrapped)
|
||||||
|
results = append(results, data)
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue