Skip to content

Commit

Permalink
Preserve reference links as case-sensitive while unmarshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M committed Apr 24, 2024
1 parent e480d13 commit 65f5dea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/model/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestUnmarshal(t *testing.T) {
templateName := "Test Template"
authors := []string{"forgedhallpass", "ice3man"}
tags := []string{"cve", "misc"}
references := []string{"http://test.com", "http://domain.com"}
references := []string{"http://test.com", "http://Domain.com"}

dynamicKey1 := "customDynamicKey1"
dynamicKey2 := "customDynamicKey2"
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestUnmarshal(t *testing.T) {
author: ` + strings.Join(authors, ", ") + `
tags: ` + strings.Join(tags, ", ") + `
severity: critical
reference: ` + strings.Join(references, ", ") + `
reference: ` + strings.Join(references, ",") + `
metadata:
` + dynamicKey1 + `: ` + dynamicKeysMap[dynamicKey1].(string) + `
` + dynamicKey2 + `: ` + dynamicKeysMap[dynamicKey2].(string) + `
Expand Down
9 changes: 9 additions & 0 deletions pkg/model/types/stringslice/stringslice_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ func (rawStringSlice *RawStringSlice) Normalize(value string) string {
return value
}

func (rawStringSlice *RawStringSlice) UnmarshalYAML(unmarshal func(interface{}) error) error {
marshalledSlice, err := marshalStringToSlice(unmarshal)
if err != nil {
return err
}
rawStringSlice.Value = marshalledSlice
return nil
}

func (rawStringSlice RawStringSlice) JSONSchemaAlias() any {
return StringOrSlice("")
}

0 comments on commit 65f5dea

Please sign in to comment.