Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit Empty Fields #3977

Merged
merged 6 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion v2/pkg/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Info struct {
// examples:
// - value: >
// []string{"https://github.com/strapi/strapi", "https://github.com/getgrav/grav"}
Reference stringslice.RawStringSlice `json:"reference,omitempty" yaml:"reference,omitempty" jsonschema:"title=references for the template,description=Links relevant to the template"`
Reference *stringslice.RawStringSlice `json:"reference,omitempty" yaml:"reference,omitempty" jsonschema:"title=references for the template,description=Links relevant to the template"`
// description: |
// Severity of the template.
SeverityHolder severity.Holder `json:"severity,omitempty" yaml:"severity,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions v2/pkg/model/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestInfoJsonMarshal(t *testing.T) {
Description: "Test description",
SeverityHolder: severity.Holder{Severity: severity.High},
Tags: stringslice.StringSlice{Value: []string{"cve", "misc"}},
Reference: stringslice.NewRaw("Reference1"),
Reference: stringslice.NewRawStringSlice("Reference1"),
Metadata: map[string]interface{}{
"string_key": "string_value",
"array_key": []string{"array_value1", "array_value2"},
Expand All @@ -42,7 +42,7 @@ func TestInfoYamlMarshal(t *testing.T) {
Description: "Test description",
SeverityHolder: severity.Holder{Severity: severity.High},
Tags: stringslice.StringSlice{Value: []string{"cve", "misc"}},
Reference: stringslice.NewRaw("Reference1"),
Reference: stringslice.NewRawStringSlice("Reference1"),
Metadata: map[string]interface{}{
"string_key": "string_value",
"array_key": []string{"array_value1", "array_value2"},
Expand Down
6 changes: 3 additions & 3 deletions v2/pkg/model/types/stringslice/stringslice_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ type RawStringSlice struct {
StringSlice
}

func NewRaw(value interface{}) RawStringSlice {
return RawStringSlice{StringSlice: StringSlice{Value: value}}
func NewRawStringSlice(value interface{}) *RawStringSlice {
return &RawStringSlice{StringSlice: StringSlice{Value: value}}
}

func (rawStringSlice RawStringSlice) Normalize(value string) string {
func (rawStringSlice *RawStringSlice) Normalize(value string) string {
return value
}
2 changes: 1 addition & 1 deletion v2/pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type ResultEvent struct {
// MatcherStatus is the status of the match
MatcherStatus bool `json:"matcher-status"`
// Lines is the line count for the specified match
Lines []int `json:"matched-line"`
Lines []int `json:"matched-line,omitempty"`

FileToIndexPosition map[string]int `json:"-"`
}
Expand Down
5 changes: 3 additions & 2 deletions v2/pkg/reporting/format/format_utils_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package format

import (
"github.com/stretchr/testify/assert"
"strings"
"testing"

"github.com/stretchr/testify/assert"

"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"
Expand All @@ -18,7 +19,7 @@ func TestToMarkdownTableString(t *testing.T) {
Description: "Test description",
SeverityHolder: severity.Holder{Severity: severity.High},
Tags: stringslice.StringSlice{Value: []string{"cve", "misc"}},
Reference: stringslice.NewRaw("reference1"),
Reference: stringslice.NewRawStringSlice("reference1"),
Metadata: map[string]interface{}{
"customDynamicKey1": "customDynamicValue1",
"customDynamicKey2": "customDynamicValue2",
Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/templates/templates_doc_examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
Name: "Argument Injection in Ruby Dragonfly",
Authors: stringslice.StringSlice{Value: "0xspara"},
SeverityHolder: severity.Holder{Severity: severity.High},
Reference: stringslice.NewRaw("https://zxsecurity.co.nz/research/argunment-injection-ruby-dragonfly/"),
Reference: stringslice.NewRawStringSlice("https://zxsecurity.co.nz/research/argunment-injection-ruby-dragonfly/"),
Tags: stringslice.StringSlice{Value: "cve,cve2021,rce,ruby"},
}
exampleNormalHTTPRequest = &http.Request{
Expand Down
Loading