Skip to content

Commit

Permalink
Add changes
Browse files Browse the repository at this point in the history
  • Loading branch information
piyushroshan committed Nov 22, 2024
1 parent b1bc13f commit 53eb0f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion experimental/types/value_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func NewDataMetadataList() DataMetadataList {

func (v *DataMetadataList) EvaluateMetadata(data string) {
// we do the analysis only once
if !v.evaluated {
if v != nil && !v.evaluated {
v.metadata = make(map[DataMetadata]bool)
v.evaluateBoolean(data)
v.evaluateNumeric(data)
Expand Down
3 changes: 3 additions & 0 deletions internal/corazarules/rule_match.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func (m MatchData) ChainLevel() int {

func (m *MatchData) DataMetadata() experimentalTypes.DataMetadataList {
// Evaluate the metadata if it's not set
if m.Metadata_ == nil {
m.Metadata_ = &experimentalTypes.DataMetadataList{}
}
m.Metadata_.EvaluateMetadata(m.Value_)
return *m.Metadata_
}
Expand Down
3 changes: 3 additions & 0 deletions internal/seclang/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func TestAllowedMetadataTagsInspectionEnabled(t *testing.T) {
t.Error(err)
}
tx := waf.NewTransaction()
tx.SetMetadataInspection(true)
tx.AddRequestHeader("Content-Type", "application/json")
tx.ProcessURI("http://localhost/test.php", "GET", "1.1")
tx.ProcessRequestHeaders()
Expand Down Expand Up @@ -210,6 +211,7 @@ func BenchmarkAllowedMetadataTagsInspectionEnabled(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
tx := waf.NewTransaction()
tx.SetMetadataInspection(true)
tx.AddRequestHeader("Content-Type", "application/json")
tx.ProcessURI("http://localhost/test.php", "GET", "1.1")
tx.ProcessRequestHeaders()
Expand Down Expand Up @@ -267,6 +269,7 @@ func BenchmarkAllowedMetadataTagsInspectionDisabled(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
tx := waf.NewTransaction()
tx.SetMetadataInspection(false)
tx.AddRequestHeader("Content-Type", "application/json")
tx.SetMetadataInspection(false)
tx.ProcessURI("http://localhost/test.php", "GET", "1.1")
Expand Down

0 comments on commit 53eb0f8

Please sign in to comment.