From e450dee03d9adac3f59fabba92243430b89b693e Mon Sep 17 00:00:00 2001 From: Ramana Reddy <90540245+RamanaReddy0M@users.noreply.github.com> Date: Wed, 24 Apr 2024 18:44:59 +0530 Subject: [PATCH 1/2] Preserve reference links as case-sensitive while unmarshalling (#5098) --- pkg/model/model_test.go | 4 ++-- pkg/model/types/stringslice/stringslice_raw.go | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/model/model_test.go b/pkg/model/model_test.go index 3f87add2c9..cd2826405c 100644 --- a/pkg/model/model_test.go +++ b/pkg/model/model_test.go @@ -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" @@ -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) + ` diff --git a/pkg/model/types/stringslice/stringslice_raw.go b/pkg/model/types/stringslice/stringslice_raw.go index 7d9e470bfa..fa96c2cc3f 100644 --- a/pkg/model/types/stringslice/stringslice_raw.go +++ b/pkg/model/types/stringslice/stringslice_raw.go @@ -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("") } From cfe6f5da581942d290a5c9c739c8791564b480d7 Mon Sep 17 00:00:00 2001 From: Dogan Can Bakir <65292895+dogancanbakir@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:19:39 +0300 Subject: [PATCH 2/2] fix tests (#5092) --- pkg/protocols/dns/request_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/protocols/dns/request_test.go b/pkg/protocols/dns/request_test.go index 7275097b2c..f32a8c622b 100644 --- a/pkg/protocols/dns/request_test.go +++ b/pkg/protocols/dns/request_test.go @@ -37,7 +37,7 @@ func TestDNSExecuteWithResults(t *testing.T) { Name: "test", Part: "raw", Type: matchers.MatcherTypeHolder{MatcherType: matchers.WordsMatcher}, - Words: []string{"93.184.216.34"}, + Words: []string{"93.184.215.14"}, }}, Extractors: []*extractors.Extractor{{ Part: "raw", @@ -64,7 +64,7 @@ func TestDNSExecuteWithResults(t *testing.T) { require.Equal(t, 1, len(finalEvent.Results), "could not get correct number of results") require.Equal(t, "test", finalEvent.Results[0].MatcherName, "could not get correct matcher name of results") require.Equal(t, 1, len(finalEvent.Results[0].ExtractedResults), "could not get correct number of extracted results") - require.Equal(t, "93.184.216.34", finalEvent.Results[0].ExtractedResults[0], "could not get correct extracted results") + require.Equal(t, "93.184.215.14", finalEvent.Results[0].ExtractedResults[0], "could not get correct extracted results") finalEvent = nil t.Run("url-to-domain", func(t *testing.T) { @@ -79,6 +79,6 @@ func TestDNSExecuteWithResults(t *testing.T) { require.Equal(t, 1, len(finalEvent.Results), "could not get correct number of results") require.Equal(t, "test", finalEvent.Results[0].MatcherName, "could not get correct matcher name of results") require.Equal(t, 1, len(finalEvent.Results[0].ExtractedResults), "could not get correct number of extracted results") - require.Equal(t, "93.184.216.34", finalEvent.Results[0].ExtractedResults[0], "could not get correct extracted results") + require.Equal(t, "93.184.215.14", finalEvent.Results[0].ExtractedResults[0], "could not get correct extracted results") finalEvent = nil }