mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 22:35:27 +00:00
feat: added MarshalYAML to severities array + issue tracker options fix (#5166)
* feat: added MarshalYAML to severities array * fix issue with creation of reports
This commit is contained in:
parent
fed10a11e8
commit
6067b78bcf
@ -26,6 +26,14 @@ func (severities *Severities) Set(values string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (severities Severities) MarshalYAML() (interface{}, error) {
|
||||
var stringSeverities = make([]string, 0, len(severities))
|
||||
for _, severity := range severities {
|
||||
stringSeverities = append(stringSeverities, severity.String())
|
||||
}
|
||||
return stringSeverities, nil
|
||||
}
|
||||
|
||||
func (severities *Severities) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var stringSliceValue stringslice.StringSlice
|
||||
if err := unmarshal(&stringSliceValue); err != nil {
|
||||
|
||||
@ -74,3 +74,12 @@ func TestMarshalJSON(t *testing.T) {
|
||||
}
|
||||
require.Equal(t, "[\"low\",\"medium\"]", string(data), "could not marshal json")
|
||||
}
|
||||
|
||||
func TestSeveritiesMarshalYaml(t *testing.T) {
|
||||
unmarshalled := Severities{Low, Medium}
|
||||
marshalled, err := yaml.Marshal(unmarshalled)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
require.Equal(t, "- low\n- medium\n", string(marshalled), "could not marshal yaml")
|
||||
}
|
||||
|
||||
@ -276,6 +276,7 @@ func (c *ReportingClient) CreateIssue(event *output.ResultEvent) error {
|
||||
if tracker.ShouldFilter(event) {
|
||||
continue
|
||||
}
|
||||
|
||||
trackerName := tracker.Name()
|
||||
stats, statsOk := c.stats[trackerName]
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
|
||||
// ShouldFilter determines if an issue should be logged to this tracker
|
||||
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
|
||||
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {
|
||||
|
||||
@ -176,7 +176,7 @@ func (i *Integration) Name() string {
|
||||
// ShouldFilter determines if an issue should be logged to this tracker
|
||||
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
|
||||
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {
|
||||
|
||||
@ -165,7 +165,7 @@ func (i *Integration) CloseIssue(event *output.ResultEvent) error {
|
||||
// ShouldFilter determines if an issue should be logged to this tracker
|
||||
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
|
||||
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {
|
||||
|
||||
@ -315,7 +315,7 @@ func (i *Integration) FindExistingIssue(event *output.ResultEvent) (jira.Issue,
|
||||
// ShouldFilter determines if an issue should be logged to this tracker
|
||||
func (i *Integration) ShouldFilter(event *output.ResultEvent) bool {
|
||||
if i.options.AllowList != nil && i.options.AllowList.GetMatch(event) {
|
||||
return true
|
||||
return false
|
||||
}
|
||||
|
||||
if i.options.DenyList != nil && i.options.DenyList.GetMatch(event) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user