mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 21:55:26 +00:00
YAML Unmarshal error in reporting template #995
This commit is contained in:
parent
5e50d469e7
commit
16a54e3b98
68
integration_tests/test-issue-tracker-config1.yaml
Normal file
68
integration_tests/test-issue-tracker-config1.yaml
Normal file
@ -0,0 +1,68 @@
|
||||
allow-list:
|
||||
severity: high, critical
|
||||
deny-list:
|
||||
severity: low
|
||||
|
||||
# github contains configuration options for github issue tracker
|
||||
#github:
|
||||
# # base-url is the optional self-hosted github application url
|
||||
# base-url: ""
|
||||
# # username is the username of the github user
|
||||
# username: ""
|
||||
# # owner is the owner name of the repository for issues.
|
||||
# owner: ""
|
||||
# # token is the token for github account.
|
||||
# token: ""
|
||||
# # project-name is the name of the repository.
|
||||
# project-name: ""
|
||||
# # issue-label is the label of the created issue type
|
||||
# issue-label: ""
|
||||
|
||||
# gitlab contains configuration options for gitlab issue tracker
|
||||
#gitlab:
|
||||
# # base-url is the optional self-hosted gitlab application url
|
||||
# base-url: ""
|
||||
# # username is the username of the gitlab user
|
||||
# username: ""
|
||||
# # token is the token for gitlab account.
|
||||
# token: ""
|
||||
# # project-id is the ID of the repository.
|
||||
# project-id: ""
|
||||
# # issue-label is the label of the created issue type
|
||||
# issue-label: ""
|
||||
|
||||
# jira contains configuration options for jira issue tracker
|
||||
#jira:
|
||||
# # cloud is the boolean which tells if Jira instance is running in the cloud or on-prem version is used
|
||||
# cloud: true
|
||||
# # update-existing is the boolean which tells if the existing, opened issue should be updated or new one should be created
|
||||
# update-existing: false
|
||||
# # URL is the jira application url
|
||||
# url: ""
|
||||
# # account-id is the account-id of the jira user or username in case of on-prem Jira
|
||||
# account-id: ""
|
||||
# # email is the email of the user for jira instance
|
||||
# email: ""
|
||||
# # token is the token for jira instance or password in case of on-prem Jira
|
||||
# token: ""
|
||||
# # project-name is the name of the project.
|
||||
# project-name: ""
|
||||
# # issue-type is the name of the created issue type
|
||||
# issue-type: ""
|
||||
|
||||
# elasticsearch contains configuration options for elasticsearch exporter
|
||||
#elasticsearch:
|
||||
# # IP for elasticsearch instance
|
||||
# ip: 127.0.0.1
|
||||
# # Port is the port of elasticsearch instance
|
||||
# port: 9200
|
||||
# # IndexName is the name of the elasticsearch index
|
||||
# index-name: nuclei
|
||||
# # SSL enables ssl for elasticsearch connection
|
||||
# # ssl: false
|
||||
# # SSLVerification disables SSL verification for elasticsearch
|
||||
# # ssl-verification: false
|
||||
# # Username for the elasticsearch instance
|
||||
# # username: test
|
||||
# # Pasword is the password for elasticsearch instance
|
||||
# # password: test
|
||||
70
integration_tests/test-issue-tracker-config2.yaml
Normal file
70
integration_tests/test-issue-tracker-config2.yaml
Normal file
@ -0,0 +1,70 @@
|
||||
allow-list:
|
||||
severity:
|
||||
- high
|
||||
- critical
|
||||
deny-list:
|
||||
severity: low
|
||||
|
||||
# github contains configuration options for github issue tracker
|
||||
#github:
|
||||
# # base-url is the optional self-hosted github application url
|
||||
# base-url: ""
|
||||
# # username is the username of the github user
|
||||
# username: ""
|
||||
# # owner is the owner name of the repository for issues.
|
||||
# owner: ""
|
||||
# # token is the token for github account.
|
||||
# token: ""
|
||||
# # project-name is the name of the repository.
|
||||
# project-name: ""
|
||||
# # issue-label is the label of the created issue type
|
||||
# issue-label: ""
|
||||
|
||||
# gitlab contains configuration options for gitlab issue tracker
|
||||
#gitlab:
|
||||
# # base-url is the optional self-hosted gitlab application url
|
||||
# base-url: ""
|
||||
# # username is the username of the gitlab user
|
||||
# username: ""
|
||||
# # token is the token for gitlab account.
|
||||
# token: ""
|
||||
# # project-id is the ID of the repository.
|
||||
# project-id: ""
|
||||
# # issue-label is the label of the created issue type
|
||||
# issue-label: ""
|
||||
|
||||
# jira contains configuration options for jira issue tracker
|
||||
#jira:
|
||||
# # cloud is the boolean which tells if Jira instance is running in the cloud or on-prem version is used
|
||||
# cloud: true
|
||||
# # update-existing is the boolean which tells if the existing, opened issue should be updated or new one should be created
|
||||
# update-existing: false
|
||||
# # URL is the jira application url
|
||||
# url: ""
|
||||
# # account-id is the account-id of the jira user or username in case of on-prem Jira
|
||||
# account-id: ""
|
||||
# # email is the email of the user for jira instance
|
||||
# email: ""
|
||||
# # token is the token for jira instance or password in case of on-prem Jira
|
||||
# token: ""
|
||||
# # project-name is the name of the project.
|
||||
# project-name: ""
|
||||
# # issue-type is the name of the created issue type
|
||||
# issue-type: ""
|
||||
|
||||
# elasticsearch contains configuration options for elasticsearch exporter
|
||||
#elasticsearch:
|
||||
# # IP for elasticsearch instance
|
||||
# ip: 127.0.0.1
|
||||
# # Port is the port of elasticsearch instance
|
||||
# port: 9200
|
||||
# # IndexName is the name of the elasticsearch index
|
||||
# index-name: nuclei
|
||||
# # SSL enables ssl for elasticsearch connection
|
||||
# # ssl: false
|
||||
# # SSLVerification disables SSL verification for elasticsearch
|
||||
# # ssl-verification: false
|
||||
# # Username for the elasticsearch instance
|
||||
# # username: test
|
||||
# # Pasword is the password for elasticsearch instance
|
||||
# # password: test
|
||||
@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
)
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
# to specify which severities should be reported
|
||||
#allow-list:
|
||||
# severity: "critical, high"
|
||||
# severity: critical, high
|
||||
# to specify which severities should be excluded from reporting
|
||||
#deny-list:
|
||||
# severity: "info, low, medium"
|
||||
# severity: info, low, medium
|
||||
|
||||
# github contains configuration options for github issue tracker
|
||||
#github:
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"github.com/projectdiscovery/goflags"
|
||||
"github.com/projectdiscovery/gologger"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/runner"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
)
|
||||
|
||||
|
||||
@ -4,8 +4,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
|
||||
"github.com/projectdiscovery/gologger"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@ -19,10 +19,10 @@ import (
|
||||
"github.com/projectdiscovery/gologger"
|
||||
"github.com/projectdiscovery/hmap/store/hybrid"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/colorizer"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/catalog"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/loader"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/parsers"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/progress"
|
||||
@ -87,35 +87,10 @@ func New(options *types.Options) (*Runner, error) {
|
||||
}
|
||||
|
||||
runner.catalog = catalog.New(runner.options.TemplatesDirectory)
|
||||
var reportingOptions *reporting.Options
|
||||
if options.ReportingConfig != "" {
|
||||
file, err := os.Open(options.ReportingConfig)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not open reporting config file")
|
||||
}
|
||||
|
||||
reportingOptions = &reporting.Options{}
|
||||
if parseErr := yaml.NewDecoder(file).Decode(reportingOptions); parseErr != nil {
|
||||
file.Close()
|
||||
return nil, errors.Wrap(parseErr, "could not parse reporting config file")
|
||||
}
|
||||
file.Close()
|
||||
}
|
||||
if options.DiskExportDirectory != "" {
|
||||
if reportingOptions != nil {
|
||||
reportingOptions.DiskExporter = &disk.Options{Directory: options.DiskExportDirectory}
|
||||
} else {
|
||||
reportingOptions = &reporting.Options{}
|
||||
reportingOptions.DiskExporter = &disk.Options{Directory: options.DiskExportDirectory}
|
||||
}
|
||||
}
|
||||
if options.SarifExport != "" {
|
||||
if reportingOptions != nil {
|
||||
reportingOptions.SarifExporter = &sarif.Options{File: options.SarifExport}
|
||||
} else {
|
||||
reportingOptions = &reporting.Options{}
|
||||
reportingOptions.SarifExporter = &sarif.Options{File: options.SarifExport}
|
||||
}
|
||||
reportingOptions, err := createReportingOptions(options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if reportingOptions != nil {
|
||||
client, err := reporting.New(reportingOptions, options.ReportingDB)
|
||||
@ -271,6 +246,40 @@ func New(options *types.Options) (*Runner, error) {
|
||||
return runner, nil
|
||||
}
|
||||
|
||||
func createReportingOptions(options *types.Options) (*reporting.Options, error) {
|
||||
var reportingOptions *reporting.Options
|
||||
if options.ReportingConfig != "" {
|
||||
file, err := os.Open(options.ReportingConfig)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not open reporting config file")
|
||||
}
|
||||
|
||||
reportingOptions = &reporting.Options{}
|
||||
if parseErr := yaml.NewDecoder(file).Decode(reportingOptions); parseErr != nil {
|
||||
file.Close()
|
||||
return nil, errors.Wrap(parseErr, "could not parse reporting config file")
|
||||
}
|
||||
file.Close()
|
||||
}
|
||||
if options.DiskExportDirectory != "" {
|
||||
if reportingOptions != nil {
|
||||
reportingOptions.DiskExporter = &disk.Options{Directory: options.DiskExportDirectory}
|
||||
} else {
|
||||
reportingOptions = &reporting.Options{}
|
||||
reportingOptions.DiskExporter = &disk.Options{Directory: options.DiskExportDirectory}
|
||||
}
|
||||
}
|
||||
if options.SarifExport != "" {
|
||||
if reportingOptions != nil {
|
||||
reportingOptions.SarifExporter = &sarif.Options{File: options.SarifExport}
|
||||
} else {
|
||||
reportingOptions = &reporting.Options{}
|
||||
reportingOptions.SarifExporter = &sarif.Options{File: options.SarifExport}
|
||||
}
|
||||
}
|
||||
return reportingOptions, nil
|
||||
}
|
||||
|
||||
// Close releases all the resources and cleans up
|
||||
func (r *Runner) Close() {
|
||||
if r.output != nil {
|
||||
|
||||
26
v2/internal/runner/runner_test.go
Normal file
26
v2/internal/runner/runner_test.go
Normal file
@ -0,0 +1,26 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
)
|
||||
|
||||
func Test_createReportingOptions(t *testing.T) {
|
||||
var options types.Options
|
||||
options.ReportingConfig = "../../../integration_tests/test-issue-tracker-config1.yaml"
|
||||
resultOptions, err := createReportingOptions(&options)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, resultOptions.AllowList.Severities, severity.Severities{severity.High, severity.Critical})
|
||||
assert.Equal(t, resultOptions.DenyList.Severities, severity.Severities{severity.Low})
|
||||
|
||||
options.ReportingConfig = "../../../integration_tests/test-issue-tracker-config2.yaml"
|
||||
resultOptions2, err := createReportingOptions(&options)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, resultOptions2.AllowList.Severities, resultOptions.AllowList.Severities)
|
||||
assert.Equal(t, resultOptions2.DenyList.Severities, resultOptions.DenyList.Severities)
|
||||
}
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"github.com/karrick/godirwalk"
|
||||
|
||||
"github.com/projectdiscovery/gologger"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/parsers"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
)
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
package severity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Severities []Severity
|
||||
|
||||
func (severities Severities) String() string {
|
||||
return strings.Join(severities.ToStringArray(), ", ")
|
||||
}
|
||||
|
||||
func (severities *Severities) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var marshalledSeverities string
|
||||
if err := unmarshal(&marshalledSeverities); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := severities.Set(marshalledSeverities); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (severities *Severities) Set(value string) error {
|
||||
inputSeverities := toStringSlice(value)
|
||||
|
||||
for _, inputSeverity := range inputSeverities {
|
||||
if err := setSeverity(severities, inputSeverity); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func setSeverity(severities *Severities, value string) error {
|
||||
computedSeverity, err := toSeverity(value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("'%s' is not a valid severity", value)
|
||||
}
|
||||
|
||||
// TODO change the Severities type to map[Severity]interface{}, where the values are struct{}{}, to "simulates" a "set" data structure
|
||||
*severities = append(*severities, computedSeverity)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (severities *Severities) ToStringArray() []string {
|
||||
var result []string
|
||||
for _, severity := range *severities {
|
||||
result = append(result, severity.String())
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func toStringSlice(value string) []string {
|
||||
var result []string
|
||||
if strings.Contains(value, ",") {
|
||||
slices := strings.Split(value, ",")
|
||||
result = append(result, slices...)
|
||||
} else {
|
||||
result = []string{value}
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -1,95 +0,0 @@
|
||||
package severity
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/jsonschema"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Severity int
|
||||
|
||||
const (
|
||||
Undefined Severity = iota
|
||||
Info
|
||||
Low
|
||||
Medium
|
||||
High
|
||||
Critical
|
||||
limit
|
||||
)
|
||||
|
||||
var severityMappings = map[Severity]string{
|
||||
Info: "info",
|
||||
Low: "low",
|
||||
Medium: "medium",
|
||||
High: "high",
|
||||
Critical: "critical",
|
||||
}
|
||||
|
||||
func toSeverity(valueToMap string) (Severity, error) {
|
||||
normalizedValue := normalizeValue(valueToMap)
|
||||
for key, currentValue := range severityMappings {
|
||||
if normalizedValue == currentValue {
|
||||
return key, nil
|
||||
}
|
||||
}
|
||||
return -1, errors.New("Invalid severity: " + valueToMap)
|
||||
}
|
||||
|
||||
func GetSupportedSeverities() Severities {
|
||||
var result []Severity
|
||||
for index := Severity(1); index < limit; index++ {
|
||||
result = append(result, index)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func normalizeValue(value string) string {
|
||||
return strings.TrimSpace(strings.ToLower(value))
|
||||
}
|
||||
|
||||
func (severity Severity) String() string {
|
||||
return severityMappings[severity]
|
||||
}
|
||||
|
||||
//nolint:exported,revive //prefer to be explicit about the name, and make it refactor-safe
|
||||
type SeverityHolder struct {
|
||||
Severity Severity
|
||||
}
|
||||
|
||||
func (severityHolder SeverityHolder) JSONSchemaType() *jsonschema.Type {
|
||||
gotType := &jsonschema.Type{
|
||||
Type: "string",
|
||||
Title: "severity of the template",
|
||||
Description: "Seriousness of the implications of the template",
|
||||
}
|
||||
for _, severity := range GetSupportedSeverities() {
|
||||
gotType.Enum = append(gotType.Enum, severity.String())
|
||||
}
|
||||
return gotType
|
||||
}
|
||||
|
||||
func (severityHolder *SeverityHolder) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var marshalledSeverity string
|
||||
if err := unmarshal(&marshalledSeverity); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
computedSeverity, err := toSeverity(marshalledSeverity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
severityHolder.Severity = computedSeverity
|
||||
return nil
|
||||
}
|
||||
|
||||
func (severityHolder *SeverityHolder) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(severityHolder.Severity.String())
|
||||
}
|
||||
|
||||
func (severityHolder SeverityHolder) MarshalYAML() (interface{}, error) {
|
||||
return severityHolder.Severity.String(), nil
|
||||
}
|
||||
@ -2,16 +2,17 @@ package testutils
|
||||
|
||||
import (
|
||||
"github.com/logrusorgru/aurora"
|
||||
"go.uber.org/ratelimit"
|
||||
|
||||
"github.com/projectdiscovery/gologger/levels"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/catalog"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/progress"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolinit"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
"go.uber.org/ratelimit"
|
||||
)
|
||||
|
||||
// Init initializes the protocols and their configurations
|
||||
|
||||
@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
// TagFilter is used to filter nuclei templates for tag based execution
|
||||
|
||||
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
func TestTagBasedFilter(t *testing.T) {
|
||||
|
||||
@ -4,9 +4,9 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/projectdiscovery/gologger"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/catalog"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/loader/filter"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/parsers"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/templates"
|
||||
|
||||
@ -1,13 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/jsonschema"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
|
||||
)
|
||||
|
||||
// Info contains metadata information about a template
|
||||
@ -25,7 +20,7 @@ type Info struct {
|
||||
// Multiple values can also be specified separated by commas.
|
||||
// examples:
|
||||
// - value: "\"<username>\""
|
||||
Authors StringSlice `json:"author,omitempty" yaml:"author,omitempty" jsonschema:"title=author of the template,description=Author is the author of the template,example=username"`
|
||||
Authors stringslice.StringSlice `json:"author,omitempty" yaml:"author,omitempty" jsonschema:"title=author of the template,description=Author is the author of the template,example=username"`
|
||||
// description: |
|
||||
// Any tags for the template.
|
||||
//
|
||||
@ -34,7 +29,7 @@ type Info struct {
|
||||
// examples:
|
||||
// - name: Example tags
|
||||
// value: "\"cve,cve2019,grafana,auth-bypass,dos\""
|
||||
Tags StringSlice `json:"tags,omitempty" yaml:"tags,omitempty" jsonschema:"title=tags of the template,description=Any tags for the template"`
|
||||
Tags stringslice.StringSlice `json:"tags,omitempty" yaml:"tags,omitempty" jsonschema:"title=tags of the template,description=Any tags for the template"`
|
||||
// description: |
|
||||
// Description of the template.
|
||||
//
|
||||
@ -52,7 +47,7 @@ type Info struct {
|
||||
// examples:
|
||||
// - value: >
|
||||
// []string{"https://github.com/strapi/strapi", "https://github.com/getgrav/grav"}
|
||||
Reference StringSlice `json:"reference,omitempty" yaml:"reference,omitempty" jsonschema:"title=references for the template,description=Links relevant to the template"`
|
||||
Reference stringslice.StringSlice `json:"reference,omitempty" yaml:"reference,omitempty" jsonschema:"title=references for the template,description=Links relevant to the template"`
|
||||
// description: |
|
||||
// Severity of the template.
|
||||
//
|
||||
@ -62,7 +57,7 @@ type Info struct {
|
||||
// - medium
|
||||
// - high
|
||||
// - critical
|
||||
SeverityHolder severity.SeverityHolder `json:"severity,omitempty" yaml:"severity,omitempty"`
|
||||
SeverityHolder severity.Holder `json:"severity,omitempty" yaml:"severity,omitempty"`
|
||||
// description: |
|
||||
// AdditionalFields regarding metadata of the template.
|
||||
//
|
||||
@ -71,84 +66,3 @@ type Info struct {
|
||||
// map[string]string{"customField1":"customValue1"}
|
||||
AdditionalFields map[string]string `json:"additional-fields,omitempty" yaml:"additional-fields,omitempty" jsonschema:"title=additional metadata for the template,description=Additional metadata fields for the template"`
|
||||
}
|
||||
|
||||
// StringSlice represents a single (in-lined) or multiple string value(s).
|
||||
// The unmarshaller does not automatically convert in-lined strings to []string, hence the interface{} type is required.
|
||||
type StringSlice struct {
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) JSONSchemaType() *jsonschema.Type {
|
||||
gotType := &jsonschema.Type{
|
||||
OneOf: []*jsonschema.Type{{Type: "string"}, {Type: "array"}},
|
||||
}
|
||||
return gotType
|
||||
}
|
||||
|
||||
func (stringSlice *StringSlice) IsEmpty() bool {
|
||||
return len(stringSlice.ToSlice()) == 0
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) ToSlice() []string {
|
||||
switch value := stringSlice.Value.(type) {
|
||||
case string:
|
||||
return []string{value}
|
||||
case []string:
|
||||
return value
|
||||
case nil:
|
||||
return []string{}
|
||||
default:
|
||||
panic(fmt.Sprintf("Unexpected StringSlice type: '%T'", value))
|
||||
}
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) String() string {
|
||||
return strings.Join(stringSlice.ToSlice(), ", ")
|
||||
}
|
||||
|
||||
func (stringSlice *StringSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
marshalledSlice, err := marshalStringToSlice(unmarshal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result := make([]string, 0, len(marshalledSlice))
|
||||
//nolint:gosimple,nolintlint //cannot be replaced with result = append(result, slices...) because the values are being normalized
|
||||
for _, value := range marshalledSlice {
|
||||
result = append(result, strings.ToLower(strings.TrimSpace(value))) // TODO do we need to introduce RawStringSlice and/or NormalizedStringSlices?
|
||||
}
|
||||
stringSlice.Value = result
|
||||
return nil
|
||||
}
|
||||
|
||||
func marshalStringToSlice(unmarshal func(interface{}) error) ([]string, error) {
|
||||
var marshalledValueAsString string
|
||||
var marshalledValuesAsSlice []string
|
||||
|
||||
sliceMarshalError := unmarshal(&marshalledValuesAsSlice)
|
||||
if sliceMarshalError != nil {
|
||||
stringMarshalError := unmarshal(&marshalledValueAsString)
|
||||
if stringMarshalError != nil {
|
||||
return nil, stringMarshalError
|
||||
}
|
||||
}
|
||||
|
||||
var result []string
|
||||
if len(marshalledValuesAsSlice) > 0 {
|
||||
result = marshalledValuesAsSlice
|
||||
} else if utils.IsNotBlank(marshalledValueAsString) {
|
||||
result = strings.Split(marshalledValueAsString, ",")
|
||||
} else {
|
||||
result = []string{}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) MarshalYAML() (interface{}, error) {
|
||||
return stringSlice.Value, nil
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(stringSlice.Value)
|
||||
}
|
||||
|
||||
@ -5,20 +5,22 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestInfoJsonMarshal(t *testing.T) {
|
||||
info := Info{
|
||||
Name: "Test Template Name",
|
||||
Authors: StringSlice{[]string{"forgedhallpass", "ice3man"}},
|
||||
Authors: stringslice.StringSlice{Value: []string{"forgedhallpass", "ice3man"}},
|
||||
Description: "Test description",
|
||||
SeverityHolder: severity.SeverityHolder{Severity: severity.High},
|
||||
Tags: StringSlice{[]string{"cve", "misc"}},
|
||||
Reference: StringSlice{"reference1"},
|
||||
SeverityHolder: severity.Holder{Severity: severity.High},
|
||||
Tags: stringslice.StringSlice{Value: []string{"cve", "misc"}},
|
||||
Reference: stringslice.StringSlice{Value: "reference1"},
|
||||
}
|
||||
|
||||
result, err := json.Marshal(&info)
|
||||
@ -31,11 +33,11 @@ func TestInfoJsonMarshal(t *testing.T) {
|
||||
func TestInfoYamlMarshal(t *testing.T) {
|
||||
info := Info{
|
||||
Name: "Test Template Name",
|
||||
Authors: StringSlice{[]string{"forgedhallpass", "ice3man"}},
|
||||
Authors: stringslice.StringSlice{Value: []string{"forgedhallpass", "ice3man"}},
|
||||
Description: "Test description",
|
||||
SeverityHolder: severity.SeverityHolder{Severity: severity.High},
|
||||
Tags: StringSlice{[]string{"cve", "misc"}},
|
||||
Reference: StringSlice{"reference1"},
|
||||
SeverityHolder: severity.Holder{Severity: severity.High},
|
||||
Tags: stringslice.StringSlice{Value: []string{"cve", "misc"}},
|
||||
Reference: stringslice.StringSlice{Value: "reference1"},
|
||||
}
|
||||
|
||||
result, err := yaml.Marshal(&info)
|
||||
|
||||
62
v2/pkg/model/types/severity/severities.go
Normal file
62
v2/pkg/model/types/severity/severities.go
Normal file
@ -0,0 +1,62 @@
|
||||
package severity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/projectdiscovery/goflags"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
|
||||
)
|
||||
|
||||
// Severities used by the goflags library for parsing an array of Severity types, passed as CLI arguments from the user
|
||||
type Severities []Severity
|
||||
|
||||
func (severities *Severities) Set(values string) error {
|
||||
inputSeverities, err := goflags.ToNormalizedStringSlice(values)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, inputSeverity := range inputSeverities {
|
||||
if err := setSeverity(severities, inputSeverity); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (severities *Severities) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var stringSliceValue stringslice.StringSlice
|
||||
if err := unmarshal(&stringSliceValue); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stringSLice := stringSliceValue.ToSlice()
|
||||
var result = make(Severities, 0, len(stringSLice))
|
||||
for _, severityString := range stringSLice {
|
||||
if err := setSeverity(&result, severityString); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
*severities = result
|
||||
return nil
|
||||
}
|
||||
|
||||
func (severities Severities) String() string {
|
||||
var stringSeverities []string
|
||||
for _, severity := range severities {
|
||||
stringSeverities = append(stringSeverities, severity.String())
|
||||
}
|
||||
return strings.Join(stringSeverities, ", ")
|
||||
}
|
||||
|
||||
func setSeverity(severities *Severities, value string) error {
|
||||
computedSeverity, err := toSeverity(value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("'%s' is not a valid severity", value)
|
||||
}
|
||||
|
||||
// TODO change the Severities type to map[Severity]interface{}, where the values are struct{}{}, to "simulates" a "set" data structure
|
||||
*severities = append(*severities, computedSeverity)
|
||||
return nil
|
||||
}
|
||||
53
v2/pkg/model/types/severity/severity.go
Normal file
53
v2/pkg/model/types/severity/severity.go
Normal file
@ -0,0 +1,53 @@
|
||||
package severity
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Severity int
|
||||
|
||||
const (
|
||||
Undefined Severity = iota
|
||||
Info
|
||||
Low
|
||||
Medium
|
||||
High
|
||||
Critical
|
||||
limit
|
||||
)
|
||||
|
||||
var severityMappings = map[Severity]string{
|
||||
Info: "info",
|
||||
Low: "low",
|
||||
Medium: "medium",
|
||||
High: "high",
|
||||
Critical: "critical",
|
||||
}
|
||||
|
||||
func GetSupportedSeverities() Severities {
|
||||
var result []Severity
|
||||
for index := Severity(1); index < limit; index++ {
|
||||
result = append(result, index)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func toSeverity(valueToMap string) (Severity, error) {
|
||||
normalizedValue := normalizeValue(valueToMap)
|
||||
for key, currentValue := range severityMappings {
|
||||
if normalizedValue == currentValue {
|
||||
return key, nil
|
||||
}
|
||||
}
|
||||
return -1, errors.New("Invalid severity: " + valueToMap)
|
||||
}
|
||||
|
||||
func normalizeValue(value string) string {
|
||||
return strings.TrimSpace(strings.ToLower(value))
|
||||
}
|
||||
|
||||
func (severity Severity) String() string {
|
||||
return severityMappings[severity]
|
||||
}
|
||||
48
v2/pkg/model/types/severity/severity_holder.go
Normal file
48
v2/pkg/model/types/severity/severity_holder.go
Normal file
@ -0,0 +1,48 @@
|
||||
package severity
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/alecthomas/jsonschema"
|
||||
)
|
||||
|
||||
//nolint:exported,revive //prefer to be explicit about the name, and make it refactor-safe
|
||||
// Holder holds a Severity type. Required for un/marshalling purposes
|
||||
type Holder struct {
|
||||
Severity Severity
|
||||
}
|
||||
|
||||
func (severityHolder Holder) JSONSchemaType() *jsonschema.Type {
|
||||
gotType := &jsonschema.Type{
|
||||
Type: "string",
|
||||
Title: "severity of the template",
|
||||
Description: "Seriousness of the implications of the template",
|
||||
}
|
||||
for _, severity := range GetSupportedSeverities() {
|
||||
gotType.Enum = append(gotType.Enum, severity.String())
|
||||
}
|
||||
return gotType
|
||||
}
|
||||
|
||||
func (severityHolder *Holder) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var marshalledSeverity string
|
||||
if err := unmarshal(&marshalledSeverity); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
computedSeverity, err := toSeverity(marshalledSeverity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
severityHolder.Severity = computedSeverity
|
||||
return nil
|
||||
}
|
||||
|
||||
func (severityHolder *Holder) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(severityHolder.Severity.String())
|
||||
}
|
||||
|
||||
func (severityHolder Holder) MarshalYAML() (interface{}, error) {
|
||||
return severityHolder.Severity.String(), nil
|
||||
}
|
||||
@ -13,7 +13,7 @@ func TestYamlUnmarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestYamlMarshal(t *testing.T) {
|
||||
severity := SeverityHolder{Severity: High}
|
||||
severity := Holder{Severity: High}
|
||||
|
||||
marshalled, err := severity.MarshalYAML()
|
||||
assert.Nil(t, err, "could not marshal yaml")
|
||||
@ -51,8 +51,8 @@ func testUnmarshalFail(t *testing.T, unmarshaller func(data []byte, v interface{
|
||||
assert.Panics(t, func() { unmarshal(payloadCreator("invalid"), unmarshaller) })
|
||||
}
|
||||
|
||||
func unmarshal(value string, unmarshaller func(data []byte, v interface{}) error) SeverityHolder {
|
||||
severityStruct := SeverityHolder{}
|
||||
func unmarshal(value string, unmarshaller func(data []byte, v interface{}) error) Holder {
|
||||
severityStruct := Holder{}
|
||||
var err = unmarshaller([]byte(value), &severityStruct)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
92
v2/pkg/model/types/stringslice/stringslice.go
Normal file
92
v2/pkg/model/types/stringslice/stringslice.go
Normal file
@ -0,0 +1,92 @@
|
||||
package stringslice
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/jsonschema"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
||||
)
|
||||
|
||||
// StringSlice represents a single (in-lined) or multiple string value(s).
|
||||
// The unmarshaller does not automatically convert in-lined strings to []string, hence the interface{} type is required.
|
||||
type StringSlice struct {
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) JSONSchemaType() *jsonschema.Type {
|
||||
gotType := &jsonschema.Type{
|
||||
OneOf: []*jsonschema.Type{{Type: "string"}, {Type: "array"}},
|
||||
}
|
||||
return gotType
|
||||
}
|
||||
|
||||
func (stringSlice *StringSlice) IsEmpty() bool {
|
||||
return len(stringSlice.ToSlice()) == 0
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) ToSlice() []string {
|
||||
switch value := stringSlice.Value.(type) {
|
||||
case string:
|
||||
return []string{value}
|
||||
case []string:
|
||||
return value
|
||||
case nil:
|
||||
return []string{}
|
||||
default:
|
||||
panic(fmt.Sprintf("Unexpected StringSlice type: '%T'", value))
|
||||
}
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) String() string {
|
||||
return strings.Join(stringSlice.ToSlice(), ", ")
|
||||
}
|
||||
|
||||
func (stringSlice *StringSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
marshalledSlice, err := marshalStringToSlice(unmarshal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result := make([]string, 0, len(marshalledSlice))
|
||||
//nolint:gosimple,nolintlint //cannot be replaced with result = append(result, slices...) because the values are being normalized
|
||||
for _, value := range marshalledSlice {
|
||||
result = append(result, strings.ToLower(strings.TrimSpace(value))) // TODO do we need to introduce RawStringSlice and/or NormalizedStringSlices?
|
||||
}
|
||||
stringSlice.Value = result
|
||||
return nil
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) MarshalYAML() (interface{}, error) {
|
||||
return stringSlice.Value, nil
|
||||
}
|
||||
|
||||
func (stringSlice StringSlice) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(stringSlice.Value)
|
||||
}
|
||||
|
||||
func marshalStringToSlice(unmarshal func(interface{}) error) ([]string, error) {
|
||||
var marshalledValueAsString string
|
||||
var marshalledValuesAsSlice []string
|
||||
|
||||
sliceMarshalError := unmarshal(&marshalledValuesAsSlice)
|
||||
if sliceMarshalError != nil {
|
||||
stringMarshalError := unmarshal(&marshalledValueAsString)
|
||||
if stringMarshalError != nil {
|
||||
return nil, stringMarshalError
|
||||
}
|
||||
}
|
||||
|
||||
var result []string
|
||||
if len(marshalledValuesAsSlice) > 0 {
|
||||
result = marshalledValuesAsSlice
|
||||
} else if utils.IsNotBlank(marshalledValueAsString) {
|
||||
result = strings.Split(marshalledValueAsString, ",")
|
||||
} else {
|
||||
result = []string{}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@ -13,8 +13,8 @@ import (
|
||||
|
||||
"github.com/projectdiscovery/interactsh/pkg/server"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/colorizer"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
)
|
||||
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
func TestDNSCompileMake(t *testing.T) {
|
||||
@ -25,7 +25,7 @@ func TestDNSCompileMake(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile dns request")
|
||||
|
||||
@ -8,9 +8,9 @@ import (
|
||||
"github.com/miekg/dns"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
@ -32,7 +32,7 @@ func TestResponseToDSLMap(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile dns request")
|
||||
@ -64,7 +64,7 @@ func TestDNSOperatorMatch(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile dns request")
|
||||
@ -147,7 +147,7 @@ func TestDNSOperatorExtract(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile dns request")
|
||||
@ -217,7 +217,7 @@ func TestDNSMakeResult(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile dns request")
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
@ -42,7 +42,7 @@ func TestDNSExecuteWithResults(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile dns request")
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
func TestFileCompile(t *testing.T) {
|
||||
@ -24,7 +24,7 @@ func TestFileCompile(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
|
||||
@ -8,9 +8,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
func TestFindInputPaths(t *testing.T) {
|
||||
@ -27,7 +27,7 @@ func TestFindInputPaths(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
@ -28,7 +28,7 @@ func TestResponseToDSLMap(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
@ -53,7 +53,7 @@ func TestFileOperatorMatch(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
@ -118,7 +118,7 @@ func TestFileOperatorExtract(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
@ -183,7 +183,7 @@ func TestFileMakeResult(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
|
||||
@ -6,14 +6,15 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestFileExecuteWithResults(t *testing.T) {
|
||||
@ -43,7 +44,7 @@ func TestFileExecuteWithResults(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
|
||||
@ -4,10 +4,11 @@ import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
func TestBaseURLWithTemplatePrefs(t *testing.T) {
|
||||
@ -77,7 +78,7 @@ func TestMakeRequestFromModal(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile http request")
|
||||
@ -104,7 +105,7 @@ func TestMakeRequestFromModalTrimSuffixSlash(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile http request")
|
||||
@ -142,7 +143,7 @@ Accept-Encoding: gzip`},
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile http request")
|
||||
@ -181,7 +182,7 @@ Accept-Encoding: gzip`},
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile http request")
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
func TestHTTPCompile(t *testing.T) {
|
||||
@ -32,7 +32,7 @@ Accept-Encoding: gzip`},
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile http request")
|
||||
|
||||
@ -14,13 +14,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/proxy"
|
||||
"golang.org/x/net/publicsuffix"
|
||||
|
||||
"github.com/projectdiscovery/fastdialer/fastdialer"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/protocolstate"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
||||
"github.com/projectdiscovery/rawhttp"
|
||||
"github.com/projectdiscovery/retryablehttp-go"
|
||||
"golang.org/x/net/proxy"
|
||||
"golang.org/x/net/publicsuffix"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@ -7,9 +7,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
@ -29,7 +29,7 @@ func TestResponseToDSLMap(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
@ -59,7 +59,7 @@ func TestHTTPOperatorMatch(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
@ -129,7 +129,7 @@ func TestHTTPOperatorExtract(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
@ -240,7 +240,7 @@ func TestHTTPMakeResult(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile file request")
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
func TestNetworkCompileMake(t *testing.T) {
|
||||
@ -23,7 +23,7 @@ func TestNetworkCompileMake(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile network request")
|
||||
|
||||
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
@ -27,7 +27,7 @@ func TestResponseToDSLMap(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile network request")
|
||||
@ -52,7 +52,7 @@ func TestNetworkOperatorMatch(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile network request")
|
||||
@ -115,7 +115,7 @@ func TestNetworkOperatorExtract(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile network request")
|
||||
@ -178,7 +178,7 @@ func TestNetworkMakeResult(t *testing.T) {
|
||||
}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err := request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile network request")
|
||||
|
||||
@ -10,9 +10,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
@ -55,7 +55,7 @@ func TestNetworkExecuteWithResults(t *testing.T) {
|
||||
request.Inputs = append(request.Inputs, &Input{Data: fmt.Sprintf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", parsed.Host)})
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
err = request.Compile(executerOpts)
|
||||
require.Nil(t, err, "could not compile network request")
|
||||
|
||||
@ -8,9 +8,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
)
|
||||
|
||||
@ -22,7 +22,7 @@ func TestFindResponses(t *testing.T) {
|
||||
request := &Request{}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
executerOpts.Operators = []*operators.Operators{{}}
|
||||
err := request.Compile(executerOpts)
|
||||
|
||||
@ -7,9 +7,9 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/testutils"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
@ -24,7 +24,7 @@ func TestResponseToDSLMap(t *testing.T) {
|
||||
request := &Request{}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
executerOpts.Operators = []*operators.Operators{{}}
|
||||
err := request.Compile(executerOpts)
|
||||
@ -50,7 +50,7 @@ func TestHTTPOperatorMatch(t *testing.T) {
|
||||
request := &Request{}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
executerOpts.Operators = []*operators.Operators{{}}
|
||||
err := request.Compile(executerOpts)
|
||||
@ -116,7 +116,7 @@ func TestHTTPOperatorExtract(t *testing.T) {
|
||||
request := &Request{}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
executerOpts.Operators = []*operators.Operators{{}}
|
||||
err := request.Compile(executerOpts)
|
||||
@ -169,7 +169,7 @@ func TestHTTPMakeResult(t *testing.T) {
|
||||
request := &Request{}
|
||||
executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{
|
||||
ID: templateID,
|
||||
Info: model.Info{SeverityHolder: severity.SeverityHolder{Severity: severity.Low}, Name: "test"},
|
||||
Info: model.Info{SeverityHolder: severity.Holder{Severity: severity.Low}, Name: "test"},
|
||||
})
|
||||
executerOpts.Operators = []*operators.Operators{{
|
||||
Matchers: []*matchers.Matcher{{
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/owenrumney/go-sarif/sarif"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/format"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
|
||||
|
||||
@ -6,18 +6,19 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
|
||||
)
|
||||
|
||||
func TestToMarkdownTableString(t *testing.T) {
|
||||
info := model.Info{
|
||||
Name: "Test Template Name",
|
||||
Authors: model.StringSlice{Value: []string{"forgedhallpass", "ice3man"}},
|
||||
Authors: stringslice.StringSlice{Value: []string{"forgedhallpass", "ice3man"}},
|
||||
Description: "Test description",
|
||||
SeverityHolder: severity.SeverityHolder{Severity: severity.High},
|
||||
Tags: model.StringSlice{Value: []string{"cve", "misc"}},
|
||||
Reference: model.StringSlice{Value: "reference1"},
|
||||
SeverityHolder: severity.Holder{Severity: severity.High},
|
||||
Tags: stringslice.StringSlice{Value: []string{"cve", "misc"}},
|
||||
Reference: stringslice.StringSlice{Value: "reference1"},
|
||||
AdditionalFields: map[string]string{
|
||||
"customDynamicKey1": "customDynamicValue1",
|
||||
"customDynamicKey2": "customDynamicValue2",
|
||||
|
||||
@ -6,8 +6,8 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/multierr"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/output"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/dedupe"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/reporting/exporters/disk"
|
||||
@ -41,8 +41,8 @@ type Options struct {
|
||||
// Filter filters the received event and decides whether to perform
|
||||
// reporting for it or not.
|
||||
type Filter struct {
|
||||
Severities severity.Severities `yaml:"severity"`
|
||||
Tags model.StringSlice `yaml:"tags"`
|
||||
Severities severity.Severities `yaml:"severity"`
|
||||
Tags stringslice.StringSlice `yaml:"tags"`
|
||||
}
|
||||
|
||||
// GetMatch returns true if a filter matches result event
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// Package templates
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
// Package templates
|
||||
//nolint //do not lint as examples with no usage
|
||||
package templates
|
||||
|
||||
import (
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/extractors"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/operators/matchers"
|
||||
@ -16,10 +18,10 @@ import (
|
||||
var (
|
||||
exampleInfoStructure = model.Info{
|
||||
Name: "Argument Injection in Ruby Dragonfly",
|
||||
Authors: model.StringSlice{"0xspara"},
|
||||
SeverityHolder: severity.SeverityHolder{severity.High},
|
||||
Reference: model.StringSlice{"https://zxsecurity.co.nz/research/argunment-injection-ruby-dragonfly/"},
|
||||
Tags: model.StringSlice{"cve,cve2021,rce,ruby"},
|
||||
Authors: stringslice.StringSlice{Value: "0xspara"},
|
||||
SeverityHolder: severity.Holder{Severity: severity.High},
|
||||
Reference: stringslice.StringSlice{Value: "https://zxsecurity.co.nz/research/argunment-injection-ruby-dragonfly/"},
|
||||
Tags: stringslice.StringSlice{Value: "cve,cve2021,rce,ruby"},
|
||||
}
|
||||
exampleNormalHTTPRequest = &http.Request{
|
||||
Method: "GET",
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
// JSONScalarToString converts an interface coming from json to string
|
||||
@ -62,7 +62,7 @@ func ToString(data interface{}) string {
|
||||
return strconv.FormatUint(uint64(s), 10)
|
||||
case []byte:
|
||||
return string(s)
|
||||
case severity.SeverityHolder:
|
||||
case severity.Holder:
|
||||
return s.Severity.String()
|
||||
case severity.Severity:
|
||||
return s.String()
|
||||
|
||||
@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/projectdiscovery/goflags"
|
||||
"github.com/projectdiscovery/nuclei/v2/internal/severity"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity"
|
||||
)
|
||||
|
||||
// Options contains the configuration options for nuclei scanner.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package workflows
|
||||
|
||||
import (
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/model/types/stringslice"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols"
|
||||
)
|
||||
|
||||
@ -26,7 +26,7 @@ type WorkflowTemplate struct {
|
||||
Template string `yaml:"template,omitempty" jsonschema:"title=template/directory to execute,description=Template or directory to execute as part of workflow"`
|
||||
// description: |
|
||||
// Tags to run templates based on.
|
||||
Tags model.StringSlice `yaml:"tags,omitempty" jsonschema:"title=tags to execute,description=Tags to run template based on"`
|
||||
Tags stringslice.StringSlice `yaml:"tags,omitempty" jsonschema:"title=tags to execute,description=Tags to run template based on"`
|
||||
// description: |
|
||||
// Matchers perform name based matching to run subtemplates for a workflow.
|
||||
Matchers []*Matcher `yaml:"matchers,omitempty" jsonschema:"title=name based template result matchers,description=Matchers perform name based matching to run subtemplates for a workflow"`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user